//Algorithm should: /*NOT destroy any of the originally even-valued node. This means that the originally even-valued nodes should be retained as part of the resulting list. Destroy ONLY nodes that are originally odd-valued. Create new nodes and copy data between nodes ONLY when duplicating originally even-valued nodes. Only ONE new node should be created for each originally even-valued node. Creating pointer-to-node's (to provide temporary storage for node addresses) does not constitute creating new nodes or copying of items. NOT make any temporary copies of any of the data items (using any kind of data structures including but not limited to arrays, Linked lists and trees). This means that the algorithm should largely involve the manipulation of pointers. Function must be iterative (NOT recursive) - use only Looping construct(s), without the function calling itself (directly or indirectly). Function should not call any other functions to help in performing the task. bool DelOddCopEven (Node* headptr) { while (headPtr != 0) { headPtr = headPtr -> link; Node *newNodePtr = new Node; }
Types of Linked List
A sequence of data elements connected through links is called a linked list (LL). The elements of a linked list are nodes containing data and a reference to the next node in the list. In a linked list, the elements are stored in a non-contiguous manner and the linear order in maintained by means of a pointer associated with each node in the list which is used to point to the subsequent node in the list.
Linked List
When a set of items is organized sequentially, it is termed as list. Linked list is a list whose order is given by links from one item to the next. It contains a link to the structure containing the next item so we can say that it is a completely different way to represent a list. In linked list, each structure of the list is known as node and it consists of two fields (one for containing the item and other one is for containing the next item address).
bool DelOddCopEven(Node* headPtr);
Trending now
This is a popular solution!
Step by step
Solved in 2 steps