0% found this document useful (0 votes)
42 views9 pages

ADA1

Uploaded by

manojnasee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views9 pages

ADA1

Uploaded by

manojnasee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

ADA- Medium level questions

1. Dijkstra’s algorithm is used to solve ______ problems


a. Network lock
b. Single source shortest path
c. All pair shortest path
d. Sorting
2. The Bellmann Ford Algorithm returns ______ value
a. String
b. Boolean
c. Double
d. Integer
3. Which of the following is used for solving the N Queens Problem?
a. Greedy Algorithm
b. Dynamic Programming
c. Backtracking
d. Sorting
4. Which of the following is true for AVL trees?
a. The difference between the heights of left and right nodes cannot be more than 1.
b. The height of an AVL tree always remains of the order of O(logn)
c. AVL trees are a type
d. All the above
5. Representation of data structure in memory is known as?
a. Storage structure
b. File structure
c. Recursive
d. Abstract Data type
6. In what time complexity can we find the diameter of a binary tree optimally?
a. O(V+E)
b. O(V)
c. O(E)
d. O(V*logE)
7. To main measures of the efficiency of an algorithm are?
a. Time and space complexity
b. Data and space
c. Processor and memory
d. Complexity and capacity
8. Which of the following sorting algorithms provide the best time complexity in the worst-case
scenario?
a. Merge Sort
b. Quick Sort
c. Bubble Sort
d. Selection Sort
9. Which of the following is a Divide and Conquer algorithm?
a. Bubble Sort
b. Selection Sort
c. Heap Sort
d. Merge Sort
10. Which of the following data structure is used to perform recursion?
a. Linked list
b. Array
c. Queue
d. Stack
11. Identify the best case time complexity of selection sort?
a. O(nlogn)
b. O(n^2)
c. O(n)
d. O(1)
12. Another name of the fractional knapsack is
a. Non-continuous knapsack problem
b. Divisible knapsack problem
c. 0/1 knapsack problem
d. Continuous knapsack problem
13. Identify the approach followed in Floyd Warshall’s algorithm
a. Linear programming
b. Dynamic programming
c. Greedy technique
d. Backtracking
14. Hamiltonian oath problem is ______
a. NP problem
b. P class problem
c. NP-complete problem
d. N class problem
15. 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;
}

a. O(n)
b. O(n^2)
c. O(1)
d. O(log n)
16. What is the time complexity of the binary search algorithm?
a. O(n)
b. O(1)
c. O(log2n)
d. O(n^2)
17. What will be the best sorting algorithm, given that the array elements are small(<=1e6)?
a. Bubble sort
b. Merge sort
c. Counting sort
d. Heap sort
18. What is the time complexity of the Sieve of Eratosthenes to check if a number is prime?
a. O(nlog(logn)) Precomputation, O(1) for check
b. O(n) Precomputation, O(1) for check
c. O(n*logn) Precomputation, O(logn) for check
d. O(n) Precomputation, O(logn) for check
19. The worst-case time complexity of Quicksort is
a. O(n)
b. O(1)
c. O(log2n)
d. O(n^2)
20. What is the technique called in which it does not require extra memory for carrying out the
sorting procedure?
a. Stable
b. Unstable
c. In-place
d. In-partition
21. Identify the slowest sorting technique among the following
a. Merge sort
b. Quick sort
c. Bubble sort
d. Selection sort
22. Select the correct recurrence relation of Tower of Hanoi
a. T(N)=2T(N-1)+1
b. T(N)=2T(N/2)+1
c. T(N)=2T(N-1)+N
d. T(N)=2T(N-2)+2
23. Identify the sorting technique which compare adjacent elements in a list and switches
whenever necessary
a. Merge sort
b. Quick sort
c. Bubble sort
d. Selection sort
24. Which of the following algorithms are used to find the shortest path from a source node to all
other nodes in a weighted graph?
a. BFS
b. Dijkstra’s Algorithm
c. Prims Algorithm
d. Kruskal’s Algorithm
25. Which of the following are applications of Topological Sort of a graph?
a. Sentence Ordering
b. Course Scheduling
c. OS Deadlock Detection
d. All of the above
26. What is the time complexity in decreasing the node value in a binomial heap?
a. O(1)
b. O(N)
c. O(logN)
d. O(NlogN)
27. What should be considered when designing an algorithm?
a. If this software is used correctly
b. If the hardware is used correctly
c. If there is more than one way to solve the problem
d. All of the above are correct
28. Which of the following is known to be not an NP-Hard Problem?
a. Vertex cover problem
b. o/1 Knapsack problem
c. Maximal independent set problem
d. Travelling salesman problem
29. What is the difference between

class Codechef {
public static void main(String[] args) {
System.out.println(12);
System.out.println(11);
}
}

and

class Codechef {
public static void main(String[] args) {
System.out.println(12);

System.out.println(11);
}
}
Select one of the following options.
a. The first code will have outputs on the same line, and the second code will output
inseparate lines.
b. The two codes are equivalent.
c. The second code is wrong, and will not compile.
Ans: b
30. Depth First Search is equivalent to which of the traversal in the Binary
Trees?

a. Pre-order Traversal
b. Post-order Traversal
c. Level-order Traversal
d. In-order Traversal
Ans: a

31. Consider the following C program


int main()
{
int x, y, m, n;
scanf ("%d %d", &x, &y);
/* x > 0 and y > 0 */
m = x; n = y;
while (m != n)
{
if(m>n)
m = m - n;
else
n = n - m;
}
printf("%d", n);
}
What does the program compute? (GATE CS 2004)
a. x + y using repeated subtraction
b. x mod y using repeated subtraction
c. the greatest common divisor of x and y
d. the least common multiple of x and y

Ans: c

32. Which of the following is not a backtracking algorithm?


a. Knight tour problem
b. N queen problem
c. Tower of hanoi
d. M coloring problem

Ans: c

33. Suppose T(n) = 2T(n/2) + n, T(0) = T(1) = 1 Which one of the following is false.
a. T(n) = O(n^2)
b. T(n) = \theta(nLogn)
c. T(n) = \Omega(n^2)
d. T(n) = O(nLogn)

Ans: c

34. In a complete k-ary tree, every internal node has exactly k children. The number of leaves in
such a tree with n internal nodes is:

a. nk
b. (n – 1) k+ 1
c. n( k – 1) + 1
d. n( k – 1)

Ans: c

35. The following statement is valid. log(n!) = \theta (n log n).


a. True
b. False

Ans: a

36. What is the time complexity of Floyd–Warshall algorithm to calculate all pair shortest path in
a graph with n vertices?
a. O(n2log(n))
b. Theta(n2log(n))
c. Theta(n4)
d. Theta(n3)

Ans: d

37. Assuming P != NP, which of the following is true ?


a. NP-complete = NP
b. NP-complete \cap P = \Phi
c. NP-hard = NP
d. P = NP-complete

Ans: b
38. ______ solution requires reasoning built on knowledge and experience
a. Algorithmic Solution
b. Heuristic Solution
c. Random Solution
d. None of these

Ans: b
39. Artificial Intelligence makes use of following prominently
a. Database
b. Data Warehouse
c. Knowledge base
d. None of these

Answer: c

40. Naming convention for variable is followed in company because ____________.


a. it enhances readability
b. it allows to work without conflicts
c. it enhances the efficiency
d. all of the above

Ans: d

41. The true and false values represent __________.


a. logical data
b. numeric data
c. character data
d. alphanumeric data

Ans: a

42. Evaluate 5*(x+y)-4*y/(z+6) where x = 2, y = 3, and z = 6


a. 1
b. 24
c. 5
d. 10

Ans: b1

43. Evaluate a-2>b where a=6, b = 8


a. False
b. True
c. 6
d. 7

Ans:a

44. Evaluate for a = 5, b = 4, c = 3, d = 12 for the equation E =a*b+d/c


a. 40
b. 24
c. 10
d. 10.66

Ans:b
45. Evaluate for the equation e = 5*a\d*(b+1) where a = 5, b = 4,c = 3, d = 12
a. 10
b. 24
c. 0
d. 10

Ans: c

46. There are four algorithms A1, A2, A3, A4 to solve the given problem with the order log(n),
nlog(n), log(log(n))n/log(n),Which is the best algorithm.
a. A1
b. A2
c. A3
d. A4

Ans: c

47. Express the formula (n-1)*(n-5) in terms of big Oh notation


a. O(1)
b. O(log n)
c. O(n)
d. O(n2)

Ans: d

48. The three factors contributing to the sort efficiency considerations are the efficiency in
coding, machine run time and the space requirement for running the procedure.
a. True
b. False

Ans: a

49. How many passes are required to sort a file of size n by bubble sort method?
a. N2
b. N
c. N-1
d. N/2

Ans: c

50. How many number of comparisons are required in insertion sort to sort a file if the file is
sorted in reverse order?

a. N2
b. N
c. N-1
d. N/2
Ans: a

You might also like