read_me.txt EOOP-LAB104-21L Instructor: Rajmund Kożuszek e-mail: XXXXXXXXXX Singly-linked lists You should provide implementation of several functions operating on the singly linked list defined in...

how much?


read_me.txt EOOP-LAB104-21L Instructor: Rajmund Kożuszek e-mail: [email protected] Singly-linked lists You should provide implementation of several functions operating on the singly linked list defined in sllist.h. All the tests in sllist.cpp should not produce error messages (i.e. the only output produced by your program is "End of tests."). All functions should be implemented in sllist.cpp. Note that you should use new and delete operators for object allocation/deallocation. Use nullptr instead of NULL. I suggest you to implement your solution in smallest possible steps by commenting out all tests at the beginning by moving "first line of test elimination region" (currently line 87 in sllist_test.cpp) to the beginning of the main function (say, line 23). After completing one test you can move "elimination line" one test further, and so on. The best possible use of your time is to complete as much as possible during lab session. I'll wait for solutions until 8PM today. Sending the solution (just sllist.cpp file) please include EOOP in the title of your e-mail. Rajmund Kożuszek sllist.h #ifndef SLLIST_H_INCLUDED #define SLLIST_H_INCLUDED // Rajmund Kozuszek (121528) struct sl_node { int value; sl_node *next; }; // in the following functions we assume that parameter pHead // points to the first element of the singly linked list bool empty(const sl_node* pHead); // returns true if list is empty, i.e. contains no elements int size(const sl_node* pHead); // returns number of elements in list sl_node* push_front(sl_node* pHead, int val); // adds element val in the beginning of the list // returns pointer to the new head of the list sl_node* pop_front(sl_node* pHead); // removes the first element of the list // returns pointer to the new head of the list sl_node* clear(sl_node* pHead); // removes all elements from the list // returns pointer to the new head of the list sl_node* insert(sl_node* pHead, int val); // inserts the new element (set to val) // BEFORE the element of greater than or equal value // or at the end of the list if no such element exists // returns pointer to the new head of the list #endif // SLLIST_H_INCLUDED sllist_test.cpp #include #include "sllist.h" using namespace std; void check_empty_list(const sl_node* pHead) { if (pHead != nullptr) cerr < "error="" in="" head="" pointer="" -="" it="" should="" be="" nullptr.\n";="" if="" (empty(phead)="" !="true)" cerr="">< "error="" in="" empty()="" for="" empty="" list.\n";="" if="" (size(phead)="" !="0)" cerr="">< "error="" in="" size()="" for="" empty="" list.\n";="" }="" int="" main()="" {="" sl_node="" *list_head="nullptr;" tests="" on="" empty="" list="" check_empty_list(list_head);="" tests="" on="" one-element="" list="" list_head="push_front(list_head," 17);="" if="" (size(list_head)="" !="1)" cerr="">< "error="" in="" size()="" for="" one-element="" list.\n";="" if="" (list_head="=" nullptr)="" cerr="">< "error="" in="" header="" pointer="" for="" one-element="" list.\n";="" else="" {="" if="" (list_head-="">value != 17) cerr < "error="" in="" val="" member="" in="" one-element="" list.\n";="" if="" (list_head-="">next != nullptr) cerr < "error="" in="" next="" member="" in="" one-element="" list.\n";="" }="" list_head="pop_front(list_head);" the="" list="" should="" be="" empty="" check_empty_list(list_head);="" let's="" try="" to="" pop="" from="" empty="" list="" -="" should="" do="" no="" harm="" pop_front(list_head);="" check_empty_list(list_head);="" test="" inserting="" elements="" list_head="insert(list_head," 8);="" insert="" 4="" other="" elements="" for="" (int="" i="2;" i="">< 1000;="" i="" *="i)" 2="" 4="" 16="" 256="" list_head="insert(list_head," i);="" if="" (size(list_head)="" !="5)" cerr="">< "error="" in="" size()="" after="" adding="" five="" values.\n";="" if="" (list_head-="">value != 2) cerr < "error="" in="" the="" first="" value="" after="" inserts.\n";="" list_head="pop_front(list_head);" if="" (size(list_head)="" !="4)" cerr="">< "error="" in="" size()="" after="" pop="" #1.\n";="" if="" (list_head-="">value != 4) cerr < "error="" in="" the="" first="" value="" after="" pop="" #1.\n";="" list_head="pop_front(list_head);" if="" (size(list_head)="" !="3)" cerr="">< "error="" in="" size()="" after="" pop="" #2.\n";="" if="" (list_head-="">value != 8) cerr < "error="" in="" the="" first="" value="" after="" pop="" #2.\n";="" list_head="pop_front(list_head);" if="" (size(list_head)="" !="2)" cerr="">< "error="" in="" size()="" after="" pop="" #3.\n";="" if="" (list_head-="">value != 16) cerr < "error="" in="" the="" first="" value="" after="" pop="" #3.\n";="" list_head="pop_front(list_head);" if="" (size(list_head)="" !="1)" cerr="">< "error="" in="" size()="" after="" pop="" #4.\n";="" if="" (list_head-="">value != 256) cerr < "error="" in="" the="" first="" value="" after="" pop="" #4.\n";="" list_head="pop_front(list_head);" check_empty_list(list_head);="" *="" first="" line="" of="" test="" elimination="" region="" last="" line="" of="" test="" elimination="" region="" */="" cerr="">< "end="" of="" tests."="">< endl; return 0; } endl;="" return="" 0;="">
Mar 24, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here