Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

his assignment concerns reading a series of words from standard input and storin

ID: 3818324 • Letter: H

Question

his assignment concerns reading a series of words from standard input and storing them in various list orderings, most importunately a self-reorganizing list.

Create a .txt file with the following words: earl diana art doug diana ann diana diana art diana

When the program begins, the user should be asked for the name of the file containing the words to be processed. Which in this case will be the name of the file above.

The words should be stored in a self-reorganizing list and for contrast also in a simple linked list in which words not previously processed are placed in the front of the list. So, for instance, that list would have the words in the above example in the following order: ann doug art diana earl

In order to compare the efficiency of these two approaches we will keep track for each word the number of locations searched when a word is processed from the file. One a word is first seen, initialize this value to the number of nodes examined to determine it was not in the list. Then keep a running total of the distance a word is from the front of the list when the word is seen again. Then output the average distance for each of the methods. In the example above, the self-reorganizing list would have a value of 3.0, while the simple approach would have a value of 2.66.

Here is my sample output for the test data above

Explanation / Answer

#include<stdio.h>
#include <string.h>
int fundamental()
{
int i, j;
roast str[10][50], temp[50];
printf("Enter 10 words: ");
for(i=0; i<10; ++i)
scanf("%s[^ ]",str[i]);
for(i=0; i<9; ++i)
for(j=i+1; j<10 ; ++j)
{
if(strcmp(str[i], str[j])>0)
{
strcpy(temp, str[i]);
strcpy(str[i], str[j]);
strcpy(str[j], temp);
}
}
printf(" In lexicographical request: ");
for(i=0; i<10; ++i)
{
puts(str[i]);
}
return 0;
}