Exercise 10_1

Use the following structure as the node type for implementing a linked list:

#define MAX_WORD 30

typedef struct _listnode {
char word[MAX_WORD];
struct _listnode *pNext;
} WordNode;

Read all the words from a file called words.txt. Place each word in the list by adding them to the end of the list. Add the words to the list in the order they were read from the file.

Each node in the list must be created using malloc.

Once the list is populated with all the words from the file, print the word list in the order the words appear in the list.

Exercise 10_2

Use the following structure as the node type for implementing a linked list:

#define MAX_WORD 30

typedef struct _listnode {
char word[MAX_WORD];
struct _listnode *pNext;
} WordNode;

Read all the words from a file called words.txt. Place each word in the list by adding them to the list in SORTED order. The list should contain an alphabetically sorted list of the words from the file words.txt.

Each node in the list must be created using malloc.

Once the list is populated with all the words from the file, print the word list in the order the words appear in the list.

Exercise 10_3

Implement a circular queue by writing circular.h and circular.c.

Here are the contents of circular.h:

#define QUEUE_SIZE 100

typedef struct {
int head;
int tail;
int count;
int data[QUEUE_SIZE];
} CircularQueue;

void CircularInitialize(CircularQueue *q);
void CircularEnqueue(CircularQueue *q, int value);
int CircularDequeue(CircularQueue *q, int *pValue);

Using an array, implement a circular queue of up to 100 elements. Implement CircularEnqueue() and CircularDequeue() functions to place numbers on the queue and read them from the queue tail. A circular queue only saves the last n entries (where n is the number of elements in the queue). Overwrite the oldest entries with newest entries once the queue is full.

A main.c and makefile is supplied. The main.c source file contains a set of tests that verify your implementation is correct.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.