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
Which of the following algorithms are used to find the shortest path from a source node to all other nodes in a weighted graph?
What is the maximum number of swaps that can be performed in the Selection Sort algorithm?
What is the technique called in which it does not require extra memory for carrying out the sorting procedure?
What is the time complexity in decreasing the node value in a binomial heap?
What is the time complexity of the binary search algorithm?
Learn via our Video Courses
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;
}
What is the time complexity of the Sieve of Eratosthenes to check if a number is prime?
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?
What will be the best sorting algorithm, given that the array elements are small (<= 1e6)?
When a pop() operation is called on an empty queue, what is the condition called?
Which of the following algorithms are used for string and pattern matching problems??
What is the best time complexity we can achieve to precompute all-pairs shortest paths in a weighted graph?
Which of the following are applications of Topological Sort of a graph?
Which of the following data structure is used to perform recursion?
Which of the following functions provides the maximum asymptotic complexity?
Which of the following is a Divide and Conquer algorithm?
Which of the following is incorrect? Algorithms can be represented:
Which of the following is known to be not an NP-Hard Problem?
Which of the following is used for solving the N Queens Problem?
Which of the following sorting algorithms provide the best time complexity in the worst-case scenario?
Which of the following statements is true about AVL Trees?
Worst-case time complexity to access an element in a BST can be?
In what time complexity can we find the diameter of a binary tree optimally?
An algorithm is __________?
Another name of the fractional knapsack is?
Dijkstra’s algorithm is used to solve __________ problems?
Hamiltonian path problem is _________?
Heap is a _____________?
Identify the approach followed in Floyd Warshall’s algorithm?
Identify the best case time complexity of selection sort?
Identify the function of the stack that returns the top data element of the stack?
Identify the slowest sorting technique among the following?
Identify the sorting technique which compares adjacent elements in a list and switches whenever necessary?
In a graph of n nodes and n edges, how many cycles will be present?
Among the following options which is the best sorting algorithm when the list is already sorted?
Kruskal’s Algorithm for finding the Minimum Spanning Tree of a graph is a kind of a?
Representation of data structure in memory is known as?
Select the correct recurrence relation for Tower of Hanoi?
The Bellmann Ford Algorithm returns __________ value?
The time complexity for travel Singh all nodes in a binary search tree with n nodes and printing them in order is?
The time complexity to find the longest common subsequence of two strings of length M and N is?
The worst-case time complexity of Quicksort is?
The worst-case time complexity of Selection Exchange Sort is?
To main measures of the efficiency of an algorithm are?
What is the best case time complexity of the binary search algorithm?