CProject2
Basic Linked List Fun
Submission Guidelines
- Please do a make clean before zipping
- Zip file (no rar please).
- Please submit your program using the turnin script at http://rosemary.umw.edu/~raz/turnin/turnin.php If you have a problem email me your program.
Note: If you code works on all the uncommented code (code that is commented but is intended to be uncommented) that is worth a 'B'. Note that this code may need to be altered to work correctly. An 'A' will require your code working on other values I put in. For example, for problem 1 I may try a NULL list or use an index larger than the number of elements in the array; for problem 3 I might try to insert elements at the beginning and end of the list.
Node type
For the problems below assume a node type of
struct node {
int data;
struct node* next;
}
Code template
Use the start of the source code file project2.c
Problem 1 NthGet
Write a NthGet() function that takes a linked list and an integer and returns the value stored in the node at that index position. If the index is larger than the number of elements in the list, your function should generate an error msg. When you have written your function uncomment the associated section of the code.
Problem 2: NthInsert
Write a function NthInsert which will insert a new node at the index within the list. As an example see the source code file. The parameters are the list, an index, and an integer value to insert.
Problem 3: InsertSorted
Write a function which is given a list and a new integer to store and inserts a new node at the correct sorted position. Assume the list is already sorted
Problem 4: DeleteList
Write a function that takes a list and deallocates all of its memory and sets the head pointer to NULL.
Comments
Agena
InsertSorted does not work correctly. here is the output when I try to insert 2
13->15->42->NULL 13->2->15->27->42->47->NULL
Conroe
InsertSorted does not work correctly. will not insert 2 at start of list, for ex.
Kentsfield
Missing InsertSorted.
Northwood
Submitted original source file w/ no modifications. NEW SUBMISSION: delete does not work correctly. (it doesn't free up all memory)
Sparta
Program does not compile
Yorkfield
InsertSorted does not work correctly. Does not insert 2 in the correct spot.
