Assignment 3: Word statistics with linked lists
Preparations: | Net lesson 5 with material about linked lists. |
Examination: | Orally in the computer lab no later than December 14, 2020. |
The same problem as assignment 2 for grade 3 but the words should be stored in a sorted linked list.
Sample output: | List illustration: | |
Array 2
EOF 2
Linked 2
List 1
NULL 4
Node 4
Unsorted 1
add 3
array 1
buffer 7
c 7
char 9
cons 2
count 2
ctype 1
d 2
else 2
|
|
Work flow
-
Write the declarations for list nodes containing a word pointer,
an
int
for the frequency and a pointer to the next node. - Write a constructor function for list nodes.
-
Write an
add
function that searches the list for a word. If the word is found, its frequency should be updated. If not, it should be created in such way that the list stays sorted.
Hint: Look at the section "A sorted list" in lesson 5. -
Write a
print
function for word lists. - Run with your program as input.