NEW
Font size
WorksheetsCode Uncode 2.0
Total questions: 40
Worksheet time: 40mins
In order traversal of binary search tree will produce −
unsorted list
sorted list
reverse of input
none of the above
What data structure is used for breadth first traversal of a graph?
queue
stack
list
none of the above
left_subtree (keys) ≤ node (key) ≤ right_subtree (keys)
Complete Binary Tree
Binary Tree
Binary Search Tree
All of the above
If the array is already sorted, which of these algorithms will exhibit the best performance
Merge Sort
Insertion Sort
Quick Sort
Heap Sort
An algorithm is
a piece of code to be executed.
a loosely written code to make final code.
a step by step procedure to solve problem.
all of the above.
In binary heap, whenever the root is removed then the rightmost element of last level is replaced by the root. Why?
It is the easiest possible way.
To make sure that it is still complete binary tree.
Because left and right subtree might be missing.
None of the above!
If queue is implemented using arrays, what would be the worst run time complexity of queue and dequeue operations?
Ο(n), Ο(n)
Ο(n), Ο(1)
Ο(1), Ο(n)
Ο(1), Ο(1)
Program with highest run-time complexity is
Tower of Hanoi
Fibonacci Series
Prime Number Series
None of the above
If we choose Prim's Algorithm for uniquely weighted spanning tree instead of Kruskal's Algorithm, then
we'll get a different spanning tree.
we'll get the same spanning tree.
spanning will have less edges.
spanning will not cover all vertices.
Which of the following algorithm does not divide the list −
linear search
binary search
merge sort
quick sort
Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?
Insertion sort
Quick sort
Heap sort
Merge sort
Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are
Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT
Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR
Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT
Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT
A program P reads in 500 integers in the range [0..100] representing the scores 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?
An array of 50 numbers
An array of 100 numbers
An array of 500 numbers
A dynamically allocated array of 550 numbers
In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is
log(2*n)
n/2
log(2*n) -1
n
What is the worst case possible height of AVL tree?
2Logn, Assume base of log is 2
1.44log n, Assume base of log is 2
Depends upon implementation
Theta(n)
Which of the following is AVL Tree?
Only A
A and C
A, B and C
Only B
B+ Trees are considered BALANCED because
the lengths of the paths from the root to all leaf nodes are all equal.
the lengths of the paths from the root to all leaf nodes differ from each other by at most 1.
the number of children of any two non-leaf sibling nodes differ by at most 1.
the number of records in any two leaf nodes differ by at most 1.
The minimum number of stacks needed to implement a queue is
3
1
2
4
The average depth of a binary search tree is:
O(n0.5)
O(n)
O(log n)
O(n log n)
The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is
A
B
C
D
Which of the following correctly declares an array?
int geeks[20];
int geeks;
geeks{20};
array geeks[20];
What is the time complexity of binary search algorithm?
O(n)
O(log n)
O(n^2)
O(1)
What is the worst case time complexity of quicksort algorithm?
O(n)
O(log n)
O(n^2)
O(1)
Which of the following is not a stable sorting algorithm?
Insertion sort
Selection sort
Bubble sort
Quick sort
What is the main advantage of using a hash table data structure?
Constant time for all operations
Efficient sorting
Efficient searching in a sorted array
Dynamic resizing
Which sorting algorithm has the worst-case time complexity of O(n^2) but is widely used for small datasets or as a subroutine in other algorithms?
Quick Sort
Bubble Sort
Merge Sort
Insertion Sort
In a binary search tree, which traversal visits the nodes in ascending order?
Preorder
Inorder
Postorder
Level Order
Which data structure is used to implement priority queues?
Stack
Queue
Heap
Linked List
Which of the following is NOT a type of algorithm design paradigm?
Divide and Conquer
Dynamic Programming
Sequential
Greedy
Which of the following is NOT a fundamental operation in a binary search tree?
Insertion
Deletion
Searching
Sorting
In dynamic programming, what does "optimal substructure" mean?
A problem can be divided into smaller subproblems
A solution can be built from solutions to subproblems
A problem can be solved by a greedy algorithm
A solution is derived by choosing the best option at each step
Which sorting algorithm has a time complexity of O(n log n) in the best, average, and worst cases?
Bubble Sort
Selection Sort
Merge Sort
Insertion Sort
Which algorithm is used for finding the shortest path in a weighted graph when there are negative weight edges?
Dijkstra's Algorithm
Bellman-Ford Algorithm
Prim's Algorithm
Kruskal's Algorithm
What is the primary advantage of using an AVL tree over a regular binary search tree?
Faster insertion
Faster deletion
Guaranteed balanced height
Lower memory usage
Given an algorithm with a time complexity of O(2^n), how will the running time be affected if the input size is doubled?
It will remain the same
It will be halved
It will double
It will quadruple
Suppose you have an algorithm with a time complexity of O(log n) and another with a time complexity of O(sqrt(n)). As n increases, which algorithm will have a slower growth rate in terms of time?
O(log n)
O(sqrt(n))
Both will have the same growth rate
It depends on the specific values of n
You have an algorithm with a time complexity of O(n^2) and another with a time complexity of O(n log n). For what range of input sizes, will the algorithm with O(n log n) be faster?
n < 10
10 < n < 100
100 < n < 1000
n > 1000
Consider a weighted directed graph with n vertices and m edges. What is the maximum possible time complexity to find the shortest path between two vertices using Dijkstra's algorithm?
O(n log n)
O(n^2)
O(m + n log n)
O(n^3)
You are given a weighted, connected, undirected graph. You want to find a spanning tree with the minimum possible weight. Which algorithm should you use?
Prim's Algorithm
Bellman-Ford Algorithm
Kruskal's Algorithm
Floyd-Warshall Algorithm
In algorithm design, what is the primary purpose of the "Master Theorem"?
To analyze the average-case time complexity of algorithms
To analyze the worst-case time complexity of algorithms
To provide a general framework for solving recurrence relations
To optimize algorithms for specific use cases
