Design and Analysis of Algorithms
2023105402
End Semester Examination - 2023
Instructions
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer of the following (Any seven question
only):
Ask AI
Q1.1
The fractional Knapsack problem can be solved by using
Ask AI
Q1.2
BFS on a graph $ G=(V,E) $ has running time
Ask AI
Q1.3
The minimum number of colors needed to color a graph having $ n>3 $ vertices and 2 edges is
Ask AI
Q1.4
Complexity the recurrence relation $ T(n)=8T(\frac{n}{2})+n^2 $ is
Ask AI
Q1.5
Travelling salesman problem belongs to
Ask AI
Q1.6
Kruskal's algorithm uses ___ and Prism' algorithm uses ___ in determining the MST
Ask AI
Q1.7
Level order traversal of a rooted tree can be done by starting from root and performing
Ask AI
Q1.8
An algorithm is made up of two independent time complexities $ f(n) $ and $ g(n) $. Then the complexities of the algorithm is in order of
Ask AI
Q1.9
Which of the following standard algorithms is not a greedy algorithm?
Ask AI
Q1.10
The node removal of which makes a graph disconnected is called
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
Write the algorithm for quick-sort and find its complexity.
Ask AI
Q2.2
Discuss the average, worst, best time complexity of the algorithm. Give suitable examples.
Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
Construct the Huffman coding tree for the text of characters with given frequencies: T:43, I:38, V:16, K:8, L:56, E:12, O:41, Z:13, P:22, R:6.
Ask AI
Q3.2
State the general Knapsack problem. Write a greedy algorithm for this problem and derive its time complexity.
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
State master's theorem and find the time complexity for the following recurrence: $ T(n) = 2T(n^{1/2}) + \log n $
Ask AI
Q4.2
What is negative weight-cycle? Write Bellman-Ford algorithm to find single source shortest distance of a directed graph.
Ask AI
Q.5 Solve both questions :
Ask AI
Q5.1
Find the minimum number of operations required for the following matrix chain multiplication using dynamic programming: $ A(10 \times 20) * B(20 \times 50) * C(50 \times 1) * D(1 \times 100) $
Ask AI
Q5.2
Write Knuth-Morris-Pratt algorithm for string matching problem.
Ask AI
Q.6 Solve both questions :
Ask AI
Q6.1
Write an algorithm to find a minimum spanning tree (MST) for an undirected graph. Estimate the time complexity of your algorithm.
Ask AI
Q6.2
Using greedy strategy. Schedule the following jobs within deadline so as to maximize the profit. Deadline and profits are mentioned as follow:
Job i: 1, 2, 3, 4
Deadline d: 3, 2, 3, 1
Profit g: 9, 7, 7, 2Ask AI
Q.7 Solve both questions :
Ask AI
Q7.1
Write an algorithm for n-queen's problem find its time-complexity and explain the algorithm using an example.
Ask AI
Q7.2
Solve the single source shortest path problem for the following graph considering '1' as the source vertex using Dijkstra's algorithm.

Ask AI
Q.8 Solve all questions :
Ask AI
Q8.1
Define the classes P and NP.
Ask AI
Q8.2
Discuss what you mean by polynomial reduction.
Ask AI
Q8.3
Discuss diagrammatically the relation among P class, NP class, NP hard and NP complete.
Ask AI
Q8.4
Describe Clique Decision Problem (CDP).
Ask AI
Q8.5
Explain the max-flow min-cut theorem with an example.
Ask AI
Q.9 Write short notes on any two of the following:
Ask AI
Q9.1
Ask AI
2023V2105402
End Semester Examination - 2023
Instructions
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer of the following (Any seven question
only):
Ask AI
Q1.1
The fractional Knapsack problem can be solved by using
Ask AI
Q1.2
BFS on a graph has running time
Ask AI
Q1.3
The minimum number of colors needed to color a graph having n>3 vertices and 2 edges is
Ask AI
Q1.4
Complexity the recurrence relation is
Ask AI
Q1.5
Travelling salesman problem belongs to
Ask AI
Q1.6
Kruskal's algorithm uses ___ and Prism' algorithm uses ___ in determining the MST
Ask AI
Q1.7
Level order traversal of a rooted tree can be done by starting from root and performing
Ask AI
Q1.8
An algorithm is made up of two independent time complexities and . Then the complexities of the algorithm is in order of
Ask AI
Q1.9
Which of the following standard algorithms is not a greedy algorithm?
Ask AI
Q1.10
The node removal of which makes a graph disconnected is called
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
Write the algorithm for quick-sort and find its complexity.
Ask AI
Q2.2
Discuss the average, worst, best time complexity of the algorithm. Give suitable examples.
Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
Construct the Huffman coding tree for the text of characters with given frequencies: T:43, I:38, V:16, K:8, L:56, E:12, O:41, Z:13, P:22, R:6.
Ask AI
Q3.2
State the general Knapsack problem. Write a greedy algorithm for this problem and derive its time complexity.
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
State master's theorem and find the time complexity for the following recurrence: $ T(n) = 2T(n^{1/2}) + \log n $
Ask AI
Q4.2
What is negative weight-cycle? Write Bellman-Ford algorithm to find single source shortest distance of a directed graph.
Ask AI
Q.5 Solve both questions :
Ask AI
Q5.1
Find the minimum number of operations required for the following matrix chain multiplication using dynamic programming: $ A(10 \times 20) * B(20 \times 50) * C(50 \times 1) * D(1 \times 100) $
Ask AI
Q5.2
Write Knuth-Morris-Pratt algorithm for string matching problem.
Ask AI
Q.6 Solve both questions :
Ask AI
Q6.1
Write an algorithm to find a minimum spanning tree (MST) for an undirected graph. Estimate the time complexity of your algorithm.
Ask AI
Q6.2
Using greedy strategy. Schedule the following jobs within deadline so as to maximize the profit. Deadline and profits are mentioned as follow:
Job i: 1, 2, 3, 4
Deadline d: 3, 2, 3, 1
Profit g: 9, 7, 7, 2Ask AI
Q.7 Solve both questions :
Ask AI
Q7.1
Write an algorithm for n-queen's problem find its time-complexity and explain the algorithm using an example.
Ask AI
Q7.2
Solve the single source shortest path problem for the following graph considering '1' as the source vertex using Dijkstra's algorithm.
Ask AI
Q.8 Solve all questions :
Ask AI
Q8.1
Define the classes P and NP.
Ask AI
Q8.2
Discuss what you mean by polynomial reduction.
Ask AI
Q8.3
Discuss diagrammatically the relation among P class, NP class, NP hard and NP complete.
Ask AI
Q8.4
Describe Clique Decision Problem (CDP).
Ask AI
Q8.5
Explain the max-flow min-cut theorem with an example.
Ask AI
Q.9 Write short notes on any two of the following:
Ask AI
Q9.1
Ask AI
2022105402
B.Tech 4th Semester Exam., 2022
Instructions
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer of the following (any seven) :
Ask AI
Q1.1
Any decision trees that sorts elements has height
Ask AI
Q1.2
Which one of the following is an application of Queue Data Structure?
Ask AI
Q1.3
The complexity of binary search algorithm is
Ask AI
Q1.4
In linear search algorithm the worst case occurs when
Ask AI
Q1.5
Given an unsorted array. The array has this property that every element in array is at most k distance from its position in sorted array where k is a positive integer smaller than size of array. Which sorting algorithm can be easily modified for sorting this array and what is the obtainable time complexity?
Ask AI
Q1.6
Approach of dynamic programming is similar to
Ask AI
Q1.7
In the divide and conquer process, breaking the problem into smaller sub-problems is the responsibility of
Ask AI
Q1.8
A priority queue is implemented as a Max-heap. Initially it has 5 elements. The level order traversal of the heap is 10, 8, 5, 3, 2. Two new elements '1' and '7' are inserted into the heap in that order. The level order traversal of the heap after the insertion of the elements is
Ask AI
Q1.9
If a problem can be solved by combining optimal solutions to non-overlapping problems, the strategy is called
Ask AI
Q1.10
The choice of polynomial class has led to the development of an extensive theory called
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
Calculate the time complexity of the following problem using divide and conquer strategies:
(i) $ T(n) = \sqrt{n} T(\sqrt{n}) + n $, $ n > 2 $
$ = a $, $ n \le 2 $
(ii) $ T(n) = T(n-1) + 1/n $, $ n > 1 $
$ = 1 $, $ n = 1 $Ask AI
Q2.2
Write time function and calculate the time complexity, space complexity and number of function calls of the following pseudocode using substitution method:
rec (n) {
if ($ n \le 1 $) return(1);
else { rec (n/2); for ($ i=1; i \le n; i++ $) printf("algorithm"); }
}Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
Explain the working of merge sort algorithm with an example. Give the complexity calculation of merge sort.
Ask AI
Q3.2
What are the rules of manipulate Big-Oh expression and about the typical growth rates of algorithms.
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
What is heap sort? What is the effect of calling MAX-HEAPIFY(A, i) when the element A[i] is larger than its children?
Ask AI
Q4.2
Explain how radix sort works, to what inputs it can be applied and what is its asymptotic complexity?
Ask AI
Q.5 Solve this question :
Ask AI
Q5.1
What do you mean by optimal solution in greedy approach? Define the properties and function of greedy approach. Consider the given graph $ G=(V,E) $ and find the minimum spanning tree by Prim's algorithms.

Ask AI
Q.6 Solve this question :
Ask AI
Q6.1
Find the optimal way to multiply the following matrices to perform the fewest multiplications:
A1: $ 5 \times 11 $, A2: $ 11 \times 4 $, A3: $ 4 \times 15 $, A4: $ 15 \times 23 $Ask AI
Q.7 Solve this question :
Ask AI
Q7.1
You are given a graph containing n vertices and m edges and given that the graph doesn't contain cycle of odd length. What is the time complexity of the best known algorithm to find out whether the graph is bipartite or not?
Ask AI
Q.8 Solve this question :
Ask AI
Q8.1
What is activity selection problem? Suppose that instead of always selecting the first activity to finish, we select the last activity to start that is compatible with all previously selected activities. Describe how this approach is a greedy algorithm, and prove that it yields an optimal solution.
Ask AI
Q.9 Write short notes on the following:
Ask AI
Q9.1
Ask AI
2022V4105402
B.Tech 4th Semester Exam., 2022
Instructions
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer of the following (any seven) :
Ask AI
Q1.1
Any decision trees that sorts elements has height
Ask AI
Q1.2
Which one of the following is an application of Queue Data Structure?
Ask AI
Q1.3
The complexity of binary search algorithm is
Ask AI
Q1.4
In linear search algorithm the worst case occurs when
Ask AI
Q1.5
Given an unsorted array. The array has this property that every element in array is at most k distance from its position in sorted array where k is a positive integer smaller than size of array. Which sorting algorithm can be easily modified for sorting this array and what is the obtainable time complexity?
Ask AI
Q1.6
Approach of dynamic programming is similar to
Ask AI
Q1.7
In the divide and conquer process, breaking the problem into smaller sub-problems is the responsibility of
Ask AI
Q1.8
A priority queue is implemented as a Max-heap. Initially it has 5 elements. The level order traversal of the heap is 10, 8, 5, 3, 2. Two new elements '1' and '7' are inserted into the heap in that order. The level order traversal of the heap after the insertion of the elements is
Ask AI
Q1.9
If a problem can be solved by combining optimal solutions to non-overlapping problems, the strategy is called
Ask AI
Q1.10
The choice of polynomial class has led to the development of an extensive theory called
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
Calculate the time complexity of the following problem using divide and conquer strategies:
(i) $ T(n) = \sqrt{n} T(\sqrt{n}) + n $, $ n > 2 $
$ = a $, $ n \le 2 $
(ii) $ T(n) = T(n-1) + 1/n $, $ n > 1 $
$ = 1 $, $ n = 1 $Ask AI
Q2.2
Write time function and calculate the time complexity, space complexity and number of function calls of the following pseudocode using substitution method:
rec (n) {
if ($ n \le 1 $) return(1);
else { rec (n/2); for ($ i=1; i \le n; i++ $) printf("algorithm"); }
}Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
Explain the working of merge sort algorithm with an example. Give the complexity calculation of merge sort.
Ask AI
Q3.2
What are the rules of manipulate Big-Oh expression and about the typical growth rates of algorithms.
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
What is heap sort? What is the effect of calling MAX-HEAPIFY(A, i) when the element A[i] is larger than its children?
Ask AI
Q4.2
Explain how radix sort works, to what inputs it can be applied and what is its asymptotic complexity?
Ask AI
Q.5 Solve this question :
Ask AI
Q5.1
What do you mean by optimal solution in greedy approach? Define the properties and function of greedy approach. Consider the given graph $ G=(V,E) $ and find the minimum spanning tree by Prim's algorithms.

Ask AI
Q.6 Solve this question :
Ask AI
Q6.1
Find the optimal way to multiply the following matrices to perform the fewest multiplications:
A1: $ 5 \times 11 $, A2: $ 11 \times 4 $, A3: $ 4 \times 15 $, A4: $ 15 \times 23 $Ask AI
Q.7 Solve this question :
Ask AI
Q7.1
You are given a graph containing n vertices and m edges and given that the graph doesn't contain cycle of odd length. What is the time complexity of the best known algorithm to find out whether the graph is bipartite or not?
Ask AI
Q.8 Solve this question :
Ask AI
Q8.1
What is activity selection problem? Suppose that instead of always selecting the first activity to finish, we select the last activity to start that is compatible with all previously selected activities. Describe how this approach is a greedy algorithm, and prove that it yields an optimal solution.
Ask AI
Q.9 Write short notes on the following:
Ask AI
2020051506
B.Tech 5th Semester Special Exam., 2020
Instructions
- The marks are indicated in the right-hand margin.
- There are EIGHT questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer of the following (any seven):
Ask AI
Q1.1
Find the complexity of the below program:
void function(int n) { int i=1, s=1; while(s<=n) { i++; s+=i; printf("*"); } }Ask AI
Q1.2
How many undirected graphs (not necessarily connected) can be constructed out of a given set $ V = \{V_1, V_2, \dots, V_n\} $ of n vertices?
Ask AI
Q1.3
The recurrence relation capturing the optimal time of the Tower of Hanoi problem with n discs is
Ask AI
Q1.4
Dijkstra's algorithm is based on
Ask AI
Q1.5
Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case complexity of sorting n numbers using randomized quicksort?
Ask AI
Q1.6
Name three sorting algorithms which are stable by nature.
Ask AI
Q1.7
What is the worst time complexity of insertion sort?
Ask AI
Q1.8
The most efficient algorithm for finding the number of connected components in an undirected graph of n vertices and m edges has the time complexity
Ask AI
Q1.9
Which of the following statement is not true about breadth-first search (BFS) in an undirected graph starting at a vertex v?
Ask AI
Q1.10
Finding the location of the element with a given value is
Ask AI
Q.2 Solve this question :
Ask AI
Q2.1
Write the asymptomatic notation used for best case, average case and worst case analysis of algorithm. Write an algorithm for finding maximum element in an array. Give best, worst and average case complexities.
Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
Explain the brute force method to find the two closet points in a set of n points in k-dimensional space.
Ask AI
Q3.2
Explain the working of merge sort algorithm with an example. Give the complexity calculation of merge sort.
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
Write an algorithm based on divide-and-conquer strategy to search an element in a given list. Assume that the elements of list are in sorted order.
Ask AI
Q4.2
What is the relationship among P, NP and NP-complete problems? Show with the help of a diagram.
Ask AI
Q.5 Solve this question :
Ask AI
Q5.1
Give the complete solution (step-by-step using state space tree) for N-Queen problem using back-tracking with pseudocode. Give the complexity analysis.
Ask AI
Q.6 Solve this question :
Ask AI
Q6.1
Construct the Huffman coding tree for the text of characters with given frequencies: T:43, I:38, V:16, K:8, L:56, E:12, O:41, Z:13, P:22, R:6. Also find the variable length Huffman codes and frequency path length for corresponding above characters.
Ask AI
Q.7 Solve this question :
Ask AI
Q7.1
Find the optimal way to multiply the following matrices to perform the fewest multiplications:
$ A_1: 5 \times 11 $, $ A_2: 11 \times 4 $, $ A_3: 4 \times 15 $, $ A_4: 15 \times 23 $Ask AI
Q.8 Write short notes on the following:
Ask AI
Q8.1
Ask AI
2020SPECIAL051506
B.Tech 5th Semester Special Exam., 2020
Instructions
- The marks are indicated in the right-hand margin.
- There are EIGHT questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer of the following (any seven):
Ask AI
Q1.1
Find the complexity of the below program:
void function(int n) { int i=1, s=1; while(s<=n) { i++; s+=i; printf("*"); } }Ask AI
Q1.2
How many undirected graphs (not necessarily connected) can be constructed out of a given set $ V = \\{V_1, V_2, \dots, V_n\\} $ of n vertices?
Ask AI
Q1.3
The recurrence relation capturing the optimal time of the Tower of Hanoi problem with n discs is
Ask AI
Q1.4
Dijkstra's algorithm is based on
Ask AI
Q1.5
Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case complexity of sorting n numbers using randomized quicksort?
Ask AI
Q1.6
Name three sorting algorithms which are stable by nature.
Ask AI
Q1.7
What is the worst time complexity of insertion sort?
Ask AI
Q1.8
The most efficient algorithm for finding the number of connected components in an undirected graph of n vertices and m edges has the time complexity
Ask AI
Q1.9
Which of the following statement is not true about breadth-first search (BFS) in an undirected graph starting at a vertex v?
Ask AI
Q1.10
Finding the location of the element with a given value is
Ask AI
Q.2 Solve this question :
Ask AI
Q2.1
Write the asymptomatic notation used for best case, average case and worst case analysis of algorithm. Write an algorithm for finding maximum element in an array. Give best, worst and average case complexities.
Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
Explain the brute force method to find the two closet points in a set of n points in k-dimensional space.
Ask AI
Q3.2
Explain the working of merge sort algorithm with an example. Give the complexity calculation of merge sort.
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
Write an algorithm based on divide-and-conquer strategy to search an element in a given list. Assume that the elements of list are in sorted order.
Ask AI
Q4.2
What is the relationship among P, NP and NP-complete problems? Show with the help of a diagram.
Ask AI
Q.5 Solve this question :
Ask AI
Q5.1
Give the complete solution (step-by-step using state space tree) for N-Queen problem using back-tracking with pseudocode. Give the complexity analysis.
Ask AI
Q.6 Solve this question :
Ask AI
Q6.1
Construct the Huffman coding tree for the text of characters with given frequencies: T:43, I:38, V:16, K:8, L:56, E:12, O:41, Z:13, P:22, R:6. Also find the variable length Huffman codes and frequency path length for corresponding above characters.
Ask AI
Q.7 Solve this question :
Ask AI
Q7.1
Find the optimal way to multiply the following matrices to perform the fewest multiplications:
$ A_1: 5 \times 11 $, $ A_2: 11 \times 4 $, $ A_3: 4 \times 15 $, $ A_4: 15 \times 23 $Ask AI
Q.8 Write short notes on the following:
Ask AI
2019051506
B.Tech 5th Semester Exam., 2019
Instructions
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer from any seven of the following:
Ask AI
Q1.1
In the following C++ function, let $ n \ge m $. What is the time complexity of the above function assuming $ n > m $?
int gcd(int n, int m) { if(n%m==0) return m; if(n < m) swap(n, m); while(m>0) { n=n%m; swap(n, m); } return n; }Ask AI
Q1.2
Time complexity of Kadane's Algorithm is
Ask AI
Q1.3
Consider an undirected random graph of eight vertices. The probability that there is an edge between a pair of vertices is 1/2. What is the expected number of unordered cycles of length three?
Ask AI
Q1.4
Any decision tree that sorts 'n' elements has height
Ask AI
Q1.5
An all-pairs shortest-paths problem is efficiently solved using
Ask AI
Q1.6
Which of the following is an advantage of adjacency list representation over adjacency matrix representation of a graph?
Ask AI
Q1.7
Which of the following is true about Huffman Coding?
Ask AI
Q1.8
Which one of the following is an application of Queue Data Structure?
Ask AI
Q1.9
In linear search algorithm the worst case occurs when
Ask AI
Q1.10
The complexity of binary search algorithm is
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
Discuss the steps in mathematical analysis for recursive algorithm. Do the same for finding the factorial of a number?
Ask AI
Q2.2
What are the rules of manipulate Big-Oh expression? Write about the typical growth rates of algorithms.
Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
What are the advantages of merge-sort over the quick-sort algorithm?
Ask AI
Q3.2
What is the time complexity of the matrix multiplication and Strassen's algorithm?
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
Prove that if $ f_1(n) = O(g_1(n)) $ and $ f_2(n) = O(g_2(n)) $, then $ f_1(n)+f_2(n) = O(g_1(n)+g_2(n)) $.
Ask AI
Q.5 Solve this question :
Ask AI
Q5.1
What is the relationship among P, NP and NP complete problems? Show with the help of a diagram.
Ask AI
Q5.2
Compare the various programming paradigms such as divide-and-conquer, dynamic programming and greedy approach.
Ask AI
Q.6 Solve this question :
Ask AI
Q6.1
Consider the array A = {26, 17, 41, 14, 21, 30, 47, 10, 16, 19, 21, 28, 38, 7, 12, 14, 20, 35, 39, 3}. Create binary search tree with one more attributes its size of node. Retrieve 17th smallest element in the tree and rank the 12th element.
Ask AI
Q.7 Solve this question :
Ask AI
Q7.1
What do you mean by optimal solution in greedy approach? Define the properties and function of greedy approach. Consider a graph $ G=(V,E) $ and find the minimum spanning tree by Prim's algorithms.

Ask AI
Q.8 Solve this question :
Ask AI
Q8.1
Explain back-tracking, DFS and BFS with help of small example. Differentiate in between backtracking and dynamic programming. Apply the backtracking algorithm to solve the three-colouring problem for the graph using state space tree. Assume three colours red, green and blue.

Ask AI
Q.9 Write short notes on:
Ask AI
Q9.1
Ask AI
2019V4051506
B.Tech 5th Semester Exam., 2019
Instructions
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer from any seven of the following:
Ask AI
Q1.1
In the following C++ function, let $ n \ge m $. What is the time complexity of the above function assuming $ n > m $?
int gcd(int n, int m) { if(n%m==0) return m; if(n < m) swap(n, m); while(m>0) { n=n%m; swap(n, m); } return n; }Ask AI
Q1.2
Time complexity of Kadane's Algorithm is
Ask AI
Q1.3
Consider an undirected random graph of eight vertices. The probability that there is an edge between a pair of vertices is 1/2. What is the expected number of unordered cycles of length three?
Ask AI
Q1.4
Any decision tree that sorts 'n' elements has height
Ask AI
Q1.5
An all-pairs shortest-paths problem is efficiently solved using
Ask AI
Q1.6
Which of the following is an advantage of adjacency list representation over adjacency matrix representation of a graph?
Ask AI
Q1.7
Which of the following is true about Huffman Coding?
Ask AI
Q1.8
Which one of the following is an application of Queue Data Structure?
Ask AI
Q1.9
In linear search algorithm the worst case occurs when
Ask AI
Q1.10
The complexity of binary search algorithm is
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
Discuss the steps in mathematical analysis for recursive algorithm. Do the same for finding the factorial of a number?
Ask AI
Q2.2
What are the rules of manipulate Big-Oh expression? Write about the typical growth rates of algorithms.
Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
What are the advantages of merge-sort over the quick-sort algorithm?
Ask AI
Q3.2
What is the time complexity of the matrix multiplication and Strassen's algorithm?
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
Prove that if $ f_1(n) = O(g_1(n)) $ and $ f_2(n) = O(g_2(n)) $, then $ f_1(n)+f_2(n) = O(g_1(n)+g_2(n)) $.
Ask AI
Q.5 Solve this question :
Ask AI
Q5.1
What is the relationship among P, NP and NP complete problems? Show with the help of a diagram.
Ask AI
Q5.2
Compare the various programming paradigms such as divide-and-conquer, dynamic programming and greedy approach.
Ask AI
Q.6 Solve this question :
Ask AI
Q6.1
Consider the array A = {26, 17, 41, 14, 21, 30, 47, 10, 16, 19, 21, 28, 38, 7, 12, 14, 20, 35, 39, 3}. Create binary search tree with one more attributes its size of node. Retrieve 17th smallest element in the tree and rank the 12th element.
Ask AI
Q.7 Solve this question :
Ask AI
Q7.1
What do you mean by optimal solution in greedy approach? Define the properties and function of greedy approach. Consider a graph $ G=(V,E) $ and find the minimum spanning tree by Prim's algorithms.

Ask AI
Q.8 Solve this question :
Ask AI
Q8.1
Explain back-tracking, DFS and BFS with help of small example. Differentiate in between backtracking and dynamic programming. Apply the backtracking algorithm to solve the three-colouring problem for the graph using state space tree. Assume three colours red, green and blue.

Ask AI
Q.9 Write short notes on:
Ask AI
2018051506
B.Tech 5th Semester Exam., 2018
Instructions
- All questions carry equal marks.
- There are NINE questions in this paper.
- Attempt any FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer (any seven):
Ask AI
Q1.1
Which algorithm is better for sorting between bubble sort and quicksort?
Ask AI
Q1.2
An algorithm which uses the past results and uses them to find the new results is
Ask AI
Q1.3
Out of the following which property of algorithm does not share?
Ask AI
Q1.4
Which of the following standard algorithms is not a greedy algorithm?
Ask AI
Q1.5
What is the time complexity of Huffman coding?
Ask AI
Q1.6
How many comparisons are required to sort the list 1, 2, 3... n using insertion sort?
Ask AI
Q1.7
Which of the following is true about Huffman coding?
Ask AI
Q1.8
A complexity of algorithm depends upon
Ask AI
Q1.9
A text is made up of the characters a, b, c, d, e each occurring with the probability 0.11, 0.40, 0.16, 0.09 and 0.24 respectively. The optimal Huffman coding technique will have the average length of
Ask AI
Q1.10
Build heap is used in heap sort as a first step for sorting. What is the time complexity of build heap operation?
Ask AI
Q.2 Solve this question :
Ask AI
Q2.1
Solve the following recurrence by successive substitution method:
$ f(1) = 1 $, if $ n=1 $
$ f(n) = 3f(n/2) + 6 $, if $ n>1 $Ask AI
Q.3 Solve this question :
Ask AI
Q3.1
COUNTING SORT algorithm assumes that each of the n input elements is an integer in the range 0 to k, for some integer k. When $ k=O(n) $, the sort runs in $ \Theta(n) $ time. Change COUNTING SORT algorithm for the numbers lying in the range p to q where $ (q-p) $ is still $ O(n) $. Also analyze the new complexity.
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
Consider a directed acyclic graph with non-negative edge costs and with a given start vertex s. Write an algorithm to compute distances from source s in $ O(E+V) $ time. Justify why your algorithm is correct.
Ask AI
Q4.2
Explain, with an example, why Dijkstra's algorithm might take $ \Omega(V \log V) $ time.
Ask AI
Q.5 Solve this question :
Ask AI
Q5.1
Consider the two standard representations of directed graphs: the adjacency-list representation and the adjacency-matrix representation. Find a problem that can be solved more efficiently in the adjacency-list representation than in the adjacency-matrix representation, and another problem that can be solved more efficiently in the adjacency-matrix representation than in the adjacency-list representation.
Ask AI
Q.6 Solve both questions :
Ask AI
Q6.1
Differentiate between the following: Fractional Knapsack vs. 0/1 Knapsack.
Ask AI
Q6.2
Differentiate between the following: Kruskal's vs. Prim's Algorithm.
Ask AI
Q.7 Solve this question :
Ask AI
Q7.1
What are NP-complete problems? Write some problems which are P, NP and NP-hard. Explain any NP-hard problem in detail.
Ask AI
Q.8 Solve this question :
Ask AI
Q8.1
Explain quicksort and its asymptotic complexities. Take some distinct numbers and perform quicksort over it.
Ask AI
Q.9 Solve both questions :
Ask AI
Q9.1
Explain travelling salesman problem using Greedy method.
Ask AI
Q9.2
Explain travelling salesman problem using Dynamic programming method.
Ask AI
2018V4051506
B.Tech 5th Semester Exam., 2018
Instructions
- All questions carry equal marks.
- There are NINE questions in this paper.
- Attempt any FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer (any seven):
Ask AI
Q1.1
Which algorithm is better for sorting between bubble sort and quicksort?
Ask AI
Q1.2
An algorithm which uses the past results and uses them to find the new results is
Ask AI
Q1.3
Out of the following which property of algorithm does not share?
Ask AI
Q1.4
Which of the following standard algorithms is not a greedy algorithm?
Ask AI
Q1.5
What is the time complexity of Huffman coding?
Ask AI
Q1.6
How many comparisons are required to sort the list 1, 2, 3... n using insertion sort?
Ask AI
Q1.7
Which of the following is true about Huffman coding?
Ask AI
Q1.8
A complexity of algorithm depends upon
Ask AI
Q1.9
A text is made up of the characters a, b, c, d, e each occurring with the probability 0.11, 0.40, 0.16, 0.09 and 0.24 respectively. The optimal Huffman coding technique will have the average length of
Ask AI
Q1.10
Build heap is used in heap sort as a first step for sorting. What is the time complexity of build heap operation?
Ask AI
Q.2 Solve this question :
Ask AI
Q2.1
Solve the following recurrence by successive substitution method:
$ f(1) = 1 $, if $ n=1 $
$ f(n) = 3f(n/2) + 6 $, if $ n>1 $Ask AI
Q.3 Solve this question :
Ask AI
Q3.1
COUNTING SORT algorithm assumes that each of the n input elements is an integer in the range 0 to k, for some integer k. When $ k=O(n) $, the sort runs in $ \Theta(n) $ time. Change COUNTING SORT algorithm for the numbers lying in the range p to q where $ (q-p) $ is still $ O(n) $. Also analyze the new complexity.
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
Consider a directed acyclic graph with non-negative edge costs and with a given start vertex s. Write an algorithm to compute distances from source s in $ O(E+V) $ time. Justify why your algorithm is correct.
Ask AI
Q4.2
Explain, with an example, why Dijkstra's algorithm might take $ \Omega(V \log V) $ time.
Ask AI
Q.5 Solve this question :
Ask AI
Q5.1
Consider the two standard representations of directed graphs: the adjacency-list representation and the adjacency-matrix representation. Find a problem that can be solved more efficiently in the adjacency-list representation than in the adjacency-matrix representation, and another problem that can be solved more efficiently in the adjacency-matrix representation than in the adjacency-list representation.
Ask AI
Q.6 Solve both questions :
Ask AI
Q6.1
Differentiate between the following: Fractional Knapsack vs. 0/1 Knapsack.
Ask AI
Q6.2
Differentiate between the following: Kruskal's vs. Prim's Algorithm.
Ask AI
Q.7 Solve this question :
Ask AI
Q7.1
What are NP-complete problems? Write some problems which are P, NP and NP-hard. Explain any NP-hard problem in detail.
Ask AI
Q.8 Solve this question :
Ask AI
Q8.1
Explain quicksort and its asymptotic complexities. Take some distinct numbers and perform quicksort over it.
Ask AI
Q.9 Solve both questions :
Ask AI
Q9.1
Explain travelling salesman problem using Greedy method.
Ask AI
Q9.2
Explain travelling salesman problem using Dynamic programming method.
Ask AI