You are on page 1of 3

CS2311: Data Structures

Tutorial #05: Linked Lists

Part I: Choose the most appropriate answer:


1. An abstract data type means:
(a) A set of Objects.
(b) A set of Operations.
(c) A set of Objects and a set of Operations.
(d) A set of pointers.

2. A node in a doubly linked list contains:


(a) Pointer to the next node.
(b) Pointer to the next node and previous node.
(c) Pointer to the previous node.
(d) Only the data.

3. An advantage of a doubly-linked list is that:


(a) It is easy to delete a node in the middle.
(b) It is easy to delete the first node.
(c) It is easy to insert a node in front.
(d) All the above.

4. The operation to delete a node in a singly-linked list has time complexity:


(a) O(n).
(b) O(1).
(c) O(n2).
(d) O(log n).

5. One of the advantages of doubly linked list is:


(a) Convenient to traverse list forwards.
(b) Convenient to traverse list backwards.
(c) Convenient to traverse list from the middle.
(d) All of the above.

6. The node of single linked list contains:


(a) Only pointer to next node.
(b) Data and pointer to next node.
(c) Only data.
(d) No data and no pointer.

7. The first node in a linked list is called:


(a) Head.
(b) Null.
(c) End.
(d) Middle.

1
PART II: Coding & Implementation:

1. Write a class that represents the definition of a node in a single linked-list?

Answer:

2. Write a method called (add2front) to insert a node that contains the value “1” at the beginning of the following linked-
list:

Head 2 3 4

Answer:

Write a method called (isFound) to return true if it finds a node in a single linked-list with data equal to ‘val’.and return false
otherwise?

Answer:

2
3. Write a method called (del_mid) to delete the node with the value “4” from the following single linked-list:

Head 4 3 2

Answer:

4. Convert the following linked list into its static representation (using array)?
Tail

Head D C B A

Answer:

You might also like