1. 1. What does the following function do for a given Linked List with first node as head?
void fun1(node head)
{ if(head == NULL)
return; fun1(head.next);
System.out.write(head.data);
}
a. Prints all nodes of linked list in reverse order
b. Prints all nodes of linked lists
c. Prints alternate nodes of Linked List
d. Prints alternate nodes in reverse order: a
2. 2. Which of the following sorting algorithms can be used to sort a random linked list with
minimum time complexity?
a. Merge Sort
b. Insertion Sort
c. Quick Sort
d. Heap Sort: a
3. 3. What is the output of following function for start pointing to first node of following linked list?
1->2->3->4->5->6
void fun(node* start)
{
if(start == NULL)
return;
System.out.write(start.data);
if(start.next != NULL )
fun(start.next.next);
System.out.write(star.data);
, CSD201 Questons and Answers 2024
}
a. 1 3 5 5 3 1
b. 1 4 6 6 4 1
c. 1 3 5 1 3 5
d. 1 2 3 5: a
4. 4. In the worst case, the number of comparisons needed to search a singly linked list of length n
for a given element is
a. n
b. n/2
, CSD201 Questons and Answers 2024
c. log¬2n -1
d. log¬2n: a
5. 5. Suppose each set is represented as a linked list with elements in arbitrary order. Which of the
operations among union, intersection, membership, cardi- nality will be the slowest?
a. union, intersection
b. membership, cardinality
c. intersection, membership
d. union only: a
6. 6. What are the time complexities of finding 8th element from beginning and 8th element from
end in a singly linked list? Let n be the number of nodes in linked list, you may assume that n > 8
a. O(1) and O(n)
b. O(1) and O(1)
c. O(n) and O(1)
d. O(n) and O(n): a
7. 7. Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head
node is not given, can we delete the node X from given linked list?
a. Possible if X is not last node. Use following two steps (a) Copy the data of next of X to X. (b)
Delete next of X.
b. Possible if size of linked list is even
c. Possible if size of linked list is odd
d. Possible if X is not first node. Use following two steps (a) Copy the data of next of X to X. (b)
Delete next of X: a
8. 8. You are given pointers to first and last nodes of a singly linked list, which of the following
operations are dependent on the length of the linked list?
a. Delete the last element of the list
b. Delete the first element
, CSD201 Questons and Answers 2024
c. Insert a new element as a first element
d. Add a new element at the end of the list: a
9. 9. Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What is
the worst-case time complexity of the best known algorithm to delete the node x from the list?
a. O(1)
b. O(n)
c. O(logn)
d. O(log2n): b