DAA MCQ
Algorithm
The algorithm is a step-by-step process to solve any problem and is a sequence of instructions that act on some input data to produce some output in a finite number of steps. The algorithm is independent of any programming language.
Why analysis of algorithms?
- For a given problem, there are many ways to design algorithms for it
- Analysis of algorithms to determine which algorithm should be chosen to solve the problem.
The complexity of algorithm on performance analysis of algorithm:
- Time complexity: time complexity of an algorithm is the total time required by the program to run till its completion
- Space complexity: Space complexity is the total space required by an algorithm to run till its completion.
Time and space complexity depends on lots of things like hardware, OS, processes, etc.
The analysis is of two types:
- Posteriori analysis: In Posteriori analysis, Algorithm is implemented and executed on certain fixed hardware and software. Then the algorithm is selected which takes the least amount of time to execute. Hence, the time used is given in time units like ms, ns, etc.
- Priori analysis: In Priori analysis, The time of the algorithm is found prior to implementation. Here time is not in terms of any such time units. Instead, it represents the number of operations that are carried out while executing the algorithm.
Asymptotic notations:
- Asymptotic notations are used to represent the complexity of an algorithm
- With the help of asymptotic notations, we can analyze the time performance of the algorithm.
There are three types of asymptotic notations:
- Theta notation
- Omega notation
- Big Oh Notation
Design and Analysis of Algorithms MCQ
Dijkstra’s algorithm is used to solve __________ problems?
The Bellmann Ford Algorithm returns __________ value?
Which of the following is used for solving the N Queens Problem?
Which of the following statements is true about AVL Trees?
Representation of data structure in memory is known as?
In what time complexity can we find the diameter of a binary tree optimally?
To main measures of the efficiency of an algorithm are?
Which of the following sorting algorithms provide the best time complexity in the worst-case scenario?
Which of the following is a Divide and Conquer algorithm?
Which of the following data structure is used to perform recursion?
Identify the best case time complexity of selection sort?
Another name of the fractional knapsack is?
Identify the approach followed in Floyd Warshall’s algorithm?
Hamiltonian path problem is _________?
What is the time complexity of the following code snippet in C++?
void solve() {
string s = "scaler";
int n = s.size();
for(int i = 0; i < n; i++) {
s = s + s[i];
}
cout << s << endl;
}
When a pop() operation is called on an empty queue, what is the condition called?
What is the time complexity of the binary search algorithm?
What will be the best sorting algorithm, given that the array elements are small (<= 1e6)?
What is the time complexity of the Sieve of Eratosthenes to check if a number is prime?
The worst-case time complexity of Quicksort is?
What is the technique called in which it does not require extra memory for carrying out the sorting procedure?
Identify the slowest sorting technique among the following?
Select the correct recurrence relation for Tower of Hanoi?
Identify the sorting technique which compares adjacent elements in a list and switches whenever necessary?
Among the following options which is the best sorting algorithm when the list is already sorted?
What is the best case time complexity of the binary search algorithm?
Which of the following algorithms are used to find the shortest path from a source node to all other nodes in a weighted graph?
Which of the following are applications of Topological Sort of a graph?
What is the time complexity in decreasing the node value in a binomial heap?
An algorithm is __________?
Which of the following is incorrect? Algorithms can be represented:
What is the time complexity to insert an element to the front of a LinkedList(head pointer given)?
What should be considered when designing an algorithm?
Which of the following is known to be not an NP-Hard Problem?
The worst-case time complexity of Selection Exchange Sort is?
Heap is a _____________?
What is the maximum number of swaps that can be performed in the Selection Sort algorithm?
Worst-case time complexity to access an element in a BST can be?
In a graph of n nodes and n edges, how many cycles will be present?
Kruskal’s Algorithm for finding the Minimum Spanning Tree of a graph is a kind of a?
Which of the following algorithms are used for string and pattern matching problems??
The time complexity for travel Singh all nodes in a binary search tree with n nodes and printing them in order is?
Identify the function of the stack that returns the top data element of the stack?
What is the best time complexity we can achieve to precompute all-pairs shortest paths in a weighted graph?
Which of the following functions provides the maximum asymptotic complexity?
The time complexity to find the longest common subsequence of two strings of length M and N is?