NPTEL Data Structures and Algorithms Design Week 4 Assignment Answers 2025
1. What is the time complexity of inserting an element at the beginning of a singly linked list?
- O(n)
- O(nlogn)
- O(1)
- O(logn)
Answer : See Answers
2. Consider the linked list : 1→2→3→4→5→6. What will the linked list look like after implementing the code below?
temp1 = head->next
temp2 = temp1->next
temp1->next = temp2->next
- 1→2→3→4→5→6
- 2→3→4→5→6
- 1→3→4→5→6
- 1→2→4→5→6
Answer :
3. A singly linked list initially contains nodes with values: 12 → 47 → 85 → 63 → 29.
The following operations are performed in code:
Node* p = head->next;
Node* temp = new Node(99);
temp->next = p->next;
p->next = temp;
p->next = p->next->next;
What is the final list?
- 12 → 47 → 99 → 85 → 63 → 29
- 12 → 47 → 99 → 63 → 29
- 12 → 47 → 85 → 63 → 29
- 12 → 99 → 47 → 85 → 63 → 29
Answer :
4. For the Range Minima problem, what is the time complexity per query using a brute-force approach when space complexity is O(n)?
- O(n)
- O(logn)
- O(1)
- O(n2)
Answer :
5. A doubly linked list initially contains nodes: 10↔25↔40↔60. You execute the following operations:
Node* p = head->next;
Node* temp = new Node(44);
temp->next = p->next;
temp->prev = p;
p->next->prev = temp;
p->next = temp;
What is the final list?
- 10↔44↔25↔40↔60
- 44↔10↔25↔40↔60
- 10↔40↔60
- 10↔25↔44↔40↔60
Answer : See Answers
6. circular singly linked list contains the nodes: 5→12→19→27→34→5 (circular).
A pointer tail points to the node with value 34.
You execute the following line of code:
tail−>next=tail−>next−>next−>next;
What does the updated circular list contain, starting from tail->next?
- 12→19→27→34→12
- 19→27→34→19
- 5→12→27→34→5
- 19→27→34→5→19
Answer :
7. Suppose we solve the 1D Range Minima Problem using an efficient algorithm that preprocesses the array in O(nlogn) time.
What is the time complexity of answering a single query after this preprocessing?
- O(1)
- O(logn)
- O(n)
- O(nlogn)
Answer :
8. Consider the following binary tree:

What is the path followed and output when performing binary search for the key 65?
- 50 → 30 → 40 → 65, output = 65
- 50 → 70 → 90 → 65, output = 65
- 50 → 70 → 60 → 65, output = 65
- 50 → 70 → 60, Key not found
Answer :
9. Which of the following best describes a struct data structure?
- A dynamic container for only one type of data
- A collection of variables of different types grouped together under one name
- A data structure used only for memory allocation
- A specialized tree-like data structure for searching records
Answer :
10. A binary search tree contains the keys 5, 10, 15,…, 100, inserted in increasing order.
The resulting BST has height 19.
How many nodes are visited when searching for the key 100?
- 10
- 1
- 20
- 5
Answer : See Answers


