Create a class OrderedLinkedList to implement a singly linked list that stores integer data in the ascending order. Each node in the linked list should point to the next node. Implement the following...


This one


in c++.


Create a class OrderedLinkedList to implement a singly linked list that stores integer data in the<br>ascending order. Each node in the linked list should point to the next node. Implement the<br>following methods and operators:<br>A default constructor:<br>Set pointers head to NULL<br>A copy constructor:<br>Copy linked list that is passed as a parameter to this object.<br>The destructor:<br>Deallocate all the memory of the linked list<br>Extraction operator >><br>To insert one integer in the linked list<br>Prompt the user for an integer and insert it at the appropriate location so that the<br>resulting linked list remains sorted.<br>Implement it as a friend function<br>Insertion operator <<<br>Display the whole list in ascending.<br>For ascending order display, start from the head and traverse up to the tail node using<br>the next pointer.<br>Implement it as a friend function<br>Addition operator +<br>Both left and right operands are OrderedLinkedList objects.<br>Merge the two linked lists into a new sorted linked list and return the new merged linked<br>list.<br>Implement it as a member of the class<br>Left and right operand linked lists should not be modified.<br>Inplace addition operator +=<br>Both left and right operands are OrderedLinkedList objects.<br>Merge the right linked list with the left linked list.<br>Should modify the left linked list instead of returning a new linked list.<br>Implement it as a member of the class<br>Inplace subtraction operator -<br>The left operand is an OrderedLinkedList object and the right operand is an integer<br>The right operand is an index rather than the data. Remove the node at index from the<br>linked list.<br>Implement it as a member of the class<br>Pre-decrement operator --<br>Remove the smallest element from the linked list.<br>Should return a reference to the left linked list so that the – expression can also be used<br>in other expressions, e.g. (--a)+b<br>Implement it as a member of the class<br>Post-decrement operator --<br>Remove the largest element from the linked list.<br>Should return a reference to the left linked list so that the – expression can also be used<br>in other expressions, e.g, (a--)+b<br>Implement it as a member of the class<br>Assignment operator =<br>Copy the right linked list to the left linked list.<br>You have to deallocate memory for some of the nodes in the left linked lists if it has more<br>nodes than the right linked list.<br>Implement it as a member of the class<br>Subscript operator []:<br>The left operand is a linked list and the index is an integer.<br>Should return integer data of the node at position

Extracted text: Create a class OrderedLinkedList to implement a singly linked list that stores integer data in the ascending order. Each node in the linked list should point to the next node. Implement the following methods and operators: A default constructor: Set pointers head to NULL A copy constructor: Copy linked list that is passed as a parameter to this object. The destructor: Deallocate all the memory of the linked list Extraction operator >> To insert one integer in the linked list Prompt the user for an integer and insert it at the appropriate location so that the resulting linked list remains sorted. Implement it as a friend function Insertion operator < display the whole list in ascending. for ascending order display, start from the head and traverse up to the tail node using the next pointer. implement it as a friend function addition operator + both left and right operands are orderedlinkedlist objects. merge the two linked lists into a new sorted linked list and return the new merged linked list. implement it as a member of the class left and right operand linked lists should not be modified. inplace addition operator += both left and right operands are orderedlinkedlist objects. merge the right linked list with the left linked list. should modify the left linked list instead of returning a new linked list. implement it as a member of the class inplace subtraction operator - the left operand is an orderedlinkedlist object and the right operand is an integer the right operand is an index rather than the data. remove the node at index from the linked list. implement it as a member of the class pre-decrement operator -- remove the smallest element from the linked list. should return a reference to the left linked list so that the – expression can also be used in other expressions, e.g. (--a)+b implement it as a member of the class post-decrement operator -- remove the largest element from the linked list. should return a reference to the left linked list so that the – expression can also be used in other expressions, e.g, (a--)+b implement it as a member of the class assignment operator = copy the right linked list to the left linked list. you have to deallocate memory for some of the nodes in the left linked lists if it has more nodes than the right linked list. implement it as a member of the class subscript operator []: the left operand is a linked list and the index is an integer. should return integer data of the node at position "index", where "index" is the operand which is passed inside the square brackets as i[index]. print error message and return 0 if the index is out of bound. implement it as a member of the class. you can write as many private methods as required. this is useful if some of the functionality is required more than one functions. display="" the="" whole="" list="" in="" ascending.="" for="" ascending="" order="" display,="" start="" from="" the="" head="" and="" traverse="" up="" to="" the="" tail="" node="" using="" the="" next="" pointer.="" implement="" it="" as="" a="" friend="" function="" addition="" operator="" +="" both="" left="" and="" right="" operands="" are="" orderedlinkedlist="" objects.="" merge="" the="" two="" linked="" lists="" into="" a="" new="" sorted="" linked="" list="" and="" return="" the="" new="" merged="" linked="" list.="" implement="" it="" as="" a="" member="" of="" the="" class="" left="" and="" right="" operand="" linked="" lists="" should="" not="" be="" modified.="" inplace="" addition="" operator="" +="Both" left="" and="" right="" operands="" are="" orderedlinkedlist="" objects.="" merge="" the="" right="" linked="" list="" with="" the="" left="" linked="" list.="" should="" modify="" the="" left="" linked="" list="" instead="" of="" returning="" a="" new="" linked="" list.="" implement="" it="" as="" a="" member="" of="" the="" class="" inplace="" subtraction="" operator="" -="" the="" left="" operand="" is="" an="" orderedlinkedlist="" object="" and="" the="" right="" operand="" is="" an="" integer="" the="" right="" operand="" is="" an="" index="" rather="" than="" the="" data.="" remove="" the="" node="" at="" index="" from="" the="" linked="" list.="" implement="" it="" as="" a="" member="" of="" the="" class="" pre-decrement="" operator="" --="" remove="" the="" smallest="" element="" from="" the="" linked="" list.="" should="" return="" a="" reference="" to="" the="" left="" linked="" list="" so="" that="" the="" –="" expression="" can="" also="" be="" used="" in="" other="" expressions,="" e.g.="" (--a)+b="" implement="" it="" as="" a="" member="" of="" the="" class="" post-decrement="" operator="" --="" remove="" the="" largest="" element="" from="" the="" linked="" list.="" should="" return="" a="" reference="" to="" the="" left="" linked="" list="" so="" that="" the="" –="" expression="" can="" also="" be="" used="" in="" other="" expressions,="" e.g,="" (a--)+b="" implement="" it="" as="" a="" member="" of="" the="" class="" assignment="" operator="Copy" the="" right="" linked="" list="" to="" the="" left="" linked="" list.="" you="" have="" to="" deallocate="" memory="" for="" some="" of="" the="" nodes="" in="" the="" left="" linked="" lists="" if="" it="" has="" more="" nodes="" than="" the="" right="" linked="" list.="" implement="" it="" as="" a="" member="" of="" the="" class="" subscript="" operator="" []:="" the="" left="" operand="" is="" a="" linked="" list="" and="" the="" index="" is="" an="" integer.="" should="" return="" integer="" data="" of="" the="" node="" at="" position="" "index",="" where="" "index"="" is="" the="" operand="" which="" is="" passed="" inside="" the="" square="" brackets="" as="" i[index].="" print="" error="" message="" and="" return="" 0="" if="" the="" index="" is="" out="" of="" bound.="" implement="" it="" as="" a="" member="" of="" the="" class.="" you="" can="" write="" as="" many="" private="" methods="" as="" required.="" this="" is="" useful="" if="" some="" of="" the="" functionality="" is="" required="" more="" than="" one="">
Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here