0% found this document useful (0 votes)
154 views

UNIT 4 - Linked List: 1. Which of The Following Is Not A Disadvantage To The Usage of Array?

The document discusses linked lists and their applications. It provides explanations for various questions about linked lists, including their time and space complexities for operations like insertion, deletion, searching and counting elements. Some key applications of linked lists mentioned are implementing file systems, separate chaining in hash tables, and implementing non-binary trees. Doubly linked lists require more space than singly linked lists but allow traversal in both directions.

Uploaded by

Rehan Pathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
154 views

UNIT 4 - Linked List: 1. Which of The Following Is Not A Disadvantage To The Usage of Array?

The document discusses linked lists and their applications. It provides explanations for various questions about linked lists, including their time and space complexities for operations like insertion, deletion, searching and counting elements. Some key applications of linked lists mentioned are implementing file systems, separate chaining in hash tables, and implementing non-binary trees. Doubly linked lists require more space than singly linked lists but allow traversal in both directions.

Uploaded by

Rehan Pathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

UNIT 4 - Linked List

1. Which of the following is not a disadvantage to the usage of array?

a) Fixed size

b) There are chances of wastage of memory space if elements inserted in an array are lesser
than the allocated size

c) Insertion based on position

d) Accessing elements at specified positions

Answer: d

Explanation: Array elements can be accessed in two steps. First, multiply the size of the data
type with the specified position, second, add this value to the base address. Both of these
operations can be done in constant time, hence accessing elements at a given index/position is
faster.

2. What is the time complexity of inserting at the end in dynamic arrays?

a) O(1)

b) O(n)

c) O(logn)

d) Either O(1) or O(n)

Answer: d

Explanation: Depending on whether the array is full or not, the complexity in dynamic array
varies. If you try to insert into an array that is not full, then the element is simply stored at the
end, this takes O(1) time. If you try to insert into an array which is full, first you will have to
allocate an array with double the size of the current array and then copy all the elements into it
and finally insert the new element, this takes O(n) time.

3. What is the time complexity to count the number of elements in the linked list?

a) O(1)
b) O(n)

c) O(logn)

d) O(n2)

Answer: b

Explanation: To count the number of elements, you have to traverse through the entire list,
hence complexity is O(n).

4. Which of these is not an application of a linked list?

a) To implement file systems

b) For separate chaining in hash-tables

c) To implement non-binary trees

d) Random Access of elements

Answer: d

Explanation: To implement file system, for separate chaining in hash-tables and to implement
non-binary trees linked lists are used. Elements are accessed sequentially in linked list. Random
access of elements is not an applications of linked list.

6. What is the space complexity for deleting a linked list?

a) O(1)

b) O(n)

c) Either O(1) or O(n)

d) O(logn)

Answer: a

Explanation: You need a temp variable to keep track of current node, hence the space
complexity is O(1).

7. Which of the following is false about a doubly linked list?

a) We can navigate in both the directions

b) It requires more space than a singly linked list


c) The insertion and deletion of a node take a bit longer

d) Implementing a doubly linked list is easier than singly linked list

Answer: d

Explanation: A doubly linked list has two pointers ‘left’ and ‘right’ which enable it to traverse in
either direction. Compared to singly liked list which has only a ‘next’ pointer, doubly linked list
requires extra space to store this extra pointer. Every insertion and deletion requires
manipulation of two pointers, hence it takes a bit longer time. Implementing doubly linked list
involves setting both left and right pointers to correct nodes and takes more time than singly
linked list.

8. How do you calculate the pointer difference in a memory efficient double linked list?

a) head xor tail

b) pointer to previous node xor pointer to next node

c) pointer to previous node – pointer to next node

d) pointer to next node – pointer to previous node

Answer: b

Explanation: The pointer difference is calculated by taking XOR of pointer to previous node and
pointer to the next node.

9. What is the worst case time complexity of inserting a node in a doubly linked list?

a) O(nlogn)

b) O(logn)

c) O(n)

d) O(1)

Answer: c

Explanation: In the worst case, the position to be inserted maybe at the end of the list, hence
you have to traverse through the entire list to get to the correct position, hence O(n).

10. What differentiates a circular linked list from a normal linked list?

a) You cannot have the ‘next’ pointer point to null in a circular linked list
b) It is faster to traverse the circular linked list

c) You may or may not have the ‘next’ pointer point to null in a circular linked list

d) Head node is known in circular linked list

Answer: c

Explanation: The ‘next’ pointer points to null only when the list is empty, otherwise it points to
the head of the list. Every node in a circular linked list can be a starting point(head).

11. What is the time complexity of searching for an element in a circular linked list?

a) O(n)

b) O(nlogn)

c) O(1)

d) O(n2)

Answer: a

Explanation: In the worst case, you have to traverse through the entire list of n elements.

12. Which of the following application makes use of a circular linked list?

a) Undo operation in a text editor

b) Recursive function calls

c) Allocating CPU to resources

d) Implement Hash Tables

Answer: c

Explanation: Generally, round robin fashion is employed to allocate CPU time to resources
which makes use of the circular linked list data structure. Recursive function calls use stack data
structure. Undo Operation in text editor uses doubly linked lists. Hash tables uses singly linked
lists.

13. Which of the following is false about a circular linked list?

a) Every node has a successor

b) Time complexity of inserting a new node at the head of the list is O(1)
c) Time complexity for deleting the last node is O(n)

d) We can traverse the whole circular linked list by starting from any point

Answer: b

Explanation: Time complexity of inserting a new node at the head of the list is O(n) because you
have to traverse through the list to find the tail node.

14. What is the best case time complexity of deleting a node in a Singly Linked list?

a) O (n)

b) O (n2)

c) O (nlogn)

d) O (1)

Answer: d

Explanation: Deletion of the head node in the linked list is taken as the best case. The successor
of the head node is changed to head and deletes the predecessor of the newly assigned head
node. This process completes in O(1) time.

15. Which of the following statements are not correct with respect to Singly Linked List(SLL)
and Doubly Linked List(DLL)?

a) Complexity of Insertion and Deletion at known position is O(n) in SLL and O(1) in DLL

b) SLL uses lesser memory per node than DLL

c) DLL has more searching power than SLL

d) Number of node fields in SLL is more than DLL

Answer: d

Explanation: To insert and delete at known positions requires complete traversal of the list in
worst case in SLL, SLL consists of an item and a node field, while DLL has an item and two node
fields, hence SLL occupies lesser memory, DLL can be traversed both ways(left and right), while
SLL can traverse in only one direction, hence more searching power of DLL. Node fields in SLL is
2 (data and address of next node) whereas in DLL is 3(data, address to next node, address to
previous node).
16. What does ‘stack overflow’ refer to?

a) accessing item from an undefined stack

b) adding items to a full stack

c) removing items from an empty stack

d) index out of bounds exception

Answer: b

Explanation: Adding items to a full stack is termed as stack underflow.

17. In linked list implementation of queue, if only front pointer is maintained, which of the
following operation take worst case linear time?

a) Insertion

b) Deletion

c) To empty a queue

d) Both Insertion and To empty a queue

Answer: d

Explanation: Since front pointer is used for deletion, so worst time for the other two cases.

18. In linked list implementation of a queue, where does a new element be inserted?

a) At the head of link list

b) At the centre position in the link list

c) At the tail of the link list

d) At any position in the linked list

Answer: c

Explanation: Since queue follows FIFO so new element inserted at last.

19. In case of insertion into a linked queue, a node borrowed from the __________ list is
inserted in the queue.

a) AVAIL
b) FRONT

c) REAR

d) NULL

Answer: a

Explanation: All the nodes are collected in AVAIL list.

20. In linked list implementation of a queue, the important condition for a queue to be empty
is?

a) FRONT is null

b) REAR is null

c) LINK is empty

d) FRONT==REAR-1

Answer: a

Explanation: Because front represents the deleted nodes.

21. The essential condition which is checked before insertion in a linked queue is?

a) Underflow

b) Overflow

c) Front value

d) Rear value

Answer: a

Explanation: To check whether there is element in the list or not.

22. Which of these is an application of linked lists?

a. To implement file systems

b. For separate chaining in hash-tables

c. To implement non-binary trees


d. All of the mentioned

Answer: d

You might also like