DSA MIDTERM Flashcards

1
Q

What is the characteristic behavior of a queue?
A. LIFO (Last In First Out)
B. FILO (First In Last Out)
C. FIFO (First In First Out)
D. Random Access

A

FIFO (First In First Out)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which of the following operations adds an item to the end of a queue?
A. dequeue
B. enqueue
C. pop
D. front

A

enqueue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the dequeue() operation do in a queue?
A. Removes the item from the front
B. Adds an item to the rear
C. Checks if the queue is full
D. Returns the last item

A

Removes the item from the front

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which operation checks if a queue is empty?
A. get-size()
B. is-empty()
C. front()
D. back()

A

is-empty()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is returned by the front() method in a queue?
A. The item at the front
B. The item at the back
C. The number of elements
D. A boolean value

A

The item at the front

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the main disadvantage of using a linked list over an array?
A. Requires more memory due to pointers
B. Slower access to elements
C. Only stores primitive types
D. Can’t grow in size

A

Requires more memory due to pointers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which type of linked list can only be traversed in one direction?
A. Singly Linked List
B. Doubly Linked List
C. Circular Linked List
D. Binary Tree

A

Singly Linked List

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In a doubly linked list, each node contains:
A. One data field and one link
B. One data field and two links
C. Only links
D. One link and one method

A

One data field and two links

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In a circular linked list, the last node points to:
A. NULL
B. Middle node
C. First node
D. Random node

A

First node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which of the following is not a queue operation?
A. enqueue()
B. traverse()
C. dequeue()
D. front()

A

traverse()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What happens when a queue is full?
A. No more items can be enqueued
B. It resets
C. It removes the front item
D. It duplicates the rear item

A

No more items can be enqueued

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which method removes the front element without returning it?
A. pop()
B. dequeue()
C. front()
D. push()

A

pop()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the time complexity of insertion at the rear of a queue using a circular array?
A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the get-size() method return?
A. The last index
B. The number of elements in the queue
C. The queue capacity
D. Boolean value

A

The number of elements in the queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the pointer to the first node in a linked list called?
A. HEAD
B. TAIL
C. START
D. NODE

A

HEAD

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In a singly linked list, the last node points to:
A. First node
B. NULL
C. Head node
D. Itself

A

NULL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What type of linked list allows bidirectional traversal?
A. Singly linked list
B. Doubly linked list
C. Queue
D. Stack

A

Doubly linked list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Which type of linked list does not end in NULL?
A. Singly Linked List
B. Doubly Linked List
C. Circular Linked List
D. Static List

A

Circular Linked List

19
Q

What is the main purpose of using a circular array in a queue?
A. Simplifies logic
B. Saves memory
C. Speeds up sorting
D. Avoids overflow

A

Saves memory

20
Q

Which queue operation is equivalent to inserting at the end of the list?
A. enqueue
B. dequeue
C. front
D. pop

21
Q

A queue always allows insertions at the front.
T/F

22
Q

A singly linked list node stores both data and a pointer to the next node.

23
Q

Doubly linked lists require three references per node.

24
Q

In a circular linked list, traversal can go infinitely if not properly terminated.

25
A linked list uses contiguous memory blocks to store its elements.
False
26
What type of algorithm is Merge Sort? A. Greedy B. Divide and conquer C. Backtracking D. Dynamic programming
Divide and conquer
27
Which of the following best describes the process of Merge Sort? A. Sorts by comparing each element to all others B. Uses pivot to partition arrays C. Divides the array and merges sorted sub-arrays D. Repeatedly places maximum elements at the end
Divides the array and merges sorted sub-arrays
28
What is the time complexity of Merge Sort in the best, average, and worst cases? A. O(n²) B. O(n) C. O(n log n) D. O(log n)
O(n log n)
29
What does the merge() function in Merge Sort do? A. Deletes elements B. Finds the median C. Merges two sorted sub-arrays D. Finds the pivot
Merges two sorted sub-arrays
30
In Merge Sort, the base case of recursion is when the array has: A. Two elements B. One element C. Three elements D. No elements
One element
31
Quick Sort is a type of: A. Graph algorithm B. Greedy algorithm C. Divide and conquer algorithm D. Dynamic programming algorithm
Divide and conquer algorithm
32
In Quick Sort, which of the following is true about the pivot? A. It is always the largest element B. It is always the middle element C. It is the element used to partition the array D. It is the smallest element in the array
It is the element used to partition the array
33
What is the worst-case time complexity of Quick Sort? A. O(n log n) B. O(n) C. O(n²) D. O(log n)
O(n²)
34
What condition causes the worst case in Quick Sort? A. Array is partially sorted B. Array has duplicates C. Array is already sorted D. Array has only one element
Array is already sorted
35
What does the partition() function in Quick Sort do? A. Swaps all elements B. Sorts a sub-array C. Divides the array based on pivot D. Merges sub-arrays
Divides the array based on pivot
36
Which of the following is assumed by Bucket Sort for optimal performance? A. All elements are integers B. Elements are normally distributed C. Elements are uniformly distributed in [0, 1) D. Elements are in ascending order
Elements are uniformly distributed in [0, 1)
37
Bucket Sort performs best when: A. All elements are duplicates B. Elements are randomly distributed C. Array is sorted D. Array has large negative numbers
Elements are randomly distributed
38
What sorting algorithm is commonly used inside each bucket in Bucket Sort? A. Merge Sort B. Quick Sort C. Insertion Sort D. Selection Sort
Insertion Sort
39
Which data structure is typically used for storing buckets? A. Arrays B. Stacks C. Linked Lists D. Trees
Linked Lists
40
Which of the following best describes Bucket Sort’s time complexity on average? A. O(n²) B. O(log n) C. O(n) D. O(n log n)
O(n)
41
Radix Sort sorts elements based on: A. Their values only B. Their digits C. Their length D. Their frequency
Their digits
42
In Radix Sort, sorting is done from: A. Most significant digit to least B. Least significant digit to most C. Left to right D. In reverse order
Least significant digit to most
43
Radix Sort uses which type of sorting technique internally? A. Merge Sort B. Insertion Sort C. Counting Sort D. Selection Sort
Counting Sort
44
Which of the following sorting algorithms is non-comparative? A. Merge Sort B. Quick Sort C. Radix Sort D. Bubble Sort
Radix Sort