Doubly Linked List
I have the good fortune of being assigned to program a doubly linked list in C. This type of data stucture must support the following features:
- Add a value to the list.
- Return the nth element in the list.
- Return the first element in the list.
- Return the last element in the list.
- Remove an arbitrary element in the list.
- Search for an arbitrary element by either first or last name.
- Reverse the list.
- Sort the list by either first or last name, in either ascending or descending order.
- Print the list.
- Return the length of the list.
Add a Value to the List
It is helpful to consider three different case for the list:
- One Element
- Many Elements
Create a Node
struct node tmp = (struct node) malloc(sizeof(struct node)))
The implementation of a doubly linked list with the features above is now available. The only feature lacking is the sort. It has been stubbed but not completed. Since I need a Menu system to interface with the link list model it seemed logically to have a MVC type of approach where:
Showing changes from previous revision.