1. A linked list is a linear data structure where each element is a separate object.
2. Each element (i.e node) of a list is comprised of two items - the _____________________________ The last node has a reference to null.
3. In a linked list the order of elements is not given by their physical placement in memory. Instead, each element points to the next
4. Linked lists are linear and stand-alone structures which means they cannot be used to implement other abstract data types,such as stacks or queues
5. Fill in the blanks in this excerpt on the advantages of linked lists over arrays
6. Linked lists are also advantageous because they allow random access to the data at any given time
7. They use more memory than arrays because of the storage used by their pointers
8. What is the following code implementation of a linked list doing?
9. In a 'doubly linked list', each node contains, besides the next-node link, a second link field _____________________
10. The code below is creating a _________________________
11. Singly linked lists can be traversed in a forward direction only starting form the first data element. We simply print the value of the next data element by ___________________
12. What is output when the following code is executed?
class Node:
def __init__(self, dataval=None):
self.dataval = dataval
self.nextval = None
class SLinkedList:
def __init__(self):
self.headval = None
# Print the linked list
def listprint(self):
printval = self.headval
while printval is not None:
print (printval.dataval)
printval = printval.nextval
def AtBegining(self,newdata):
NewNode = Node(newdata)
# Update the new nodes next val to existing node
NewNode.nextval = self.headval
self.headval = NewNode
list = SLinkedList()
list.headval = Node("Mon")
e2 = Node("Tue")
e3 = Node("Wed")
list.headval.nextval = e2
e2.nextval = e3
list.AtBegining("Sun")
list.listprint()
Sun,Mon,Tues,Wed
Only 'Sun' will be printed for obvious reasons
Mon,Tues,Wed,Sun
Wed,Tues,Mon,Sun
13. What is happening in line 6 and 7 of this code?
14. What is happening on line 3 of this code?
15. The question in line 5 asks whether the data item is present in the current node. If so, found can be set to True.