04. Doubly, you said…
In this question, you are to build an ADT for a venerated data structure. The doubly-link. list. You will be working with a list of integers and we supply the test program. The API contains 8 functions to setup and manipulate a doubly link. list. Specifically, there are functions to:
• initialize the list • clear the list (make it empty, releasing whatever it may contain) • insert an element at the front of the list • insert an element at the back of the list • insert an element right after a given element key that may or may not appear in the list (if it does not appear, add the new element at the end) • remove an element from the list • print the list going in the forward direction (front to back) • print the list going in the backward direction (back to front)
This question will have many test cases to evaluate all the APIs and their interplay. We are providing the test program that you should mot modify. We are also providing a sample test (data . txt) that you can feed to the test program for some modest testing. The automat. test are quite a bit more thorough.
To compile the program, simply run: make To test the program simply run dltest
You should not have crashes of any kind nor any memory leaks. The header file is fix. and should not be modifi.. You will focus. exlusively on the dilist c file. (The grading suite has a lot more tests. We give you one small one). Note that the testing input is a file with a sequence of commands, one per line. each command has 0, I or 2 arguments. The commands are as follow
1. fr : inserts at the front of the list bk : inserts at the back of the list 3. in right behind the first occurrence of in the list. 4. rl : removes the first occurrence of from the list 5. pf : print the list in the forward direction. 6. pb : print the list in the backward direction. 7. cl : clears the list (remove all values held in the list, i.e., the list is empty again).
So the sequence of commands:
fr 3 fr 2 fr 1 Pf
inserts 3 in the front, then 2 in the front, then 1 in the front and prints the list forward.
#Sales Offer!| Get upto 25% Off: