[go: up one dir, main page]

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

Dsa - T4-MCQ

The document contains a series of questions related to data structures and algorithms, covering topics such as stacks, queues, linked lists, and sorting algorithms. Each question presents multiple-choice answers, testing knowledge on operations, complexities, and characteristics of various data structures. It serves as a quiz or study guide for understanding fundamental concepts in computer science.

Uploaded by

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

Dsa - T4-MCQ

The document contains a series of questions related to data structures and algorithms, covering topics such as stacks, queues, linked lists, and sorting algorithms. Each question presents multiple-choice answers, testing knowledge on operations, complexities, and characteristics of various data structures. It serves as a quiz or study guide for understanding fundamental concepts in computer science.

Uploaded by

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

DATA STRUCTURES AND ALGORITHMS

M1-T4
1. Which of the following data structures can be used for parentheses matching?
a) Linked List
b) queue
c) priority queue
d) stack
2. The function that deletes values from a queue is called
a) Enqueue
b) dequeue
c) pop
d) peek
3. The result evaluating the postfix expression 10 5 + 60 6 / * 8 – is
a) 284
b) 213
c) 142
d) 71
4. A program P reads in 500 integers in the range [0, 100] representing the cores of 500
students. It then prints the frequency of each score above 50. What would be the
best way for P to store the frequencies?
a) An array of 50 numbers
b) An array of 100 numbers
c) An array of 500 numbers
d) A dynamically allocated array of 550 numbers
5. What is a dequeue?
a) A queue implemented with both singly and doubly linked lists
b) A queue with insert/delete defined for front side of the queue
c) A queue with insert/delete defined for both front and rear ends of the queue
d) A queue implemented with a doubly linked list
6. While evaluating a prefix expression, the string is read from?
a) left to right
b) right to left
c) center to right
d) center to left to right
7. How many stacks are required for applying evaluation of infix expression algorithm?
a) one
b) two
c) three
d) four
8. The position in a queue from which an element is deleted is called as
(a) Top
(b) Front
(c) Rear
(d) Mid
9. Which function places an element on the stack?
a) Pop ()
b) Push ()
c) Peek ()
d) IsEmpty()
10. Which data structure has fixed size?
(a) Arrays
(b) Linked lists
(c) Trees
(d) Graphs
11. If TOP = MAX–1, then that the stack is
a) Empty
b) Full
c) Contains some data
d) None of these
12. The running time complexity of a linear time algorithm is given as
a) O(1)
b) O(n)
c) O(n log n)
d) O(n2)
13. If an array is declared as int arr[50], how many elements can it hold?
a) 49
b) 50
c) 51
d) 0
14. Stack is a
a) LIFO
b) FIFO
c) FILO
d) LILO
15. Disks piled up one above the other represent a
a) Stack
b) Queue
c) Linked List
d) Array
16. Reverse Polish notation is the other name of
a) Infix expression
b) Prefix expression
c) Postfix expression
d) Algebraic expression
17. In a stack data structure UNDERFLOW occurs when ____
a) TOP == NULL
b) TOP == MAX-1
c) TOP == 0
d) TOP == 1
18. A line in a grocery store represents a
a) Stack
b) Queue
c) Linked List
d) Array
19. In a queue, insertion is done at
a) Rear
b) Front
c) Back
d) Top
20. Which of the following is true about a single linked list?
a) Each node contains a pointer to the previous node.
b) Each node contains a pointer to the next node.
c) It allows bidirectional traversal.
d) It requires more memory than a doubly linked list.
21. Which of the following operations is NOT possible in a single linked list?
a) Insertion at the beginning
b) Deletion at the end
c) Random access to any element
d) Traversal from head to tail
22. What happens if the head pointer of a single linked list is lost?
a) The list becomes empty.
b) The list cannot be accessed anymore.
c) The list is automatically deleted.
d) The list becomes circular.
23. Which of the following is true about a circular single linked list?
a) The last node points to the head.
b) The head node points to the last node.
c) It cannot be traversed.
d) It requires less memory than a regular single linked list.
24. Which of the following is the correct way to reverse a single linked list?
a) Swap the head and tail pointers.
b) Traverse the list and reverse the direction of the next pointers.
c) Delete all nodes and reinsert them in reverse order.
d) Use a stack to store and reinsert nodes.
25. Which of the following is true about a circular doubly linked list?
a) The last node points to the head, and the head points to the last node.
b) The "prev" pointer of the head is NULL.
c) The "next" pointer of the last node is NULL.
d) It cannot be traversed in both directions.
26. What happens if the "next" pointer of the last node in a doubly linked list is not set to
NULL?
a) The list becomes circular.
b) The list cannot be traversed.
c) The list is automatically reversed.
d) The list is corrupted.
27. What is the corresponding postfix notation for the expression A+B∗C−D/E
a) ABC∗+DE/−
b) AB+C∗DE/−
c) ABC+∗DE/−
d) ABC∗DE/+−
28. What is the time complexity of Linear Search in the worst case?

a) O(1)
b) O(log n)
c) O(n)
d) O(n²)
29. Which of the following is a prerequisite for Binary Search?
a) The list must be unsorted.
b) The list must be sorted.
c) The list must have duplicate elements.
d) The list must be circular
30. Which searching algorithm is best suited for a linked list?
a) Binary Search
b) Linear Search
c) None of the above
d) Both Binary and Linear Search
31. Which searching algorithm uses a "divide and conquer" approach?
a) Linear Search
b) Binary Search
c) Jump Search
d) None of these
32. Which sorting algorithm is an example of a "divide and conquer" approach?
a) Bubble Sort
b) Quick Sort
c) Insertion Sort
d) Selection Sort
33. Which sorting algorithm is best suited for small datasets?
a) Quick Sort
b) Merge Sort
c) Insertion Sort
d) Heap Sort
34. If an integer requires 2 bytes of space, then what will be the size of the following C
array? Int a[3][4];
a) 24 bytes
b) 12
c) 7
d) 14 bytes
35. What will be the output of the following code snippet for 1->2->3->4->5 ?

void solve (struct ListNode* head)


{
while (head != NULL)
{
printf("%d ", head->data);
head = head->next;
}
}
a) 1 2 3 4 5
b) 5 4 3 2 1
c) 1 3 5 2 4
d) 2 4 1 3 5
36. What will be the output of the following code snippet for the list 1->2->3->4->5->6?

void solve (struct node* start)


{
If (start == NULL)
return;
printf ("%d ", start->data);
if(start->next != NULL )
solve(start->next->next);
printf ("%d ", start->data);
}

a) 1 2 3 4 5 6
b) 2 4 6 1 3 5
c) 1 3 5 1 3 5
d) 1 3 5 5 3 1
37. Which of the following are applications of linked lists?

a) Implementing file systems


b) Chaining in hash tables
c) Binary Trees implementation
d) All of the above
38. Which of the following is similar about singly and doubly linked list?
a) Both of them are not able to access the data at a random position in constant
time.
b) Both of them can add a new node after given node or at the beginning of the
list in O (1) time.
c) Both of them can delete the first node in O(1) time.
d) All of the above
39. Which of the following sorting algorithms is preferred to sort a linked list?
a) Merge Sort
b) Quick Sort
c) Insertion Sort
d) None of the above

40. In a circular linked list insertion of a record requires the


modification of?
a) 1 pointer
b) 2 pointers
c) 3 pointers
d) 4 pointers

You might also like