Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The data structure shown in Figure 1 can be thought as a list of two lists, is used to classify numbers in one of 2
The data structure shown in Figure can be thought as a list of two lists, is used to classify numbers in one of groups: even numbers and odd numbers. The first node of the main list the list drawn horizontally, made of shaded nodes stores a number to signal that the numbers stored in its secondary list the list drawn vertically, hanging from node storing number are even in the figure, the numbers and The second node of the main list stores a number to signal that the numbers stored in its secondary list in the figure, the numbers and are odd.
a In a single linked list implemented in C this is the definition of a node: struct Node
int data;
Node next;
;
This definition is useful for the nodes belonging to the secondary lists, but not for the nodes belonging to the main list. Main list nodes need two pointers one for the next node in the main list and one for the first node in the secondary list Assuming that the above definition is kept for the nodes of the secondary lists, propose a new definition of node for the nodes of the main list. Call this type of node Nodemain and use the names of pointers given in Figure
b Write the pseudocode of the function INSERTheadx that inserts a new number in this data structure. If the number is even it must go to the
first secondary list the one hanging from node in the main list Otherwise, it must go to the second secondary list. Assume the data structure already has the main list created and numbers are inserted at the start of the secondary list.
c Write the pseudocode of the function SEARCHheadx that returns TRUE if the number x is in the data structure in any of the secondary lists and FALSE otherwise.
d Write the pseudocode of the function DELETEhead b that receives as input arguments the head of the last of two lists and a Boolean value. The function DELETEheadb deletes one of the main nodes. If b equals then the node storing number is deleted. Otherwise, the main node storing number is deleted. Consider the following cases: the main list is empty and it has only one node node or
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started