Question: Question 3 This question is about array lists and linked lists. In the first sub-question we consider linked lists which are sequences of connected nodes,

 Question 3 This question is about array lists and linked lists.

Question 3 This question is about array lists and linked lists. In the first sub-question we consider linked lists which are sequences of connected nodes, taken from the class below. class Node : def __init__(self, d, n): self data = d self.next = n The data stored are integers. (a) You are asked to solve the following pointer game. Start from this initial configuration: 1 3 5 7 1s1 2 4 6 ls2 Figure 1: Initial pointer configuration Perform the following sequences of operations and draw the final configuration in each case. Each time you should start from the configuration in Figure 1 above. (i) ptr = ls 2 while ptr.next != None : ptr.data 1 ptr = ptr.next ptr.next = Node (ptr.data , None) [5 marks] = (ii) 1s2.next ls2.next.next ptri = ls 1 ptr2 = ls2 while ptri. data != ptr2.data: ptri = ptri.next ptr2 ptr2.next ptri.data 0 = [5 marks]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!