0% found this document useful (0 votes)
45 views6 pages

Data Structures and Algorithms Design - Unit 7 - Week - 4

Uploaded by

saiking007ak
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)
45 views6 pages

Data Structures and Algorithms Design - Unit 7 - Week - 4

Uploaded by

saiking007ak
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

X

(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)

[email protected]

NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL) » Data Structures and Algorithms Design (course)


Click to register for Certification exam
(https://examform.nptel.ac.in/2025_10/exam_form/dashboard)

If already registered, click to check your payment status

Course outline

About NPTEL ()

How does an NPTEL online course work? ()

Week 0 ()

Week - 1 ()

Week - 2 ()

Week - 3 ()

Week - 4 ()

Lecture 10: Range Minima in 1D array (unit?unit=38&lesson=39)

Lecture 11: Abstract Data Structures: Lists (unit?unit=38&lesson=40)

Lecture 12: Linked Lists (unit?unit=38&lesson=41)

Quiz: Week 4 : Assignment 4 (assessment?name=42)

Week 4 Feedback (unit?unit=38&lesson=45)

Week 4: Assignment 4 Solution (unit?unit=38&lesson=53)

Week - 5 ()

Week - 6 ()
Week - 7 ()

Week 4 : Assignment 4
The due date for submitting this assignment has passed.
Due on 2025-08-20, 23:59 IST.

Assignment submitted on 2025-08-13, 09:08 IST


1) What is the time complexity of inserting an element at the beginning of a singly linked list? 1 point

O(n)

O(n log n)

O(1)

O(log n)

Yes, the answer is correct.


Score: 1
Accepted Answers:
O(1)

2) Consider the linked list : 1 → 2 → 3 → 4 → 5 → 6 . What will the linked list look like after 1 point
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

Yes, the answer is correct.


Score: 1
Accepted Answers:
1 → 2 → 4 → 5 → 6

3) A singly linked list initially contains nodes with values: 12 → 47 → 85 → 63 → 29. 1 point

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

Yes, the answer is correct.


Score: 1
Accepted Answers:
12 → 47 → 85 → 63 → 29

4) For the Range Minima problem, what is the time complexity per query using a brute-force approach when 1 point
space complexity is O(n) ?

O(n)

O(log n)

O(1)

2
O(n )

Yes, the answer is correct.


Score: 1
Accepted Answers:
O(n)

5) A doubly linked list initially contains nodes: 10 ↔ 25 ↔ 40 ↔ 60 . You execute the following 1 point
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

Yes, the answer is correct.


Score: 1
Accepted Answers:
10 ↔ 25 ↔ 44 ↔ 40 ↔ 60

6) circular singly linked list contains the nodes: 5 → 12 → 19 → 27 → 34 → 5 (circular). 1 point

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

Yes, the answer is correct.


Score: 1
Accepted Answers:
19 → 27 → 34 → 19

7) Suppose we solve the 1D Range Minima Problem using an efficient algorithm that preprocesses the array in 1 point
O(n log n) time.

What is the time complexity of answering a single query after this preprocessing?

O(1)

O(log n)

O(n)

O(n log n)

Yes, the answer is correct.


Score: 1
Accepted Answers:
O(1)

8) Consider the following binary tree: 1 point


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
No, the answer is incorrect.
Score: 0
Accepted Answers:
50 → 70 → 60, Key not found

9) Which of the following best describes a struct data structure? 1 point

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


Yes, the answer is correct.
Score: 1
Accepted Answers:
A collection of variables of different types grouped together under one name

10) A binary search tree contains the keys 5, 10, 15,..., 100, inserted in increasing order. 1 point
The resulting BST has height 19.
How many nodes are visited when searching for the key 100?

10
1

20

Yes, the answer is correct.


Score: 1
Accepted Answers:
20

You might also like