0% found this document useful (0 votes)
19 views2 pages

Dsa Quiz-2 Set-2

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 2

DSA Quiz II

CSE2711 - Data Structure and Algorithms


05th May 2023

Name: …………………………………………………………………. ID: ………………………………………………………

Option/Ques 1 2 3 4 5 6 7 8 9 10
a.
b.
c.
d.

Note: All Questions are Mandatory. Write the reason for each question in the space provided (Max. Marks = 10)

1. In the worst case, the number of a. Returns the original linked list
comparisons needed to search a singly b. Returns the linked list after reversing it
linked list of length n for a given element c. Returns the linked list containing
will be …. elements at odd nodes
a. O (logn) d. None of above
b. O (n)
c. O (1)
d. None

3. Which of the following is not the


application of stack?
a) A parentheses balancing program
2. What does the following code snippet b) Tracking of local variables at run time
do? c) Compiler Syntax Analyzer
ListNode* solve(ListNode* head) { d) Data Transfer between two asynchronous
ListNode* prev = NULL;
processed.
if(head == NULL) {
return head;
}
if(head -> next == NULL) {
return head;
}
ListNode* curr = head -> next; 4. What is the value of the postfix
while(head != NULL) {
expression 6 3 2 4 + – *?
head -> next = prev;
prev = head; a. 1
head = curr; b. 40
if(curr != NULL) { c. 74
curr = curr -> next; d. -18
}
}
return prev;
}
DSA Quiz II

b. 2,7
c. 1,3
5. What are the time complexities of finding 8th d. 5,2
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.
9. A stack has a capacity of 5 and currently has 3
a. O(1) and O(n) elements in it. What is the maximum number
b. O(1) and O(1) of elements that can be pushed onto the
c. O(n) and O(1) stack?
d. O(n) and O(n) a. 2
b. 3
c. 5
d. None

6. What is the result of the following


operation?
Top (Push (S, X))
a. X 10. What is the time complexity for deleting an
b. X+S element from a singly linked list?
c. S a. O(1)
d. XS b. O(n)
c. O(log n)
d. O(n^2)

7. PUSH (10), PUSH (20), POP, PUSH (10), PUSH


(20), POP, POP, POP, PUSH (20), POP.
The sequence of values popped out is:
a. 20, 10, 20, 10, 20
b. 20, 20, 10, 10, 20
c. 10, 20,20,10,20
d. 20,20,10,20,10

8. A queue has the following elements: 3, 5, 2,


7, 1. What is the result of dequeuing two
elements from the queue?
a. 3,5

You might also like