1. How many pointers are contained in the nodes of a circularly doubly-linked li
ID: 3876859 • Letter: 1
Question
1. How many pointers are contained in the nodes of a circularly doubly-linked list with a sentinel node of five data nodes?
2.given a circularly doubly-linked list with a sentinel node where each node has two references(forw and back); one that points to the next node and another that points to the previous node. Assume the linked list below:
SENTINEL - 30 - 70 - 90 - 50 - 10
Provide the output for the following statement
Print( head->forw->forw->forw->forw->back->data)
3.given a circularly doubly-linked list with a sentinel node where each node has two references(forw and back); one that points to the next node and another that points to the previous node. Assume the linked list below:
SENTINEL - 30 - 70 - 90 - 50 - 10
provide the output for the following pseudocode
ptr = head->forw->forw
ptr->back->forw=ptr->forw
ptr->forw->back=ptr->back
list.printForw()//lprints the list forward.
4.given a circularly doubly-linked list with a sentinel node where each node has two references(forw and back); one that points to the next node and another that points to the previous node. Assume the linked list below:
SENTINEL - 30 - 70 - 90 - 50 - 10
provide the output for the following pseudocode
head->forw->data+=head->back->data
list.printBack()//lprints the list backward.
Answer should only be numbers
Explanation / Answer
1. 12 Pointers
There are two pointers forward and previous for each node.For five data nodes in total there are 10 pointers and two pointers for sentinel node as well. Thus in total there are 12 pointers cointained in the circular doubly linked list of five data notes with one sentinel node.
2. 50
SENTINEL - 30 - 70 - 90 - 50 - 10
print(head->forw->forw->forw->forw->back->data)
head node will be node that is pointed as forward of sentinel node.
Here it is the node with data 30, head->forw points to node with data 70, head->forw->forw points to node with data 90, head->forw->forw->forw points to node with data 50, head->forw->forw->forw->forw points to node with data 10.
head->forw->forw->forw->forw->back points to node(back of node with data 10) with data 50. Hence the output is 50
3. 30-70-50-10
for the pseudo code below
ptr = head->forw->forw , ptr points to node with data 90
ptr->back->forw=ptr->forw, back pointer of node with data 90 points to node with data 70, forward pointer of this node is made to point to node with data 50(which is the forward node of node with with data 90)
ptr->forw->back=ptr->back, forward pointer of node with data 90 points to node with data 50, back pointer of this node is made to point to node with data 70(which is the back node of node with with data 90).
Hence node with data 90 is removed from the list.
list.printForw()//lprints the list forward, List prints forward from head to last node which is not a head node.
4. 30-80-90-50-10
for the pseudo code below
head->forw->data+=head->back->data
list.printBack()//lprints the list backward.
forward node of head node has the data as 70. back node of head node points to sentinel which is a dummy node whose back node has the data as 10(which is logically the back node of head node). 10 is added to 70(80) and result is reflected in the that node( wich has the data 70) to 80.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.