R 1.
Define the following terms: linked list, node, head reference, external reference.
Chapter ExercisesReview QuestionsR 1.
Define the following terms: linked list, node, head reference, external reference.R 2.
Why must a linked list contain at least one external reference, namely the head reference?R 3.
How is an empty list represented?R 4.
Why is a second external reference needed when removing a node from a linked list?R 5.
What advantage does the use of a tail reference provide?R 6.
In terms of storage space, what advantage(s) does a singly linked list provide over a vector? What about the disadvantage(s)?R 7.
Given a head reference to a singly linked list that contains integer values, implement a function that accepts the head reference and returns the smallest value or None if the list is empty.
def findSmallest( head ): if head is None : return None else : smallest = head.next curNode = head.next while curNode is not None : if curNode.data < smallest : smallest = curNode.data curNode = curNode.next return smallest ExercisesE 1.
Implement the following functions related to the singly linked list:
E 2.
Evaluate the following code segment which creates a singly linked list. Draw the resulting list, including the external references.
box = None temp = None for i in range( 4 ) : if i % 3 != 0 : temp = ListNode( i ) temp.next = box box = temp E 3.
Consider the following singly linked list. Provide the instructions to insert the new node immediately following the node containing 52. Do not use a loop or any additional external references.
E 4.
Consider the following singly linked list. Provide the instructions to remove the node containing 18. Do not use a loop or any additional external references.
E 5.
The following questions are related to the Sparse Matrix ADT.
Programming Projects
|