CS23005 Design and analysis of algorithms

Autumn 2004--2005

Assignment 1

This assignment helps you brush up your C programming skill. Here you should play with file i/o and pointers.

Part 1
Deadline: July 26, 2004

Read data from the input file and create a linked list. Each node in your list must separately store the roll number, name and the e-mail address of a student. Each line in the input file has the format:

RollNo,"Name",EmailAddress
The three fields are separated by commas. The name field additionally contains commas. In order to remove confusion, the names are surrounded by double quotes.

Part 2
Deadline: August 2, 2004

Add three other pointers to each node. The first set of added pointers maintains a sorted list with respect to roll numbers, the second with respect to name and the third with respect to e-mail address. Click here to see a figure that demonstrates a linked list with two sets of pointers (green and blue) used for sorting in addition to the usual set of pointers (red) needed for maintaining the raw list.

Print the three sorted lists by traversing along the three sets of links. Choose your own sorting algorithm.

Note

You may use the following data type for a node:
struct _student {
   char rollNo[10];
   char name[100];
   char email[40];
   struct _student *next;
   struct _student *rNext;
   struct _student *nNext;
   struct _student *eNext;
};
typedef struct _student student;
typedef student *studentPointer;
The following built-in C library calls may be useful:
fscanf, fgets,
strcmp, strchr.


Home