
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Assigned: Thurs, October 26, 2006 Due: Wed, November 1, 11:59pm.
For this assignment, we implement a Doubly-Linked List of integers. You will need to define the following structures using typedef :
DListElement_t , must contain the necessary pointers to manage each integer element in the linked list, as well as an integer value that is the associated data.
DlistBase_t must contain the necessary pointers to keep track of the beginning and end of the list.
Next, you should implement three subroutines, as follows:
AddIntSorted(DListBase_t base, int i)* ; - This subroutine adds the integer “i” to the linked list referred to by “base”. The integer “i” should be inserted in the list in sorted order. In other words, if the list already contains 1, 5, 7 and 9, a new value 8 should be inserted after the 7 and before the 9. If the value to be inserted is already in the list, the new value must also be inserted, and can be either before or after the existing duplicate value.
PrintList(DlistBase_t base)* ; Prints the list referred to by “base”. This should print only the integer value of each element (not the pointers), and should put an end-of-line after each one. This should print the list in sequence, starting from the first element and continuing up to and including the last one.
PrintListReverse(DlistBase_t base)* ; Same as PrintList, except it prints the list in reverse order, starting with the last element and continuing up to and including the first element.
Finally, your main program should choose 100 random integer values in the range [-10 .. +10] (inclusive on both ends) and call AddIntSorted for each. After that, call PrintList and PrintListReverse to print out the resulting linked list.
One final thing is that we are not providing a skeleton Visual Studio project file, or any skeleton code. You must create your own Visual Studio project from the beginning. You should use a Win32 Console Application without pre-compiled headers. In the project creation wizard, if you proceed to the second page, you can deselect precompiled headers. If you forget and create a project with precompiled headers, you can remove them from the Project / Properties / C/C++ / Precompiled Headers page.