Download Linked List Deque Implementation in C and more Exams Data Structures and Algorithms in PDF only on Docsity! Worksheet 11: Linked List Deque Name: An Active Learning Approach to Data Structures using C 1 Worksheet 11: Linked List Deque In this lesson and the following we will develop a reasonably complete linked list abstraction. Our list will use sentinels on both the front and the back of the list, and double links. In this lesson we will emphasize the deque aspects of the list. In the following lesson we will add more operations. A deque, you recall, allows insertions at both the beginning and the end of the container. The interface is shown at right. Sentinels ensure the list is never completely empty. They also mean that all instructions can be described as special cases of more general routines. One of these, removeLink, you developed in the previous lesson. Another internal routine, addBefore, can be described as “insert a new link immediate before an existing link”. Write this new routine, and then show how all insertions can be handled by this one routine. As you add and remove elements make sure you keep the value of the size field up to date. When a value is removed from a list make sure you free the associated link fields. Use an assertion to check that allocations of new links are successful, and that you do not attempt to remove a value from an empty list. Finish the implementation of the LinkedList based on these ideas: backSentinel frontSentinel sentinel 7 4 Sentinel struct list { int size; struct dlink *frontSentinel; struct dlink *backSentinel; }; void listInit (struct list *lst); void listDestroy (struct list *lst); void listAddFront (struct list *lst, EleType d); void listAddBack (struct list *lst, EleType d); void listRemoveFront (struct list *lst); void listRemoveBack (struct list *lst); EleType listFront (struct list *lst); EleType listBack (struct list *lst); int listSize (struct list *lst); Worksheet 11: Linked List Deque Name: An Active Learning Approach to Data Structures using C 2 void listInit (struct list *lst); { } void listDestroy (struct list *lst) { } void listAddBefore (struct dlink * lnk, EleType d) { } void listAddFront (struct list *lst, EleType d) { } void listAddBack (struct list *lst, EleType d) { } void listRemoveFront (struct list *lst) { }