Question:
What will be the auxiliary space complexity of the following code?
#include <bits/stdc++.h>
using namespace std;
void convert(int arr[], int n)
{
	int temp[n];
	memcpy(temp, arr, n*sizeof(int));
	sort(temp, temp + n);
        unordered_map<int, int> map;
	int sort_index = 0;
	for (int i = 0; i < n; i++)
		map[temp[i]] = sort_index++;
	for (int i = 0; i < n; i++)
		arr[i] = map[arr[i]];
}
void printArr(int arr[], int n)
{
	for (int i=0; i<n; i++)
		cout << arr[i] << " ";
}
int main()
{
	int arr[] = {10, 20, 15, 12, 11, 50};
	int n = sizeof(arr)/sizeof(arr[0]);
	convert(arr , n);
	printArr(arr, n);
	return 0;
}

Choices:
- O(n)
- O(1)
- O(log n)
- O(n log n)


Question: What are the methods to handle  collision:

Choices:
- Separate Chaining
- Open Chaining
- Both of the above
- None of the above


Question:
What is the time complexity of fun()?

int fun(int n)
{
    int count = 0;
    for (int i = 0; i < n; i++)
        for (int j = i; j > 0; j--)
            count = count + 1;
    return count;
}

``````C

Choices:
- Theta (n)
- Theta (n2)
- Theta (n*log(n))
- Theta (n*(log(n*log(n))))


Question: What are the applications of linear probing include:

Choices:
- Databases
- Caching
- Compiler Design
- All of the above


Question: Which is a simple form of hashing where the data is directly mapped to an index in a hash table.

Choices:
- Collision
- Index Mapping
- Functional Mapping
- Hash function


Question: Which of the following are components of Hashing?

Choices:
- Key
- Hash Function
- Hash Table
- All of the above


Question:
What is time complexity of fun()?

int fun(int n)
{
    int count = 0;
    for (int i = n; i > 0; i /= 2)
        for (int j = 0; j < i; j++)
            count += 1;
    return count;
}

``````C

Choices:
- O(n2)
- O(n*log(n))
- O(n)
- O(n*log(n*Log(n)))


Question:
Output of given program is,

def findSymPairs(arr, row):
    hM = dict()
    for i in range(row):
        first = arr[i][0]
        sec = arr[i][1]
        if (sec in hM.keys() and hM[sec] == first):
            print("(", sec,",", first, ")")
        else:
            hM[first] = sec

if __name__ == '__main__':
    arr = [[0 for i in range(2)]
      for i in range(5)]
    arr[0][0], arr[0][1] = 11, 20
    arr[1][0], arr[1][1] = 30, 40
    arr[2][0], arr[2][1] = 5, 10
    arr[3][0], arr[3][1] = 40, 30
    arr[4][0], arr[4][1] = 10, 5
    findSymPairs(arr, 5)

``````Python3

Choices:
- (30, 40)(5, 10)
- (30, 40)(5, 5)
- (30, 4)(5, 1)
- (3, 4)(5, 1)


Question: Six files F1, F2, F3, F4, F5 and F6 have 100, 200, 50, 80, 120, 150 records respectively. In what order should they be stored so as to optimize act. Assume each file is accessed with the same frequency

Choices:
- F3, F4, F1, F5, F6, F2
- F2, F6, F5, F1, F4, F3
- F1, F2, F3, F4, F5, F6
- Ordering is immaterial as all files are accessed with the same frequency.


Question: 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:

Choices:
- 2.40
- 2.16
- 2.26
- 2.15


Question:
What is the output of the below code: for n=5 and arr[] = {3, 10, 2, 1, 20};

int function(int arr[], int n)
{
    int lis[n];
    lis[0] = 1;
    for (int i = 1; i < n; i++) {
        lis[i] = 1;
        for (int j = 0; j < i; j++)
            if (arr[i] > arr[j] && lis[i] < lis[j] + 1)
                lis[i] = lis[j] + 1;
    }
    return *max_element(lis, lis + n);
}

``````C++

Choices:
- 2
- 10
- 1
- 3


Question: What is memoization in the context of dynamic programming?

Choices:
- A technique to write memory-efficient programs.
- A way to avoid solving subproblems by storing their solutions and reusing them.
- A process of converting recursive algorithms into iterative ones.
- A method of analyzing the time complexity of algorithms.


Question: The recurrence relation capturing the optimal time of the Tower of Hanoi problem with n discs is. (GATE CS 2012)

Choices:
- T(n) = 2T(n – 2) + 2
- T(n) = 2T(n – 1) + n
- T(n) = 2T(n/2) + 1
- T(n) = 2T(n – 1) + 1


Question: Suppose we are given n keys, m hash table slots, and two simple uniform hash functions h1 and h2. Further, suppose our hashing scheme uses h1 for the odd keys and h2 for the even keys. What is the expected number of keys in a slot?

Choices:
- [Tex]\frac{n}{2m}[/Tex]
- [Tex]\frac{n}{m}[/Tex]
- [Tex]\frac{m}{n}[/Tex]
- [Tex]\frac{2n}{m}[/Tex]


Question: A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and linear probing. After inserting 6 values into an empty hash table, the table is as shown below.  Which one of the following choices gives a possible order in which the key values could have been inserted in the table?

Choices:
- 46, 42, 34, 52, 23, 33
- 34, 42, 23, 52, 33, 46
- 46, 34, 42, 23, 52, 33
- 42, 46, 33, 23, 34, 52


Question:
The number of permutations of the characters in LILAC so that no character appears in its original position, if the two L’s are indistinguishable, is ________ .

Note - This question was Numerical Type.

Choices:
- 12
- 10
- 8
- 15


Question: O( n2 ) is the worst case time complexity, so among the given options it can represent :-

Choices:
- O( n )
- O( 1 )
- O ( nlogn )
- All of the above


Question: The minimum number of arithmetic operations required to evaluate the polynomial P(X) = X5 + 4X3 + 6X + 5 for a given value of X using only one temporary variable.

Choices:
- 6
- 7
- 8
- 9


Question:
What is the time complexity of the below function?

void fun(int n, int arr[])
{
    int i = 0, j = 0;
    for (; i < n; ++i)
        while (j < n && arr[i] < arr[j])
            j++;
}

``````C

Choices:
- O(n)
- O(n2)
- O(n*log(n))
- O(n*log(n)2)


Question: Suppose we have an O(n) time algorithm that finds the median of an unsorted array. Now consider a QuickSort implementation where we first find the median using the above algorithm, then use the median as a pivot. What will be the worst-case time complexity of this modified QuickSort?

Choices:
- O(n^2 Logn)
- O(n^2)
- O(n Logn Logn)
- O(nLogn)


Question: The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty hash table of length 10 using open addressing with hash function h(k) = k mod 10 and linear probing. What is the resultant hash table?

Choices:
- A
- B
- C
- D


Question: Which of the following is not a stable sorting algorithm in its typical implementation.

Choices:
- Insertion Sort
- Merge Sort
- Quick Sort
- Bubble Sort


Question: What is recurrence for worst case of QuickSort and what is the time complexity in Worst case?

Choices:
- Recurrence is T(n) = T(n-2) + O(n) and time complexity is O(n^2)
- Recurrence is T(n) = T(n-1) + O(n) and time complexity is O(n^2)
- Recurrence is T(n) = 2T(n/2) + O(n) and time complexity is O(nLogn)
- Recurrence is T(n) = T(n/10) + T(9n/10) + O(n) and time complexity is O(nLogn)


Question: 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:

Choices:
- nk
- (n – 1) k+ 1
- n( k – 1) + 1
- n( k – 1)


Question: The minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted array of n integers is

Choices:
- θ(n)
- θ(logn)
- θ(nlogn)
- θ(1)


Question:
In the following C function, let n >= m.

int gcd(n, m)
{
    if (n % m == 0)
        return m;
    n = n % m;
    return gcd(m, n);
}

``````C

How many recursive calls are made by this function?(A) [Tex]\\theta  [/Tex](log(n))(B) [Tex]\\Omega  [/Tex](n)(C) [Tex]\\theta  [/Tex](log(log(n)))(D) [Tex]\\theta  [/Tex](sqrt(n))

Choices:
- A
- B
- C
- D


Question:
Which of the given options provides the increasing order of asymptotic complexity of functions f1, f2, f3, and f4?  f1(n) = 2n
  f2(n) = n(3/2)
  f3(n) = n*log(n)
  f4(n) = nlog(n)

Choices:
- f3, f2, f4, f1
- f3, f2, f1, f4
- f2, f3, f1, f4
- f2, f3, f4, f1


Question:
Consider the following functions:  f(n)   = 2n
  g(n)   = n!
  h(n)   = nlog(n)
Which of the following statements about the asymptotic behavior of f(n), g(n), and h(n) is true?(A) f(n) = O(g(n)); g(n) = O(h(n))(B) f(n) = [Tex]\\Omega  [/Tex](g(n)); g(n) = O(h(n))(C) g(n) = O(f(n)); h(n) = O(f(n))(D) h(n) = O(f(n)); g(n) = [Tex]\\Omega  [/Tex](f(n))

Choices:
- A
- B
- C
- D


Question:
In a competition, four different functions are observed. All the functions use a single for loop and within the for loop, same set of statements are executed. Consider the following for loops:

A) for(i = 0; i < n; i++)

B) for(i = 0; i < n; i += 2)

C) for(i = 1; i < n; i *= 2)

D) for(i = n; i <= n; i /= 2)

``````C

If n is the size of input(positive), which function is most efficient(if the task to be performed is not an issue)?

Choices:
- A
- B
- C
- D


Question: The cube root of a natural number n is defined as the largest natural number m such that m3 ≤ n. The complexity of computing the cube root of n (n is represented in binary notation) is:

Choices:
- O(n) but not O(n0.5)
- O(n0.5) but not O((log n)k) for any constant k > 0
- O((log n)k) for some constant k > 0, but not O ((log log n)m) for any constant m > 0
- O((log log n)m) for some constant k > 0.5, but not O((log log n)0.5)


Question: Given an array that represents elements of arithmetic progression in order. It is also given that one element is missing in the progression, the worst case time complexity to find the missing element efficiently is:

Choices:
- Θ(n)
- Θ(nLogn)
- Θ(Logn)
- Θ(1)


Question:
Consider the following pseudo code, where x and y are positive integers.
begin
   q := 0
   r := x
while r >= y do
   begin
      r := r – y
      q := q + 1
   end
end

The post condition that needs to be satisfied after the program terminates is

Choices:
- {r = qx + y ∧ r < y}
- {x = qy + r ∧ r < y}
- {y = qx +  r ∧ 0 < r < y}
- { q + 1 < r–y ∧ y > 0}


Question:
The following function computes XY for positive integers X and Y.

int exp(int X, int Y)
{
    int res = 1, a = X, b = Y;
    while ( b != 0 )
    {
        if ( b%2 == 0)
        {
            a = a*a;
            b = b/2;
        }
        else
        {
            res = res*a;
            b = b-1;
        }
    }
    return res;
}

``````C

Which one of the following conditions is TRUE before every iteration of the loop

Choices:
- A
- B
- C
- D


Question:
Consider the following table

       Algorithms                   Design Paradigms
(P) Dijkastra’s Algorithm              (i) Divide and Conquer
(Q) Strassen’s Matrix Multiplication   (ii) Greedy
(R) Fibonacci numbers                  (iii) Dynamic Programming

Match the algorithm to design paradigms they are based on:

Choices:
- P-(ii), Q-(iii), R-(i)
- P-(iii), Q-(i), R-(ii)
- P-(ii), Q-(i), R-(iii)
- P-(i), Q-(ii), R-(iii)


Question: The infix expression A + (B - C)* D is correctly represented in prefix notation as

Choices:
- A + B − C ∗ D
- + A ∗ − B C D
- A B C − D ∗ +
- A + B C − D ∗


Question: What does it mean when we say that an algorithm X is asymptotically more efficient than Y?

Choices:
- X will be a better choice for all inputs
- X will be a better choice for all inputs except possibly small inputs
- X will be a better choice for all inputs except possibly large inputs
- Y will be a better choice for small inputs


Question: Consider a hash table of size seven, with starting index zero, and a hash function (7x+3) mod 4. Assuming the hash table is initially empty, which of the following is the contents of the table when the sequence 1, 3, 8, 10 is inserted into the table using closed hashing ? Here “__” denotes an empty location in the table.

Choices:
- 3, 10, 1, 8, __ , __ , __
- 1, 3, 8, 10, __ , __ , __
- 1, __ , 3, __ , 8, __ , 10
- 3, 10, __ , __ , 8, __ , __


Question: The height of a tree is the length of the longest root-to-leaf path in it. The maximum and minimum number of nodes in a binary tree of height 5 are

Choices:
- 63 and 6, respectively
- 64 and 5, respectively
- 32 and 6, respectively
- 31 and 5, respectively


Question: Consider the undirected graph below:  Using Prim's algorithm to construct a minimum spanning tree starting with node A, which one of the following sequences of edges represents a possible order in which the edges would be added to construct the minimum spanning tree?

Choices:
- (E, G), (C, F), (F, G), (A, D), (A, B), (A, C)
- (A, D), (A, B), (A, C), (C, F), (G, E), (F, G)
- (A, B), (A, D), (D, F), (F, G), (G, E), (F, C)
- (A, D), (A, B), (D, F), (F, C), (F, G), (G, E)


Question:
The secant method is used to find the root of an equation f(x) = 0. It is started from two distinct estimates xa and xb for the root. It is an iterative procedure involving linear interpolation to a root. The iteration stops if f(xb) is very small and then xb is the solution. The procedure is given below. Observe that there is an expression which is missing and is marked by? Which is the suitable expression that is to be put in place of? So that it follows all steps of the secant method?

Secant Initialize: xa, xb, ε, N     // ε = convergence indicator
fb = f(xb) i = 0
while (i < N and |fb| > ε) do
   i = i + 1                 // update counter
   xt = ?                    // missing expression for
                             // intermediate value
   xa = xb                   // reset xa
   xb = xt                   // reset xb
   fb = f(xb)                // function value at new xb
end while
if |fb| > ε
  then // loop is terminated with i = N
  write “Non-convergence”
else
  write “return xb”
end if

Choices:
- xb – (fb– f(xa)) fb/ (xb – xa)
- xa– (fa– f(xa)) fa/ (xb – xa)
- xb – (fb – xa) fb/ (xb – fb(xa)
- xa – (xb – xa) fa/ (fb – f(xa))


Question:
Consider the problem of searching an element x in an array \'arr[]\' of size n.  The problem can be solved in O(Logn) time if.
1) Array is sorted
2) Array is sorted and rotated by k.  k is given to you and k  <= n
3) Array is sorted and rotated by k.  k is NOT given to you and k  <= n
4) Array is not sorted

Choices:
- 1 Only
- 1 & 2 only
- 1, 2 and 3 only
- 1, 2, 3 and 4


Question: Consider a situation where you don\'t have function to calculate power (pow() function in C) and you need to calculate x^n where x can be any number and n is a positive integer.  What can be the best possible time complexity of your power function?

Choices:
- O(n)
- O(nLogn)
- O(LogLogn)
- O(Logn)


Question: Consider the polynomial p(x) = a0 + a1x + a2x^2 +a3x^3, where ai != 0, for all i. The minimum number of multiplications needed to evaluate p on an input x is:

Choices:
- 3
- 4
- 6
- 9


Question: Which of the following algorithms is NOT a divide & conquer algorithm by nature?

Choices:
- Euclidean algorithm to compute the greatest common divisor
- Heap Sort
- Cooley-Tukey fast Fourier transform
- Quick Sort


Question: An array of integers of size n can be converted into a heap by adjusting the heaps rooted at each internal node of the complete binary tree starting at the node ⌊(n - 1) /2⌋, and doing this adjustment up to the root node (root node is at index 0) in the order ⌊(n - 1)/2⌋, ⌊(n - 3)/ 2⌋, ....., 0. The time required to construct a heap in this manner is

Choices:
- O(log n)
- O(n)
- O (n log log n)
- O(n log n)


Question: A binary tree T has 20 leaves. The number of nodes in T having two children is

Choices:
- 18
- 19
- 17
- Any number between 10 and 20


Question: The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height h is:

Choices:
- 2h−1
- 2h−1 -1
- 2h+1-1
- 2h+1


Question: In a binary tree with n nodes, every node has an odd number of descendants. Every node is considered to be its own descendant. What is the number of nodes in the tree that have exactly one child?

Choices:
- 0
- 1
- (n-1)/2
- n-1


Question: Consider a node X in a Binary Tree.  Given that X has two children, let Y be Inorder successor of X. Which of the following is true about Y?

Choices:
- Y has no right child
- Y has no left child
- Y has both children
- None of the above


Question: Consider the following nested representation of binary trees: (X Y Z) indicates Y and Z are the left and right sub stress, respectively, of node X. Note that Y and Z may be NULL, or further nested. Which of the following represents a valid binary tree?

Choices:
- (1 2 (4 5 6 7))
- (1 (2 3 4) 5 6) 7)
- (1 (2 3 4)(5 6 7))
- (1 (2 3 NULL) (4 5))


Question:
Postorder traversal of a given binary search tree, T produces the following sequence of keys
        10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29
Which one of the following sequences of keys can be the result of an in-order traversal of the tree T? (GATE CS 2005)

Choices:
- 9, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95
- 9, 10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29
- 29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95
- 95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29


Question: What is the worst case possible height of AVL tree?

Choices:
- 2Logn (Assume base of log is 2)
- 1.44log n (Assume base of log is 2)
- Depends upon implementation
- Theta(n)


Question: Which of the following sorting algorithms in its typical implementation gives best performance when applied on an array which is sorted or almost sorted (maximum 1 or two elements are misplaced).

Choices:
- Quick Sort
- Heap Sort
- Merge Sort
- Insertion Sort


Question: A scheme for storing binary trees in an array X is as follows. Indexing of X starts at 1 instead of 0. the root is stored at X[1]. For a node stored at X[i], the left child, if any, is stored in X[2i] and the right child, if any, in X[2i+1]. To be able to store any binary tree on n vertices the minimum size of X should be. (GATE CS 2006)

Choices:
- log2n
- n
- 2n + 1
- 2^n — 1


Question: Consider the problem of computing min-max in an unsorted array where min and max are minimum and maximum elements of array. Algorithm A1 can compute min-max in a1 comparisons without divide and conquer. Algorithm A2 can compute min-max in a2 comparisons by scanning the array linearly. What could be the relation between a1 and a2 considering the worst case scenarios?

Choices:
- a1 < a2
- a1 > a2
- a1 = a2
- Depends on the input


Question:
Consider the following array.

Which algorithm out of the following options uses the least number of comparisons (among the array elements) to sort the above array in ascending order?

Choices:
- Selection sort
- Mergesort
- Insertion sort
- Quicksort using the last element as pivot


Question: A binary search tree T contains n distinct elements. What is the time complexity of picking an element in T that is smaller than the maximum element in T?

Choices:
- Θ(nlogn)
- Θ(n)
- Θ(logn)
- Θ(1)


Question: In a binary tree, for every node the difference between the number of nodes in the left and right subtrees is at most 2. If the height of the tree is h > 0, then the minimum number of nodes in the tree is:

Choices:
- 2h - 1
- 2h - 1 + 1
- 2h - 1
- 2h


Question: What is the other name of Dijkstra algorithm?

Choices:
- single-source shortest path problem
- multiple-source shortest path problem
- multiple-destination shortest path problem
- single-destination shortest path problem


Question: Which of the following is true about Huffman Coding?

Choices:
- Huffman coding may become lossy in some cases
- Huffman Codes may not be optimal lossless codes in some cases
- In Huffman coding, no code is prefix of any other code.
- All of the above


Question: Which of the following is true about Kruskal and Prim MST algorithms? Assume that Prim is implemented for adjacency list representation using Binary Heap and Kruskal is implemented using union by rank.

Choices:
- Worst case time complexity of both algorithms is same.
- Worst case time complexity of Kruskal is better than Prim
- Worst case time complexity of Prim is better than Kruskal
- None of these


Question: In question #2, which of the following represents the word "dead"?

Choices:
- 1011111100101
- 0100000011010
- Both A and B
- None of these


Question: What is the time complexity of Huffman Coding?

Choices:
- O(N)
- O(NlogN)
- O(N(logN)^2)
- O(N^2)


Question:
A networking company uses a compression technique to encode the message before transmitting over the network. Suppose the message contains the following characters with their frequency:

character   Frequency
    a	          5
    b             9
    c             12
    d             13
    e             16
    f             45

``````C

Note : Each character in input message takes 1 byte. If the compression technique used is Huffman Coding, how many bits will be saved in the message?

Choices:
- 224
- 800
- 576
- 324


Question: What are the different techniques to solve dynamic programming problems:

Choices:
- Memoization
- Bottom-Up
- Both
- None


Question: Given a hash table T with 25 slots that stores 2000 elements, the load factor α for T is __________

Choices:
- 80
- 0.0125
- 8000
- 1.25


Question: With the help of which dynamic programming problem the Edit Distance algorithm can be solved?

Choices:
- Longest Common Subsequence (LCS)
- Longest Increasing Subsequence (LIS)
- Longest Palindromic Subsequence (LPS)
- String Alignment Problem


Question: The Fibonacci sequence is often used to illustrate dynamic programming concepts. What is the time complexity of a naive recursive implementation of Fibonacci numbers?

Choices:
- O(1)
- O(log n)
- O(n)
- O(2^n)


Question:
A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:l(i,j) = 0, if either i=0 or j=0
       = expr1, if i,j > 0 and X[i-1] = Y[j-1]
       = expr2, if i,j > 0 and X[i-1] != Y[j-1]

Choices:
- expr1 ≡ l(i-1, j) + 1
- expr1 ≡ l(i, j-1)
- expr2 ≡ max(l(i-1, j), l(i, j-1))
- expr2 ≡ max(l(i-1,j-1),l(i,j))


Question: Which of the following standard algorithms is not Dynamic Programming based?

Choices:
- Bellman–Ford Algorithm for single source shortest path
- Floyd Warshall Algorithm for all pairs shortest paths
- 0-1 Knapsack problem
- Prim\'s Minimum Spanning Tree


Question: The subset-sum problem is defined as follows. Given a set of n positive integers, S = {a1 ,a2 ,a3 ,…,an} and positive integer W, is there a subset of S whose elements sum to W? A dynamic program for solving this problem uses a 2-dimensional Boolean array X, with n rows and W+1 columns. X[i, j],1 <= i <= n, 0 <= j <= W, is TRUE if and only if there is a subset of {a1 ,a2 ,...,ai} whose elements sum to j. Which of the following is valid for 2 <= i <= n and ai <= j <= W?

Choices:
- X[i, j] = X[i - 1, j] ∨ X[i, j -ai]
- X[i, j] = X[i - 1, j] ∨ X[i - 1, j - ai]
- X[i, j] = X[i - 1, j] ∧ X[i, j - ai]
- X[i, j] = X[i - 1, j] ∧ X[i -1, j - ai]


Question: Four matrices M1, M2, M3 and M4 of dimensions pxq, qxr, rxs and sxt respectively can be multiplied is several ways with different number of total scalar multiplications. For example, when multiplied as ((M1 X M2) X (M3 X M4)), the total number of multiplications is pqr + rst + prt. When multiplied as (((M1 X M2) X M3) X M4), the total number of scalar multiplications is pqr + prs + pst. If p = 10, q = 100, r = 20, s = 5 and t = 80, then the number of scalar multiplications needed is

Choices:
- 248000
- 44000
- 19000
- 25000


Question: Let P be an array containing n integers. Let t be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of n elements. Which one of the following choices is correct?

Choices:
- t>2n−2
- t>3⌈n/2⌉ and t≤2n−2
- t>n and t≤3⌈n/2⌉
- t>⌈log2(n)⌉ and t≤n


Question:
Suppose you are provided with the following function declaration in the C programming language.
   int partition (int a[], int n);

The function treats the first element of a[] as a pivot, and rearranges the array so that all elements less than or equal to the pivot is in the left part of the array, and all elements greater than the pivot is in the right part. In addition, it moves the pivot so that the pivot is the last element of the left part. The return value is the number of elements in the left part. The following partially given function in the C programming language is used to find the kth smallest element in an array a[ ] of size n using the partition function. We assume k ≤ n

int kth_smallest (int a[], int n, int k)
{
   int left_end = partition (a, n);
   if (left_end+1==k)
   {
       return a [left_end];
   }
   if (left_end+1 > k)
   {
      return kth_smallest (____________________);
   }
   else
   {
      return kth_smallest (____________________);
    }
}

``````C

The missing argument lists are respectively

Choices:
- (a, left_end, k) and (a+left_end+1, n–left_end–1, k–left_end–1)
- (a, left_end, k) and (a, n–left_end–1, k–left_end–1)
- (a, left_end+1, N–left_end–1, K–left_end–1) and(a, left_end, k)
- (a, n–left_end–1, k–left_end–1) and (a, left_end, k)


Question: In dynamic programming, the time complexity of solving a problem with overlapping subproblems using memoization is:

Choices:
- O(1)
- O(log n)
- O(n)
- O(n^2)


Question: Given an unsorted array. The array has this property that every element in the array is at most k distance from its position in a sorted array where k is a positive integer smaller than the size of an array. Which sorting algorithm can be easily modified for sorting this array and what is the obtainable time complexity?

Choices:
- Insertion Sort with time complexity O(kn)
- Heap Sort with time complexity O(nLogk)
- Quick Sort with time complexity O(kLogk)
- Merge Sort with time complexity O(kLogk)


Question: A binary search tree contains the values 1, 2, 3, 4, 5, 6, 7, 8. The tree is traversed in pre-order and the values are printed out. Which of the following sequences is a valid output?

Choices:
- 53124786
- 53126487
- 53241678
- 53124768


Question: Suppose we are sorting an array of eight integers using heapsort, and we have just finished some heapify (either maxheapify or minheapify) operations. The array now looks like this: 16 14 15 10 12 27 28 How many heapify operations have been performed on root of heap?

Choices:
- 1
- 2
- 3 or 4
- 5 or 6


Question: In the 0-1 Knapsack Problem, if an item's weight is greater than the remaining capacity of the knapsack, what action is typically taken?

Choices:
- Ignore the item and move to the next one
- Remove the least valuable item from the knapsack to make space
- Add the fractional part of the item that can fit into the knapsack
- Remove the most valuable item from the knapsack to make space


Question: The time complexity of solving the 0-1 Knapsack Problem using dynamic programming with a bottom-up approach (tabulation) is:

Choices:
- O(n)
- O(n log n)
- O(n * capacity)
- O(n * capacity^2)


Question: The "Longest Increasing Subsequence" problem can be efficiently solved using dynamic programming. What is the time complexity of the dynamic programming approach for this problem?

Choices:
- O(n)
- B) O(n log n)
- O(n^2)
- O(2^n)


Question: Dynamic programming is particularly useful for solving problems that have exponential time complexity.

Choices:
- True
- False


Question: Suppose the letters a, b, c, d, e, f have probabilities 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. Which of the following is the Huffman code for the letter a, b, c, d, e, f?

Choices:
- 0, 10, 110, 1110, 11110, 11111
- 11, 10, 011, 010, 001, 000
- 11, 10, 01, 001, 0001, 0000
- 110, 100, 010, 000, 001, 111


Question: Suppose the letters a, b, c, d, e, f have probabilities 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. What is the average length of Huffman codes?

Choices:
- 3
- 2.1875
- 2.25
- 1.9375


Question: Consider the weights and values of items listed below. Note that there is only one unit of each item.QuestionThe task is to pick a subset of these items such that their total weight is no more than 11 Kgs and their total value is maximized. Moreover, no item may be split. The total value of items picked by an optimal algorithm is denoted by Vopt. A greedy algorithm sorts the items by their value-to-weight ratios in descending order and packs them greedily, starting from the first item in the ordered list. The total value of items picked by the greedy algorithm is denoted by Vgreedy. The value of Vopt − Vgreedy is ______ .

Choices:
- 16
- 8
- 44
- 60


Question: Consider a job scheduling problem with 4 jobs J1, J2, J3, J4 and with corresponding deadlines: ( d1, d2, d3, d4) = (4, 2, 4, 2). Which of the following is not a feasible schedule without violating any job schedule?

Choices:
- J2, J4, J1, J3
- J4, J1, J2, J3
- J4, J2, J1, J3
- J4, J2, J3, J1


Question: Consider a graph G=(V, E), where V = { v1,v2,…,v100 }, E={ (vi, vj) ∣ 1≤ i < j ≤ 100} and weight of the edge (vi, vj)  is ∣i–j∣. The weight of minimum spanning tree of G is ________. Note - This question was Numerical Type.

Choices:
- 99
- 100
- 98
- 101


Question:
Consider the string abbccddeee. Each letter in the string must be assigned a binary code satisfying the following properties:
 For any two letters, the code assigned to one letter must not be a prefix of the code assigned to the other letter.
 For any two letters of the same frequency, the letter which occurs earlier in the dictionary order is assigned a code whose length is at most the length of the code assigned to the other letter.

Among the set of all binary code assignments which satisfy the above two properties, what is the minimum length of the encoded string?

Choices:
- 21
- 23
- 25
- 30


Question:
Define Rn to be the maximum amount earned by cutting a rod of length n meters into one or more pieces of integer length and selling them. For i>0, let p[i] denote the selling price of a rod whose length is i meters. Consider the array of prices:

p[1]=1, p[2]=5, p[3]=8, p[4]=9, p[5]=10, p[6]=17, p[7]=18

Which of the following statements is/are correct about R7?

Choices:
- R7=18
- R7=19
- R7 is achieved by three different solutions
- R7 cannot be achieved by a solution consisting of three pieces


Question:
A function f defined on stacks of integers satisfies the following properties. f(∅) = 0 and f (push (S, i)) = max (f(S), 0) + i for all stacks S and integers i.
If a stack S contains the integers 2, -3, 2, -1, 2 in order from bottom to top, what is f(S)?

Choices:
- 6
- 4
- 3
- 2


Question: The result evaluating the postfix expression 10 5 + 60 6 / * 8 –  is

Choices:
- 284
- 213
- 142
- 71


Question: To evaluate an expression without any embedded function calls :

Choices:
- As many stacks as the height of the expression tree are needed
- One stack is enough
- Two stacks are needed
- A Turing machine is needed in the general case


Question: Assume that the operators +, -, × are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, x , +, -. The postfix expression corresponding to the infix expression a + b × c - d ^ e ^ f is

Choices:
- abc × + def ^ ^ -
- abc × + de ^ f ^ -
- ab + c × d - e ^ f ^
- - + a × bc ^ ^ def


Question: Which of the following problems is closely related to the LPS problem and can also be solved using dynamic programming?

Choices:
- Longest Common Subsequence Problem
- Longest Increasing Subsequence Problem
- Edit Distance Problem
- Subset Sum Problem


Question:
Breadth First Search (BFS) is started on a binary tree beginning from the root vertex. There is a vertex t at a distance four from the root. If t is the n-th vertex in this BFS traversal, then the maximum possible value of n is ________

[This Question was originally a Fill-in-the-blanks Question]

Choices:
- 15
- 16
- 31
- 32


Question: In a binary tree, the number of internal nodes of degree 1 is 5, and the number of internal nodes of degree 2 is 10. The number of leaf nodes in the binary tree is

Choices:
- 10
- 11
- 12
- 15


Question:
The following three are known to be the preorder, inorder and postorder sequences of a binary tree. But it is not known which is which.
MBCAFHPYK
KAMCBYPFH
MABCKYFPH
Pick the true statement from the following.

Choices:
- I and II are preorder and inorder sequences, respectively
- I and III are preorder and postorder sequences, respectively
- II is the inorder sequence, but nothing more can be said about the other two sequences
- II and III are the preorder and inorder sequences, respectively


Question: Which of the following points is/are true about Linked List data structure when it is compared with array?

Choices:
- Arrays have better cache locality that can make them better in terms of performance.
- It is easy to insert and delete elements in Linked List
- Random access is not allowed in a typical implementation of Linked Lists
- The size of array has to be pre-decided, linked lists can change their size any time.
- All of the above


Question:
Consider the following left-rotate and right-rotate functions commonly used in self-adjusting BSTs

T1, T2 and T3 are subtrees of the tree rooted with y (on left side)
or x (on right side)
                y                               x
               / \\     Right Rotation          /  \\
              x   T3   – - – - – - – >        T1   y
             / \\       < - - - - - - -            / \\
            T1  T2     Left Rotation            T2  T3

Which of the following is tightest upper bound for left-rotate and right-rotate operations.

Choices:
- O(1)
- O(Logn)
- O(LogLogn)
- O(n)


Question: What does the following function do for a given Linked List with first node as head?void fun1(struct node* head){  if(head == NULL)    return;    fun1(head->next);  printf("%d  ", head->data);}

Choices:
- Prints all nodes of linked lists
- Prints all nodes of linked list in reverse order
- Prints alternate nodes of Linked List
- Prints alternate nodes in reverse order


Question: A strictly binary tree with 10 leaves

Choices:
- cannot have more than 19 nodes
- has exactly 19 nodes
- has exactly 17 nodes
- has exactly 20 nodes


Question: What is the main goal of the Word Break Problem?

Choices:
- To break a given string into individual characters.
- To determine if a string can be segmented into a sequence of words from a dictionary.
- To find the longest subsequence of a string.
- To reverse a given string.


Question: The Partition Problem can be reduced to which well-known problem?

Choices:
- Knapsack Problem
- Traveling Salesman Problem
- Subset Sum Problem
- Graph Coloring Problem


Question: The "Egg Dropping Puzzle" involves determining the minimum number of attempts needed to find the critical floor from which an egg will break when dropped. What is the time complexity of the dynamic programming approach for solving the Egg Dropping Puzzle for K eggs and N floors?

Choices:
- O(K * N)
- O(K + N)
- O(K * N^2)
- O(K^2 * N)


Question: A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1 and top2 (topl< top 2) point to the location of the topmost element in each of the stacks. If the space is to be used efficiently, the condition for “stack full” is (GATE CS 2004)

Choices:
- (top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1)
- top1 + top2 = MAXSIZE
- (top1= MAXSIZE/2) or (top2 = MAXSIZE)
- top1= top2 -1


Question: The "Longest Increasing Subsequence" problem involves finding the length of the longest subsequence of an array in which the elements are in increasing order. What is the time complexity of the dynamic programming approach for solving the LIS problem for an array of length n?

Choices:
- O(n)
- O(n log n)
- O(n^2)
- O(2^n)


Question: Which of the following does not use Greedy approach?

Choices:
- Huffman Coding
- 0/1 Knapsack
- Fractional Knapsack
- Minimum Spanning Tree


Question: What is the time complexity of the greedy algorithm for the coin change problem?

Choices:
- O(n)
- O(nlogn)
- O(log n)
- O(n^2)


Question: Which of the following standard algorithms is not a Greedy algorithm?

Choices:
- Dijkstra\'s shortest path algorithm
- Prim\'s algorithm
- Kruskal algorithm
- Bellmen Ford Shortest path algorithm


Question: The number of structurally different possible binary trees with 4 nodes is

Choices:
- 14
- 12
- 336
- 168


Question:
In the balanced binary tree in the below figure, how many nodes will become unbalanced when a node is inserted as a child of the node “g”?
         a
       /   \\
      b     e
     / \\   /
    c  d  f
   /
  g

Choices:
- 1
- 3
- 7
- 8


Question:
A binary tree with n > 1 nodes has n1, n2 and n3 nodes of degree one, two and three respectively. The degree of a node is defined as the number of its neighbors.

Starting with the above tree, while there remains a node v of degree two in the tree, add an edge between the two neighbors of v and then remove v from the tree. How many edges will remain at the end of the process?

Choices:
- 2 * n1 - 3
- n2 + 2 * n1 - 2
- n3 - n2
- n2 + n1 - 2


Question:
A binary tree with n > 1 nodes has n1, n2 and n3 nodes of degree one, two and three respectively. The degree of a node is defined as the number of its neighbors.

n3 can be expressed as

Choices:
- n1 + n2 - 1
- n1 - 2
- [((n1 + n2)/2)]
- n2 - 1


Question: Which of the following problems is closely related to the Subsets Sum problem and can also be solved using dynamic programming?

Choices:
- Longest Common Subsequence Problem
- Longest Palindromic Subsequence Problem
- Coin Change Problem
- Optimal Binary Search Tree Problem


Question:
Suppose we are sorting an array of eight integers using quicksort, and we have just finished the first partitioning with the array looking like this:
 2  5  1  7  9  12  11  10

Which statement is correct?

Choices:
- The pivot could be either the 7 or the 9.
- The pivot could be the 7, but it is not the 9
- The pivot is not the 7, but it could be the 9
- Neither the 7 nor the 9 is the pivot.


Question: Let S be a stack of size n >= 1. Starting with the empty stack, suppose we push the first n natural numbers in sequence, and then perform n pop operations. Assume that Push and Pop operation take X seconds each, and Y seconds elapse between the end of one such stack operation and the start of the next operation. For m >= 1, define the stack-life of m as the time elapsed from the end of Push(m) to the start of the pop operation that removes m from S. The average stack-life of an element of this stack is

Choices:
- n(X+ Y)
- 3Y + 2X
- n(X + Y)-X
- Y + 2X


Question:
Following is an incorrect pseudocode for the algorithm which is supposed to determine whether a sequence of parentheses is balanced:

   declare a character stack
   while ( more input is available)
   {
      read a character
      if ( the character is a \'(\' )
         push it on the stack
      else if ( the character is a \')\' and the stack is not empty )
         pop a character off the stack
      else
         print \"unbalanced\" and exit
    }
    print \"balanced\"

``````C

Which of these unbalanced sequences does the above code think is balanced?


Question: How many stacks are needed to implement a queue. Consider the situation where no other data structure like arrays, linked list is available to you.

Choices:
- 1
- 2
- 3
- 4


Question:
Following is C like pseudo-code of a function that takes a Queue as an argument, and uses a stack S to do processing.

void fun(Queue *Q)
{
    Stack S;  // Say it creates an empty stack S

    // Run while Q is not empty
    while (!isEmpty(Q))
    {
        // deQueue an item from Q and push the dequeued item to S
        push(&S, deQueue(Q));
    }

    // Run while Stack S is not empty
    while (!isEmpty(&S))
    {
      // Pop an item from S and enqueue the popped item to Q
      enQueue(Q, pop(&S));
    }
}

``````C

What does the above function do in general?

Choices:
- Removes the last from Q
- Keeps the Q same as it was before the call
- Makes Q empty
- Reverses the Q


Question: What is the worst case efficiency for a path compression algorithm?

Choices:
- O(M log N)
- O(N log N)
- O(log N)
- O(N)


Question: Which of the following is an advantage of adjacency list representation over adjacency matrix representation of a graph?

Choices:
- In adjacency list representation, space is saved for sparse graphs.
- DFS and BSF can be done in O(V + E) time for adjacency list representation. These operations take O(V^2) time in adjacency matrix representation. Here is V and E are number of vertices and edges respectively.
- Adding a vertex in adjacency list representation is easier than adjacency matrix representation.
- All of the above


Question: What is the largest integer m such that every simple connected graph with n vertices and n edges contains at least m different spanning trees?

Choices:
- 1
- 2
- 3
- n


Question: The cyclomatic complexity of the flow graph of a program provides

Choices:
- an upper bound for the number of tests that must be conducted to ensure that all statements have been executed at most once
- a lower bound for the number of tests that must be conducted to ensure that all statements have been executed at most once
- an upper bound for the number of tests that must be conducted to ensure that all statements have been executed at least once
- a lower bound for the number of tests that must be conducted to ensure that all statements have been executed at least once


Question:
Consider the following undirected graph with edge weights as shown:

The number of minimum-weight spanning trees of the graph is ___________.

Choices:
- 3
- 4
- 5
- 2


Question: In an undirected connected planar graph G, there are eight vertices and five faces. The number of edges in G is _________.

Choices:
- 10
- 11
- 12
- 6


Question: Which of the following statements about disjoint-set forests is false?

Choices:
- Disjoint-set forests can be used to efficiently detect cycles in a graph.
- Disjoint-set forests can handle disconnected components efficiently.
- The union operation in disjoint-set forests can be performed in constant time.
- Disjoint-set forests are commonly used in minimum spanning tree algorithms.


Question: Which of the following according to you is incorrect?

Choices:
- Trie is also known as prefix tree
- Trie requires less storage space than hashing
- Trie allows listing of all the words with same prefix
- Tries are collision free


Question: Consider a segment tree built on an array of N elements. What is the minimum number of node updates required to rebuild the entire tree if the original array is reversed?

Choices:
- N
- N - 1
- 2N - 1
- N log N


Question:
In the following graph, discovery time stamps and finishing time stamps of Depth First Search (DFS) are shown as x/y, where x is discovery time stamp and y is finishing time stamp.

It shows which of the following depth first forest?

Choices:
- {a, b, e} {c, d, f, g, h}
- {a, b, e} {c, d, h} {f, g}
- {a, b, e} {f, g} {c, d} {h}
- {a, b, c, d} {e, f, g} {h}


Question: What is the worst case time complexity of insertion sort where position of the data to be inserted is calculated using binary search?

Choices:
- N
- N*log(N)
- N2
- N*log(N)2


Question: You have to sort 1 GB of data with only 100 MB of available main memory. Which sorting technique will be most appropriate?

Choices:
- Heap sort
- Merge sort
- Quick sort
- Insertion sort


Question: What is the best time complexity of bubble sort(optimised)?

Choices:
- N^2
- NlogN
- N
- N(logN)^2


Question: Which of the following operations on a queue data structure has a time complexity of O(1)? A) Enqueue B) Dequeue C) Peek D) Clear

Choices:
- A and B
- B only
- C only
- A and D


Question: A priority queue can efficiently implemented using which of the following data structures? Assume that the number of insert and peek (operation to see the current highest priority item) and extraction (remove the highest priority item) operations are almost same.

Choices:
- Array
- Linked List
- Heap Data Structures like Binary Heap, Fibonacci Heap
- None of the above


Question: Which of the following is true about linked list implementation of queue?

Choices:
- In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation, nodes must be removed from end.
- In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be removed from the beginning.
- Both of the above
- None of the above


Question: A Priority-Queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is given below: 10, 8, 5, 3, 2 Two new elements ”1‘ and ”7‘ are inserted in the heap in that order. The level-order traversal of the heap after the insertion of the elements is:

Choices:
- 10, 8, 7, 5, 3, 2, 1
- 10, 8, 7, 2, 3, 1, 5
- 10, 8, 7, 1, 2, 3, 5
- 10, 8, 7, 3, 2, 1, 5


Question:
Consider the following pseudocode that uses a stack

   declare a stack of characters
   while ( there are more characters in the word to read )
   {
      read a character
      push the character on the stack
   }
   while ( the stack is not empty )
   {
      pop a character off the stack
      write the character to the screen
   }

``````C

What is output for input "geeksquiz"?

Choices:
- geeksquizgeeksquiz
- ziuqskeeg
- geeksquiz
- ziuqskeegziuqskeeg


Question:
Following is C like pseudo code of a function that takes a number as an argument, and uses a stack S to do processing.

void fun(int n)
{
    Stack S;  // Say it creates an empty stack S
    while (n > 0)
    {
      // This line pushes the value of n%2 to stack S
      push(&S, n%2);

      n = n/2;
    }

    // Run while Stack S is not empty
    while (!isEmpty(&S))
      printf(\"%d \", pop(&S)); // pop an element from S and print it
}

``````C

What does the above function do in general?

Choices:
- Prints binary representation of n in reverse order
- Prints binary representation of n
- Prints the value of Logn
- Prints the value of Logn in reverse order


Question:
Consider the following binary search tree:

If we remove the root node, which of the node from the left subtree will be the new root?

Choices:
- 11
- 12
- 13
- 16


Question:
Consider the following binary search tree T given below:
 Which node contains the fourth smallest element in T?

Choices:
- Q
- V
- W
- X


Question: Access time of the symbolic table will be logarithmic if it is implemented by

Choices:
- Linear list
- Search tree
- Hash table
- Self organization list


Question:
Which of the following statements is false ?
(A) Optimal binary search tree construction can be performed efficiently using dynamic programming.
(B) Breadth-first search cannot be used to find connected components of a graph.
(C) Given the prefix and postfix walks of a binary tree, the tree cannot be re-constructed uniquely.
(D) Depth-first-search can be used to find the connected components of a graph.

Choices:
- A
- B
- C
- D


Question: A binary search tree is used to locate the number 43. Which one of the following probe sequence is not possible?

Choices:
- 61, 52, 14, 17, 40, 43
- 10, 65, 31, 48, 37, 43
- 81, 61, 52, 14, 41, 43
- 17, 77, 27, 66, 18, 43


Question:
The following postfix expression with single digit operands is evaluated using a stack:
              8 2 3 ^ / 2 3 * + 5 1 * -

Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:

Choices:
- 6, 1
- 5, 7
- 3, 2
- 1, 5


Question:
Postorder traversal of a given binary search tree T produces following sequence of keys:
3, 5, 7, 9, 4, 17, 16, 20, 18, 15, 14
Which one of the following sequences of keys can be the result of an in-order traversal of the tree T?

Choices:
- 3, 4, 5, 7, 9, 14, 20, 18, 17, 16, 15
- 20, 18, 17, 16, 15, 14, 3, 4, 5, 7, 9
- 20, 18, 17, 16, 15, 14, 9, 7, 5, 4, 3
- 3, 4, 5, 7, 9, 14, 15, 16, 17, 18, 20


Question: A binary search tree is used to locate the number 43. Which of the following probe sequences are possible and which are not? Explain

Choices:
- 61   52   14   17   40   43
- 2    3   50   40   60   43
- 10   65   31   48   37   43
- 81   61   52   14   41   43
- 17   77   27   66   18   43


Question:
A binary search tree is generated by inserting in order the following integers:
 50, 15, 62, 5, 20, 58, 91, 3, 8, 37, 60, 24

The number of nodes in the left subtree and right subtree of the root respectively is

Choices:
- (4, 7)
- (7, 4)
- (8, 3)
- (3, 8)


Question: How many distinct BSTs can be constructed with 3 distinct keys?

Choices:
- 4
- 5
- 6
- 9


Question: Which of the following is NOT a common operation in a queue data structure?

Choices:
- Enqueue
- Dequeue
- Peek
- Shuffle


Question:
Consider the following pseudo code. Assume that IntQueue is an integer queue. What does the function fun do?

void fun(int n)
{
    IntQueue q = new IntQueue();
    q.enqueue(0);
    q.enqueue(1);
    for (int i = 0; i < n; i++)
    {
        int a = q.dequeue();
        int b = q.dequeue();
        q.enqueue(b);
        q.enqueue(a + b);
        print(a);
    }
}

``````C

Choices:
- Prints numbers from 0 to n-1
- Prints numbers from n-1 to 0
- Prints first n Fibonacci numbers
- Prints first n Fibonacci numbers in reverse order.


Question: Consider the following operation along with Enqueue and Dequeue operations on queues, where k is a global parameter.MultiDequeue(Q){   m = k   while (Q is not empty and m  > 0) {      Dequeue(Q)      m = m - 1   }}What is the worst case time complexity of a sequence of n MultiDequeue() operations on an initially empty queue? (GATE CS 2013) (A) [Tex]\\Theta(n)  [/Tex](B) [Tex]\\Theta(n + k)  [/Tex](C) [Tex]\\Theta(nk)  [/Tex](D) [Tex]\\Theta(n^2) [/Tex]

Choices:
- A
- B
- C
- D


Question:
An implementation of a queue Q, using two stacks S1 and S2, is given below:

void insert(Q, x) {
   push (S1, x);
}

void delete(Q){
   if(stack-empty(S2)) then
      if(stack-empty(S1)) then {
          print(“Q is empty”);
          return;
      }
      else while (!(stack-empty(S1))){
          x=pop(S1);
          push(S2,x);
      }
   x=pop(S2);
}

``````C

Let n insert and m (<=n) delete operations be performed in an arbitrary order on an empty queue Q. Let x and y be the number of push and pop operations performed respectively in the process. Which one of the following is true for all m and n?

Choices:
- n+m <= x < 2n and 2m <= y <= n+m
- n+m <= x < 2n and 2m<= y <= 2n
- 2m <= x < 2n and 2m <= y <= n+m
- 2m <= x <2n and 2m <= y <= 2n


Question: The following numbers are inserted into an empty binary search tree in the given order: 10, 1, 3, 5, 15, 12, 16 What is the height of the binary search tree ?

Choices:
- 3
- 4
- 5
- 6


Question:
Which of the following is AVL Tree?

A
        100
     /      \\
    50       200
   /           \\
 10            300

B
           100
       /       \\
     50        200
    /        /     \\
  10       150     300
 /
5

C
            100
       /          \\
     50            200
    /  \\          /     \\
  10    60       150     300
 /                 \\        \\
5                   180       400

Choices:
- Only A
- A and C
- A, B and C
- Only B


Question: What is the worst case time complexity for search, insert and delete operations in a general Binary Search Tree for a skewed tree ?

Choices:
- O(n) for all
- O(Logn) for all
- O(Logn) for search and insert, and O(n) for delete
- O(Logn) for search, and O(n) for insert and delete


Question: What is the worst case time complexity of inserting n2 elements into an AVL-tree with n elements initially ?

Choices:
- Θ(n4)
- Θ(n2)
- Θ(n2 log n)
- Θ(n3)


Question: In how many ways can the string A ∩ B – A ∩ B – A be fully parenthesized to yield an infix expression?

Choices:
- 15
- 14
- 13
- 12


Question:
Given the following prefix expression:
* + 3 + 3 ↑ 3 + 3 3 3
What is the value of the prefix expression ?

Choices:
- 2178
- 2199
- 2205
- 2232


Question:
Consider the following statements:
S1: A queue can be implemented using two stacks.
S2: A stack can be implemented using two queues.
Which of the following is correct?

Choices:
- S1 is correct and S2 is not correct.
- S1  is not correct and S2 is correct.
- Both S1 and S2 are correct.
- Both S1 and S2 are incorrect.


Question:
A t-error correcting q-nary linear code must satisfy:

Where M is the number of code words and X is

Choices:
- qn
- qt
- q-n
- q-t


Question:
Consider the following AO graph:

Which is the best node to expand next by AO* algorithm?

Choices:
- A
- B
- C
- B and C


Question: The minimum number of scalar multiplication required, for parenthesization of a matrix-chain product whose sequence of dimensions for four matrices is <5, 10, 3, 12, 5> is

Choices:
- 630
- 580
- 480
- 405


Question: Consider a line AB with A = (0, 0) and B = (8, 4). Apply a simple DDA algorithm and compute the first four plots on this line.

Choices:
- [(0, 0), (1, 1), (2, 1), (3, 2)]
- [(0, 0), (1, 1.5), (2, 2), (3, 3)]
- [(0, 0), (1, 1), (2, 2.5), (3, 3)]
- [(0, 0), (1, 2), (2, 2), (3, 2)]


Question: Below are the few steps given for scan-converting a circle using Bresenham’s Algorithm. Which of the given steps is not correct ?

Choices:
- Compute d = 3 – 2r (where r is radius)
- Stop if x > y
- If d < 0, then d = 4x + 6 and x = x + 1
- If d ≥ 0, then d = 4 ∗ (x – y) + 10, x = x + 1 and y = y + 1


Question: If h is chosen from a universal collection of hash functions and is used to hash n keys into a table of size m, where n ≤ m, the expected number of collisions involving a particular key x is less than _______.

Choices:
- 1
- 1/n
- 1/m
- n/m


Question:
What is the worst case possible height of Red-Black tree?

Assume base of Log as 2 in all options

Choices:
- 2Log(n+1)
- 1.44 Logn
- 4Logn
- None of the above


Question: Which of the following is true about AVL and Red Black Trees?

Choices:
- In AVL tree insert() operation, we first traverse from root to newly inserted node and then from newly inserted node to root.  While in Red Black tree insert(), we only traverse once from root to newly inserted node.
- In both AVL and Red Black insert operations, we traverse only once from root to newly inserted node,
- In both AVL and Red Black insert operations, we traverse twiceL first traverse root to newly inserted node and then from newly inserted node to root.
- None of the above


Question: Which of the following is true about Red Black Trees?

Choices:
- The path from the root to the furthest leaf is no more than twice as long as the path from the root to the nearest leaf
- At least one children of every black node is red
- Root may be red
- A leaf node may be red


Question: Which of the following is true

Choices:
- The AVL trees are more balanced compared to Red Black Trees, but they may cause more rotations during insertion and deletion.
- Heights of AVL and Red-Black trees are generally same, but AVL Trees may cause more rotations during insertion and deletion.
- Red Black trees are more balanced compared to AVL Trees, but may cause more rotations during insertion and deletion.
- Heights of AVL and Red-Black trees are generally same, but Red Black trees may cause more rotations during insertion and deletion.


Question: Which of the following is a self-adjusting or self-balancing Binary Search Tree

Choices:
- Splay Tree
- AVL Tree
- Red Black Tree
- All of the above


Question:
Consider the following AVL tree.

         60
      /     \\
    20      100
           /   \\
         80    120

Which of the following is updated AVL tree after insertion of 70

A
        70
      /    \\
    60      100
   /       /    \\
 20       80    120

B
        100
      /    \\
    60      120
   /  \\     /
 20   70   80

C
        80
      /    \\
    60      100
   /  \\       \\
 20   70      120

D
        80
      /    \\
    60      100
   /       /   \\
 20      70    120

Choices:
- A
- B
- C
- D


Question:
The degree sequence of a simple graph is the sequence of the degrees of the nodes in the graph in decreasing order. Which of the following sequences can not be the degree sequence of any graph?  I. 7, 6, 5, 4, 4, 3, 2, 1
II. 6, 6, 6, 6, 3, 3, 2, 2
III. 7, 6, 6, 4, 4, 3, 2, 2
IV. 8, 7, 7, 6, 4, 2, 1, 1

Choices:
- I and II
- III and IV
- IV only
- II and IV


Question: The time complexity of computing the transitive closure of a binary relation on a set of n elements is known to be:

Choices:
- O(n)
- O(nLogn)
- O(n ^ (3/2))
- O(n^3)


Question: The most efficient algorithm for finding the number of connected components in an undirected graph on n vertices and m edges has time complexity.

Choices:
- theta(n)
- theta(m)
- theta(m + n)
- theta(mn)


Question: Consider an undirected unweighted graph G. Let a breadth-first traversal of G be done starting from a node r. Let d(r, u) and d(r, v) be the lengths of the shortest paths from r to u and v respectively, in G. lf u is visited before v during the breadth-first traversal, which of the following statements is correct?

Choices:
- d(r, u) < d (r, v)
- d(r, u) > d(r, v)
- d(r, u) <= d (r, v)
- None of the above


Question: Consider a double hashing scheme in which the primary hash function is h1(k) = k mod 23, and the secondary hash function is h2(k) = 1+(k mod 19). Assume that the table size is 23. Then the address returned by probe 1 in the probe sequence (assume that the probe sequence begins at probe 0) for key value k = 90 is ________ .

Choices:
- 13
- 15
- 21
- 23


Question: A hash function h defined h(key)=key mod 7, with linear probing, is used to insert the keys 44, 45, 79, 55, 91, 18, 63 into a table indexed from 0 to 6. What will be the location of key 18 ?

Choices:
- 3
- 4
- 5
- 6


Question: A hash table with 10 buckets with one slot per bucket is depicted here. The symbols, S1 to S7 are initially entered using a hashing function with linear probing. The maximum number of comparisons needed in searching an item that is not present is

Choices:
- 4
- 5
- 6
- 3


Question: Consider a hash table of size m = 100 and the hash function h(k) = floor(m(kA mod 1)) for  Compute the location to which the key k = 123456 is placed in hash table.

Choices:
- 77
- 82
- 88
- 89


Question: What will be the cipher text produced by the following cipher function for the plain text ISRO with key k =7. [Consider \'A\' = 0, \'B\' = 1, .......\'Z\' = 25]. Ck(M) = (kM + 13) mod 26

Choices:
- RJCH
- QIBG
- GQPM
- XPIN


Question: Consider a 13 element hash table for which f(key)=key mod 13 is used with integer keys. Assuming linear probing is used for collision resolution, at which location would the key 103 be inserted, if the keys 661, 182, 24 and 103 are inserted in that order?

Choices:
- 0
- 1
- 11
- 12


Question: Consider a hash table of size m = 10000, and the hash function h(K) = floor (m(KA mod 1)) for A = ( √(5) – 1)/2. The key 123456 is mapped to location ______.

Choices:
- 46
- 41
- 43
- 48


Question: What is the maximum height of any AVL-tree with 7 nodes? Assume that the height of a tree with a single node is 0.

Choices:
- 2
- 3
- 4
- 5


Question: What is the maximum number of edges in an acyclic undirected graph with n vertices?

Choices:
- n-1
- n
- n + 1
- 2n-1


Question:
Which of the following operations are used by Red-Black trees to maintain balance during insertion/deletion?

a) Recoloring of nodes
b) Rotation (Left and Right)

Choices:
- Only a
- Only b
- Both a and b
- Neither a nor b


Question:
Is the following statement valid?

A Red-Black Tree which is also a perfect Binary Tree can have all black nodes

Choices:
- Yes
- No


Question: How many undirected graphs (not necessarily connected) can be constructed out of a given set V = {v1, v2, ... vn} of n vertices?

Choices:
- n(n-1)/2
- 2n
- n!
- 2n(n-1)/2


Question: In which scenario would a directed acyclic graph (DAG) be most suitable?

Choices:
- Representing dependencies between tasks in a project schedule
- Modeling a social network with friend connections
- Finding the shortest path between two nodes in a weighted graph
- Performing breadth-first search (BFS) on a graph


Question: 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?

Choices:
- 1/8
- 1
- 7
- 8


Question: Which of the following statements is/are TRUE for an undirected graph? P: The number of odd-degree vertices is even Q: Sum of degrees of all vertices is even

Choices:
- P Only
- Q Only
- Both P and Q
- Neither P nor Q


Question: How many undirected graphs (not necessarily connected) can be constructed out of a given set V= {V 1, V 2,…V n} of n vertices ?

Choices:
- n(n-l)/2
- 2^n
- n!
- 2^(n(n-1)/2)


Question: Consider a source with symbols A, B, C, D with probabilities 1/2, 1/4, 1/8, 1/8 respectively. What is the average number of bits per symbol for the Huffman code generated from above information ?

Choices:
- 2 bits per symbol
- 1.75 bits per symbol
- 1.50 bits per symbol
- 1.25 bits per symbol


Question:
Consider a dynamic hashing approach for 4-bit integer keys:
 (A) There is a main hash table of size 4.
 (B) The 2 least significant bits of a key is used to index into the main hash table.
 (C) Initially, the main hash table entries are empty.
 (D) Thereafter, when more keys are hashed into it, to resolve collisions, the set of all keys corresponding to a main hash table entry is organized as a binary tree that grows on demand.
 (E) First, the 3rd least significant bit is used to divide the keys into left and right subtrees.
 (F) To resolve more collisions, each node of the binary tree is further sub-divided into left and right subtrees based on the 4th least significant bit.
 (G) A split is done only if it is needed, i.e., only when there is a collision.

Consider the following state of the hash table.

Which of the following sequences of key insertions can cause the above state of the hash table (assume the keys are in decimal notation)?

Choices:
- 5,9,4,13,10,7
- 9,5,10,6,7,1
- 10,9,6,7,5,13
- 9,5,13,6,10,14


Question: The worst case running time to search for an element in a balanced in a binary search tree with n2^n elements is (A) [Tex]\\Theta(n log n) [/Tex](B) [Tex]\\Theta (n2^n) [/Tex](C) [Tex]\\Theta (n) [/Tex](D) [Tex]\\Theta (log n) [/Tex]

Choices:
- A
- B
- C
- D


Question:
Which of the following traversals is sufficient to construct BST from given traversals
1) Inorder
2) Preorder
3) Postorder

Choices:
- Any one of the given three traversals is sufficient
- Either 2 or 3 is sufficient
- 2 and 3
- 1 and 3


Question: For parameters a and b, both of which are ω(1), T(n)=T(n1/a)+1, and T(b)=1. Then T(n) is

Choices:
- Θ(logalogbn)
- Θ(logabn)
- Θ(logblogan)
- Θ(log2log2n)


Question:
For constants a≥1 and b>1, consider the following recurrence defined on the non-negative integers:

T(n) = a⋅T(n/b) + f(n)

Which one of the following options is correct about the recurrence T(n)?

Choices:
- A
- B
- C
- D


Question: If all the edge weights of an undirected graph are positive, then any subset of edges that connects all the vertices and has minimum total weight is a

Choices:
- Hamiltonian cycle
- grid
- hypercube
- tree


Question: If Tree-1 and Tree-2 are the trees indicated below :  Which traversals of Tree-1 and Tree-2, respectively, will produce the same sequence?

Choices:
- Preorder, postorder
- Postorder, inorder
- Postorder, preorder
- Inorder, preorder


Question:
Assume that the operators +, −, × are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, ×, +, −. The postfix expression corresponding to the infix expression is
a + b × c − d ^ e ^ f

Choices:
- abc x  + def ^ ^ −
- abc x + de ^ f ^ −
- ab + c × d − e^f^
- − + a × b c^^ def


Question: Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are inserted in that order into an initially empty binary search tree. The binary search tree uses the usual ordering on natural numbers. What is the inorder traversal sequence of the resultant tree?

Choices:
- 7 5 1 0 3 2 4 6 8 9
- 0 2 4 3 1 6 5 9 8 7
- 0 1 2 3 4 5 6 7 8 9
- 9 8 6 4 2 3 0 1 5 7


Question: The in-order traversal of a tree resulted in FBGADCE. Then the pre-order traversal of that tree would result in

Choices:
- FGBDECA
- ABFGCDE
- BFGCDEA
- AFGBDEC


Question: Level order Traversal of a rooted Tree can be done by starting from root and performing:

Choices:
- Breadth First Search
- Depth First Search
- Root Search
- Deep Search


Question: The inorder and preorder Traversal of binary Tree are dbeafcg and abdecfg respectively. The post-order Traversal is __________.

Choices:
- dbefacg
- debfagc
- dbefcga
- debfgca


Question:
Consider the following statements:
(a) Depth - first search is used to traverse a rooted tree.
(b) Pre - order, Post-order and Inorder are used to list the vertices of an ordered rooted tree.
(c) Huffman’s algorithm is used to find an optimal binary tree with given weights.
(d) Topological sorting provides a labelling such that the parents have larger labels than their children.
Which of the above statements are true?

Choices:
- (a) and (b)
- (c) and (d)
- (a), (b) and (c)
- (a), (b), (c) and (d)


Question: The number of rotations required to insert a sequence of elements 9,6,5,8,7,10 into an empty AVL tree is?

Choices:
- 0
- 1
- 2
- 3


Question:
Choose the equivalent prefix form of the following expression
(a + (b − c))* ((d − e)/(f + g − h))

Choices:
- * +a − bc /− de − +fgh
- * +a −bc − /de − +fgh
- * +a − bc /− ed + −fgh
- * +ab − c /− ed + −fgh


Question:
What is wrong with the below algorithm for searching the missing number from 1 to n?
int getMissingNo(int a[], int n)
{
	int i, total;
	total = (n + 1) * (n + 2) / 2;
	for (i = 0; i < n; i++)
		total += a[i];
	return total;
}

Choices:
- variable 'total' can not be modified.
- Infinite loop
- Run time error
- we are using Add("+") operation instead of subtraction("-").


Question: Heap allocation is required for languages that

Choices:
- use dynamic scope rules
- support dynamic data structures
- support recursion
- support recursion and dynamic data structures


Question:
Consider the following function that takes reference to head of a Doubly Linked List as parameter. Assume that a node of doubly linked list has previous pointer as prev and next pointer as next.

void fun(struct node **head_ref)
{
    struct node *temp = NULL;
    struct node *current = *head_ref;

    while (current !=  NULL)
    {
        temp = current->prev;
        current->prev = current->next;
        current->next = temp;
        current = current->prev;
    }

    if(temp != NULL )
        *head_ref = temp->prev;
}

``````C

Assume that reference of head of following doubly linked list is passed to above function 1 <--> 2 <--> 3 <--> 4 <--> 5 <-->6. What should be the modified linked list after the function call?

Choices:
- 2 <--> 1 <--> 4 <--> 3 <--> 6 <-->5
- 5 <--> 4 <--> 3 <--> 2 <--> 1 <-->6.
- 6 <--> 5 <--> 4 <--> 3 <--> 2 <--> 1.
- 6 <--> 5 <--> 4 <--> 3 <--> 1 <--> 2


Question: We can show that the clique problem is NP-hard by proving that

Choices:
- CLIQUE ≤ P 3-CNF_SAT
- CLIQUE ≤ P VERTEX_COVER
- CLIQUE ≤ P SUBSET_SUM
- None of the above


Question: Standard planning algorithms assume environment to be __________.

Choices:
- Both deterministic and fully observable
- Neither deterministic nor fully observable
- Deterministic but not fully observable
- Not deterministic but fully observable


Question:
Suppose T(n) = 2T(n/2) + n, T(0) = T(1) = 1
Which one of the following is false. ( GATE CS 2005)
a)	T(n) = O(n^2)
b)	T(n) = [Tex]\\theta[/Tex](nLogn)
c)	T(n) = [Tex]\\Omega[/Tex](n^2)
d)	T(n) = O(nLogn)

Choices:
- A
- B
- C
- D


Question:
Consider the following C program

main()
{
    int x, y, m, n;
    scanf (\"%d %d\", &x, &y);
    /* Assume x > 0 and y > 0  */
    m = x;
    n = y;
    while (m! = n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    print f (\"% d\", n);
}

``````C

The program computes

Choices:
- x ÷ y using repeated subtraction
- x mod y using repeated subtraction
- the greatest common divisor of x and y
- the least common multiple of x and y


Question: Consider the following Binary Search Tree  If we randomly search one of the keys present in above BST, what would be the expected number of comparisons?

Choices:
- 2.75
- 2.25
- 2.57
- 3.25


Question: The preorder traversal sequence of a binary search tree is 30, 20, 10, 15, 25, 23, 39, 35, 42. Which one of the following is the postorder traversal sequence of the same tree?

Choices:
- 10, 20, 15, 23, 25, 35, 42, 39, 30
- 15, 10, 25, 23, 20, 42, 35, 39, 30
- 15, 20, 10, 23, 25, 42, 35, 39, 30
- 15, 10, 23, 25, 20, 35, 42, 39, 30


Question: The following numbers are inserted into an empty binary search tree in the given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree (the height is the maximum distance of a leaf node from the root)? (GATE CS 2004)

Choices:
- 2
- 3
- 4
- 6


Question: Which of the following traversal outputs the data in sorted order in a BST?

Choices:
- Preorder
- Inorder
- Postorder
- Level order


Question: How many distinct binary search trees can be created out of 4 distinct keys?

Choices:
- 4
- 14
- 24
- 42


Question: We are given a set of n distinct elements and an unlabelled binary tree with n nodes. In how many ways can we populate the tree with the given set so that it becomes a binary search tree? (GATE CS 2011)

Choices:
- 0
- 1
- n!
- (1/(n+1)).2nCn


Question: In delete operation of BST, we need inorder successor (or predecessor) of a node when the node to be deleted has both left and right child as non-empty. Which of the following is true about inorder successor needed in delete operation?

Choices:
- Inorder Successor is always a leaf node
- Inorder successor is always either a leaf node or a node with empty left child
- Inorder successor may be an ancestor of the node
- Inorder successor is always either a leaf node or a node with empty right child


Question:
Consider the following code snippet in C. The function print() receives root of a Binary Search Tree (BST) and a positive integer k as arguments.

// A BST node
struct node {
    int data;
    struct node *left, *right;
};

int count = 0;

void print(struct node *root, int k)
{
    if (root != NULL && count <= k)
    {
        print(root->right, k);
        count++;
        if (count == k)
          printf(\"%d \", root->data);
       print(root->left, k);
    }
}

``````C

What is the output of print(root, 3) where root represent root of the following BST.
                   15
                /     \\
              10      20
             / \\     /  \\
            8  12   16  25

Choices:
- 10
- 16
- 20
- 20 10


Question:
Let swap() be a function that swaps two elements using their addresses.  Consider the following C function.

void fun(int arr[], int n)
{
    for (int i = 0; i < n; i+=2)
    {
        if (i>0 && arr[i-1] > arr[i] )
            swap(&arr[i], &arr[i-1]);
        if (i<n-1 && arr[i] < arr[i+1] )
            swap(&arr[i], &arr[i + 1]);
    }
}

``````C

If an array {10, 20, 30, 40, 50, 60, 70, 80} is passed to the function, the array is changed to

Choices:
- {20, 10, 40, 30, 60, 50, 80, 70}
- {10,  30,  20, 40,  60,  50,  80, 70}
- {10, 20, 30, 40, 50, 60, 70, 80}
- {80, 70, 60, 50, 40, 30, 20, 10}


Question: X, Y and Z are closed intervals of unit length on the real line. The overlap of X and Y is half a unit. The overlap of Y and Z is also half a unit. Let the overlap of X and Z be k units. Which of the following is true?

Choices:
- k must be 1
- k must be 0
-
k can take any value between 0 and 1 (d) None
of the above
- None of the above


Question:
An n x n array v is defined as follows:
v[i, j] = i-j for all i, j, 1 <= i <= n, 1 <= j <= n

The sum of the elements of the array v is

Choices:
- 0
- n-1
- n2 - 3n + 2
- n2 (n+1)/2


Question:
In the following C program fragment, j, k n and TwoLog_n are integer variables, and A is an array of integers. The variable n is initialized to an integer ≥ 3, and TwoLog_n is initialized to the value of 2*⌈log2(n)⌉

for (k = 3; k < = n; k++)
    A[k] = 0;
for (k = 2; k < = TwoLog_n; k++)
    for (j = k + 1; j < = n; j++)
        A[j] = A[j] || (j % k);
for (j = 3; j < = n; j++)
    if (!A[j]) printf(\"%d\", j);

``````C

The set of numbers printed by this program fragment is

Choices:
- {m | m ≤ n, (∃ i) [m = i!]} Here i! mean factorial of i
- {m | m ≤ n, (∃ i) [m = i2]}
- {m | m ≤ n, m is prime}
- Last print never executes


Question:
The following are the starting and ending times of activities A, B, C, D, E, F, G and H respectively in chronological order: "asbscsaedsceesfsbedegseefehsgehe"

Here, xs denotes the starting time and xe  denotes the ending time of activity X. W need to schedule the activities in a set of rooms available to us. An activity can be scheduled in a room only if the room is reserved for the activity for its entire duration. What is the minimum number of rooms required ?

Choices:
- 3
- 4
- 5
- 6


Question: In a permutation a1.....an of n distinct integers, an inversion is a pair (ai, aj) such that i < j and ai > aj. If all permutations are equally likely, what is the expected number of inversions in a randomly chosen permutation of 1.....n ?

Choices:
- n(n - 1)/2
- n(n - 1)/4
- n(n + 1)/4
- 2n[log2 n]


Question: Huffman coding is a lossless data compression algorithm. The most frequent character gets the smallest code and the least frequent character gets the largest code. Consider the following statements regarding Huffman coding algorithm? S1 : The time complexity of the Huffman algorithm is O(nlogn). Using a heap to store the weight of each tree, each iteration requires O(logn) time to determine the cheapest weight and insert the new weight. There are O(n) iterations, one for each item. S2 : If the input array is sorted, there exists a linear time algorithm. S3 : A divide-and-conquer approach might have us asking which characters should appear in the left and right subtrees and trying to build the tree from the top down. As with the optimal binary search tree, this will lead to to an exponential time algorithm. Which of the following option is correct?

Choices:
- Statement S1 is correct, Statements S2 and S3 are not correct.
- Statements S1 and S2 are correct and statement S3 is not correct.
- Statements S2 and S3 are correct and statement S1 is not correct.
- All statements S1, S2, and S3 are correct.


Question:
What does the following algorithm approximate?

    x = m;
    y = 1;
    while (x - y > e)
    {
        x = (x + y)/2;
        y = m/x;
    }
    print(x);

``````C

(Assume m > 1, e > 0).

Choices:
- log m
- m2
- m1/2
- m1/3


Question:
Suppose you are given an array s[1..n] and a procedure reverse (s, i, j) which reverses the order of elements in a between positions i and j (both inclusive). What does the following sequence do, where 1 <= k <= n:

reverse(s, 1, k) ;
reverse(s, k + 1, n);
reverse(s, l, n);

Choices:
- Rotates s left by k positions
- Leaves s unchanged
- Reverses all elements of s
- None of the above


Question:
Consider double hashing of the form
h(k,i)=(h 1 (k)+ih 2 (k)) mod m
Where h 1 (k)=k mod m
h 2 (k)=1+(k mod n)
Where n=m-1and m=701
for k=123456, what is the difference between first and second probes in terms of slots?

Choices:
- 255
- 256
- 257
- 258


Question: An advantage of chained hash table (external hashing) over the open addressing scheme is

Choices:
- Worst case complexity of search operations is less
- Space used is less
- Deletion is easier
- None of the above


Question: Which of the following is true about Binary Trees?

Choices:
- Every binary tree is either complete or full.
- Every complete binary tree is also a full binary tree.
- Every full binary tree is also a complete binary tree.
- No binary tree is both complete and full.
- None of the above


Question:
Consider the following two sentences :
(a) The planning graph data structure can be used to give a better heuristic for a planning problem.
(b) Dropping negative effects from every action schema in a planning problem results in a relaxed problem.
Which of the following is correct with respect to the above sentences ?

Choices:
- Both sentence (a) and sentence (b) are false.
- Both sentence (a) and sentence (b) are true.
- Sentence (a) is true but sentence (b) is false.
- Sentence (a) is false but sentence (b) is true.


Question: A 5-ary tree is tree in which every internal node has exactly 5 children. The number of left nodes in such a tree with 8 internal nodes will be:

Choices:
- 30
- 33
- 45
- 130


Question: Given the symbols A, B, C, D, E, F, G and H with the probabilities 1 / 30, 1 / 30, 1 / 30, 2 / 30, 3 / 30, 5 / 30, 5 / 30, and 12 / 30 respectively. The average Huffman code size in bits per symbol is:

Choices:
- 67 / 30
- 70 / 30
- 76 / 30
- 78/ 30


Question: A symbol table of length 152 is processing 25 entries at any instant. What is occupation density?

Choices:
- 0.164
- 127
- 8.06
- 6.08


Question: Match the following:

Choices:
- (1)
- (2)
- (3)
- (4)


Question:
Q85 Part_B

Consider a simple graph with unit edge costs. Each node in the graph represents a router. Each node maintains a routing table indicating the next hop router to be used to relay a packet to its destination and the cost of the path to the destination through that router. Initially, the routing table is empty. The routing table is synchronously updated as follows. In each updation interval, three tasks are performed.
 A node determines whether its neighbours in the graph are accessible. If so, it sets the tentative cost to each accessible neighbour as 1. Otherwise, the cost is set to ∞. From each accessible neighbour, it gets the costs to relay to other nodes via that neighbour (as the next hop). Each node updates its routing table based on the information received in the previous two steps by choosing the minimum cost.   For the graph given above, possible routing tables for various nodes after they have stabilized, are shown in the following options. Identify the correct table.

1)
Table for node A

 A
 -
 -

 B
 B
 1

 C
 C
 1

 D
 B
 3

 E
 C
 3

 F
 C
 4

    2) Table for node C
    A  A  1    B  B  1    C  -  -    D  D  1    E  E  1    F  E  3        3) Table for node B
    A  A  1    B  -  -    C  C  1    D  D  1    E  C  2    F  D  2       4) Table for node D
    A  B  3    B  B  1    C  C  1    D  - -    E  E  1    F  F  1
Continuing from the earlier problem, suppose at some time t, when the costs have stabilized, node A goes down. The cost from node F to node A at time (t + 100) is

Choices:
- >100 but finite
- 3
- >3 and ≤100


Question:
Q85  Part_A

Consider a simple graph with unit edge costs. Each node in the graph represents a router. Each node maintains a routing table indicating the next hop router to be used to relay a packet to its destination and the cost of the path to the destination through that router. Initially, the routing table is empty. The routing table is synchronously updated as follows. In each updation interval, three tasks are performed.
 A node determines whether its neighbours in the graph are accessible. If so, it sets the tentative cost to each accessible neighbour as 1. Otherwise, the cost is set to ∞. From each accessible neighbour, it gets the costs to relay to other nodes via that neighbour (as the next hop). Each node updates its routing table based on the information received in the previous two steps by choosing the minimum cost.   For the graph given above, possible routing tables for various nodes after they have stabilized, are shown in the following options. Identify the correct table.

1)
Table for node A

 A
 -
 -

 B
 B
 1

 C
 C
 1

 D
 B
 3

 E
 C
 3

 F
 C
 4

    2) Table for node C
    A  A  1    B  B  1    C  -  -    D  D  1    E  E  1    F  E  3        3) Table for node B
    A  A  1    B  -  -    C  C  1    D  D  1    E  C  2    F  D  2       4) Table for node D
    A  B  3    B  B  1    C  C  1    D  - -    E  E  1    F  F  1

Choices:
- A
- B
- C
- D


Question:
Q84 Part_B  A sink in a directed graph is a vertex i such that there is an edge from every vertex j ≠ i to i and there is no edge from i to any other vertex. A directed graph G with n vertices is represented by its adjacency matrix A, where A[i] [j] = 1 if there is an edge directed from vertex i to j and 0 otherwise. The following algorithm determines whether there is a sink in the graph G.
i = 0
do {
    j = i + 1;
    while ((j < n) && E1) j++;
    if (j < n) E2;
} while (j < n);

flag = 1;
for (j = 0; j < n; j++)
    if ((j! = i) && E3)
        flag = 0;

if (flag)
    printf("Sink exists");
else
    printf("Sink does not exist");

Choose the correct expressions for E3

Choices:
- (A[i][j] && !A[j][i])
- (!A[i][j] && A[j][i])
- (!A[i][j] | |  A[j][i])
- (A[i][j] | | !A[j][i])


Question: While inserting the elements 71, 65, 84, 69, 67, 83 in an empty binary search tree (BST) in the sequence shown, the element in the lowest level is

Choices:
- 65
- 67
- 69
- 83


Question: What are the worst-case complexities of insertion and deletion of a key in a binary search tree?

Choices:
- Θ(logn) for both insertion and deletion
- Θ(n) for both insertion and deletion
- Θ(n) for insertion and Θ(logn) for deletion
- Θ(logn) for insertion and Θ(n) for deletion


Question:
Let T(n) be the number of different binary search trees on n distinct elements.
Then , where x is

Choices:
- n-k+1
- n-k
- n-k-1
- n-k-2


Question:
Suppose we have a balanced binary search tree T holding n numbers. We are given two numbers L and H and wish to sum up all the numbers in T that lie between L and H. Suppose there are m such numbers in T. If the tightest upper bound on the time to
compute the sum is O(nalogb n + mc logd n), the value of a + 10b + 100c + 1000d is ____.

Choices:
- 60
- 110
- 210
- 50


Question: You are given the postorder traversal, P, of a binary search tree on the n elements 1, 2, ..., n. You have to determine the unique binary search tree that has P as its postorder traversal. What is the time complexity of the most efficient algorithm for doing this?

Choices:
- O(Logn)
- O(n)
- O(nLogn)
- none of the above, as the tree cannot be uniquely determined.


Question:
Consider the same code as given in above question.  What does the function print() do in general?

The function print() receives root of a Binary Search Tree (BST) and a positive integer k as arguments.

// A BST node
struct node {
    int data;
    struct node *left, *right;
};

int count = 0;

void print(struct node *root, int k)
{
    if (root != NULL && count <= k)
    {
        print(root->right, k);
        count++;
        if (count == k)
          printf(\"%d \", root->data);
       print(root->left, k);
    }
}

``````C

Choices:
- Prints the kth smallest element in BST
- Prints the kth largest element in BST
- Prints the leftmost node at level k from root
- Prints the rightmost node at level k from root


Question: A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown in the figure. Let n denote the number of nodes in the queue. Let \'enqueue\' be implemented by inserting a new node at the head, and \'dequeue\' be implemented by deletion of a node from the tail.head->1->2->3->tail.Which one of the following is the time complexity of the most time-efficient implementation of \'enqueue\' and \'dequeue, respectively, for this data structure?

Choices:
- Θ(1), Θ(1)
- Θ(1), Θ(n)
- Θ(n), Θ(1)
- Θ(n), Θ(n)


Question: Question

Choices:
- 1
- 2
- 3
- 4


Question:
Consider double hashing of the form
h(k,i)=(h 1 (k)+ih 2 (k)) mod m
Where h 1 (k)=k mod m
h 2 (k)=1+(k mod n)
Where n=m-1and m=701
for k=123456, what is the difference between first and second probes in terms of slots?

Choices:
- 255
- 256
- 257
- 258


Question: The number of possible min-heaps containing each value from {1, 2, 3, 4, 5, 6, 7} exactly once is _______. Note -This was Numerical Type question.

Choices:
- 80
- 8
- 20
- 210


Question:
The number of ways in which the numbers 1, 2, 3, 4, 5, 6, 7 can be inserted in an empty binary search tree, such that the resulting tree has height 6, is _____________

Note: The height of a tree with a single node is 0.

[This question was originally a Fill-in-the-Blanks question]

Choices:
- 2
- 4
- 64
- 32


Question: The recurrence relation that arises in relation with the complexity of binary search is:

Choices:
- T(n) = 2T(n/ 2) + k , where k is constant
- T(n) = T(n / 2) + k , where k is constant
- T(n) = T(n / 2) + log n
- T(n) = T(n / 2) + n


Question: Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are inserted in that order into an initially empty binary search tree. The binary search tree uses the reversal ordering on natural numbers i.e. 9 is assumed to be smallest and 0 is assumed to be largest. The in-order traversal of the resultant binary search tree is

Choices:
- 9, 8, 6, 4, 2, 3, 0, 1, 5, 7
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
- 0, 2, 4, 3, 1, 6, 5, 9, 8, 7
- 9, 8, 7, 6, 5, 4, 3, 2, 1, 0


Question:
A data structure is required for storing a set of integers such that each of the following operations can be done in O(log n) time, where n is the number of elements in the set.
I. Deletion of the smallest element
II. Insertion of an element if it is not already present in the set

Which of the following data structures can be used for this purpose?

Choices:
- A heap can be used but not a balanced binary search tree
- A balanced binary search tree can be used but not a heap
- Both balanced binary search tree and heap can be used
- Neither balanced search tree nor heap can be used


Question: Given two Balanced binary search trees, B1 having n elements and B2 having m elements, what is the time complexity of the best known algorithm to merge these trees to form another balanced binary tree containing m+n elements ?

Choices:
- O(m+n)
- O(mlogn)
- O(nlogm)
- O(m2 + n2)


Question: A program takes as input a balanced binary search tree with n leaf nodes and computes the value of a function g(x) for each node x. If the cost of computing g(x) is min{no. of leaf-nodes in left-subtree of x, no. of leaf-nodes in right-subtree of x} then the worst-case time complexity of the program is

Choices:
- Θ(n)
- Θ(nLogn)
- Θ(n2)
- Θ(n2log n)


Question: Let G be a simple undirected graph. Let TD be a depth first search tree of G. Let TB be a breadth first search tree of G. Consider the following statements. (I) No edge of G is a cross edge with respect to TD. (A cross edge in G is between two nodes neither of which is an ancestor of the other in TD). (II) For every edge (u, v) of G, if u is at depth i and v is at depth j in TB, then ∣i − j∣ = 1. Which of the statements above must necessarily be true?

Choices:
- I only
- II only
- Both I and II
- Neither I nor II


Question: Which of the following data structure is useful in traversing a given graph by breadth first search?

Choices:
- Stack
- List
- Queue
- None of the above.


Question: Let H be a binary min-heap consisting of n elements implemented as an array. What is the worst case time complexity of an optimal algorithm to find the maximum element in H?

Choices:
- Θ(1)
- Θ(logn)
- Θ(n)
- Θ(nlogn)


Question: Let G be a simple graph with 20 vertices and 8 components. If we delete a vertex in G, then number of components in G should lie between ____.

Choices:
- 8 and 20
- 8 and 19
- 7 and 19
- 7 and 20


Question: You are given a graph containing n vertices and m edges and given that the graph doesn’t contain cycle of odd length. Time Complexity of the best known algorithm to find out whether the graph is bipartite or not is ?

Choices:
- O(m+n)
- O(1)
- O(mn)
- O(n2)


Question: Consider a directed graph with n vertices and m edges such that all edges have same edge weights. Find the complexity of the best known algorithm to compute the minimum spanning tree of the graph?

Choices:
- O(m+n)
- O(m logn)
- O(mn)
- O(n logm)


Question: For the undirected, weighted graph given below, which of the following sequences of edges represents a correct execution of Prim\'s algorithm to construct a Minimum Spanning Tree?

Choices:
- (a, b), (d, f), (f, c), (g, i), (d, a), (g, h), (c, e), (f, h)
- (c, e), (c, f), (f, d), (d, a), (a, b), (g, h), (h, f), (g, i)
- (d, f), (f, c), (d, a), (a, b), (c, e), (f, h), (g, h), (g, i)
- (h, g), (g, i), (h, f), (f, c), (f, d), (d, a), (a, b), (c, e)


Question:
A Binary Search Tree (BST) stores values in the range 37 to 573. Consider the following sequence of keys.
I. 81, 537, 102, 439, 285, 376, 305
 II. 52, 97, 121, 195, 242, 381, 472
 III. 142, 248, 520, 386, 345, 270, 307
 IV. 550, 149, 507, 395, 463, 402, 270
Which of the following statements is TRUE?

Choices:
- I, II and IV are inorder sequences of three different BSTs
- I is a preorder sequence of some BST with 439 as the root
- II is an inorder sequence of some BST where 121 is the root and 52 is a leaf
- IV is a postorder sequence of some BST with 149 as the root


Question:
A Binary Search Tree (BST) stores values in the range 37 to 573. Consider the following sequence of keys.
I.  81, 537, 102, 439, 285, 376, 305
II. 52, 97, 121, 195, 242, 381, 472
III. 142, 248, 520, 386, 345, 270, 307
IV. 550, 149, 507, 395, 463, 402, 270
 Suppose the BST has been unsuccessfully searched for key 273. Which all of the above sequences list nodes in the order in which we could have encountered them in the search?

Choices:
- II and III only
- I and III only
- III and IV only
- III only


Question: Suppose that we have numbers between 1 and 100 in a binary search tree and want to search for the number 55. Which of the following sequences CANNOT be the sequence of nodes examined?

Choices:
- {10, 75, 64, 43, 60, 57, 55}
- {90, 12, 68, 34, 62, 45, 55}
- {9, 85, 47, 68, 43, 57, 55}
- {79, 14, 72, 56, 16, 53, 55}


Question: Let G be the graph with 100 vertices numbered 1 to 100. Two vertices i and j are adjacent if |i−j|=8 or |i−j|=12. The number of connected components in G is

Choices:
- 8
- 4
- 12
- 25


Question: An A* algorithm is a heuristic search technique which

Choices:
- is like a depth-first search where most promising child is selected for expansion
- generates all successor nodes and computes an estimate of distance (cost) from start node to a goal node through each of the successors. It then chooses the successor with shortest cost
- saves all path lengths (costs) from start node to all generated nodes and chooses shortest path for further expansion.
- none of the above


Question:
Match the following and choose the correct answer for the order A, B, C, D

  A. Strassen matrix multiplication p. Decrease and Conquer   B. Insertion sort q. Dynamic Programming   C. Guassian Elimination r. Divide and Conquer   D. Floyd shortest path algorithm s. Transform and Conquer

Choices:
- r, s, p, q
- r, p, s, q
- q, s, p, r
- s, p, q, r


Question: RAID configurations of disks are used to provide

Choices:
- Fault-tolerance
- High speed
- High data density
- None of the above


Question: The backtracking algorithm is implemented by constructing a tree of choices known as?

Choices:
- State-chart-tree
- Node tree
- Backtracking tree
- State-space tree


Question: Who coined the term "Backtracking"?

Choices:
- Lehmer
- Donald
- Ross
- Ford


Question: Backtracking involves:

Choices:
- Starting from the end of the problem
- Using a stack to keep track of solutions
- Iterating through all elements in a list
- Going back to a previous step if the current step doesn't work


Question: Which of the following is NOT a characteristic of the backtracking algorithm?

Choices:
- Recursive approach
- Breadth-first exploration
- Depth-first exploration
- Trial and error


Question: Which of the following is an example of a problem that can be solved using backtracking?

Choices:
- Finding the median of an array
- Binary search in a sorted list
- Sudoku puzzle solving
- Calculating the sum of elements in an array


Question: Backtracking is best suited for solving problems that involve:

Choices:
- Sorting elements
- Searching in a sorted list
- Dynamic programming
- Exploring all possible solutions


Question: Backtracking may lead to a solution that is:

Choices:
- Optimal
- Suboptimal
- Efficient
- Deterministic


Question: A complete n-ary tree is a tree in which each node has n children or no children. Let I be the number of internal nodes and L be the number of leaves in a complete n-ary tree. If L = 41, and I = 10, what is the value of n?

Choices:
- 6
- 3
- 4
- 5


Question: Backtracking can be used to solve:

Choices:
- Linear programming problems
- Problems with a single feasible solution
- Combinatorial optimization problems
- Problems with a fixed set of solutions


Question: A weight-balanced tree is a binary tree in which for each node. The number of nodes in the left sub tree is at least half and at most twice the number of nodes in the right sub tree. The maximum possible height (number of nodes on the path from the root to the farthest leaf) of such a tree on n nodes is best described by which of the following? a) \\log_2 n b) \\log_{4/3} n c) \\log_3 n d) \\log_{3/2} n

Choices:
- A
- B
- C
- D


Question: The number of leaf nodes in a rooted tree of n nodes, with each node having 0 or 3 children is:

Choices:
- n/2
- (n-1)/3
- (n-1)/2
- (2n+1)/3


Question: The maximum number of binary trees that can be formed with three unlabelled nodes is:

Choices:
- 1
- 5
- 4
- 3


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

Choices:
- nk
- (n – 1) k+ 1
- n( k – 1) + 1
- n(k – 1)


Question:
Level of a node is distance from root to that node. For example, level of root is 1 and levels of left and right children of root is 2. The maximum number of nodes on level i of a binary tree is

In the following answers, the operator \'^\' indicates power.

Choices:
- 2^(i-1)
- 2^i
- 2^(i+1)
- 2^[(i+1)/2]


Question: What are the main applications of tree data structure?Manipulate hierarchical data Make information easy to search  Manipulate sorted lists of data Router algorithms Form of a multi-stage decision-making, like Chess Game. As a workflow for compositing digital images for visual effects

Choices:
- 1, 2, 3, 4 and 6
- 1, 2, 3, 4 and 5
- 1, 3, 4, 5 and 6
- 1, 2, 3, 4, 5 and 6


Question: If arity of operators is fixed, then which of the following notations can be used to parse expressions without parentheses? a) Infix Notation (Inorder traversal of a expression tree) b) Postfix Notation (Postorder traversal of a expression tree) c) Prefix Notation (Preorder traversal of a expression tree)

Choices:
- b and c
- Only b
- a, b and c
- None of them


Question: Which of the following is not a backtracking algorithm?

Choices:
- Knight tour problem
- N queen problem
- Tower of hanoi
- M coloring problem


Question: Which of the following is TRUE?

Choices:
- The cost of searching an AVL tree is θ (log n) but that of a binary search tree is O(n)
- The cost of searching an AVL tree is θ (log n) but that of a complete binary tree is θ (n log n)
- The cost of searching a binary search tree is O (log n ) but that of an AVL tree is θ(n)
- The cost of searching an AVL tree is θ (n log n) but that of a binary search tree is O(n)


Question: The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height h is:

Choices:
- 2^h -1
- 2^(h-1) – 1
- 2^(h+1) -1
- 2*(h+1)


Question: We use dynamic programming approach when

Choices:
- We need an optimal solution
- The solution has optimal substructure
- The given problem can be reduced to the 3-SAT problem
- It\'s faster than Greedy


Question: The number of tokens in the Fortran statement DO 10  I= 1.25 is

Choices:
- 3
- 4
- 5
- None of above


Question:
Suppose c = 〈c[0], ... , c[k – 1]〉 is an array of length k, where all the entries are from the set {0, 1}. For any positive integers a and n, consider the following pseudocode.

DOSOMETHING (c, a, n)
z ← 1
for i ← 0 to k – 1
    do z ← z2 mod n
    if c[i] = 1
       then z ← (z × a) mod n
return z

If k = 4, c = 〈1, 0, 1, 1〉, a = 2 and n = 8, then the output of DOSOMETHING(c, a, n) is ____________.

Choices:
- 0
- 1
- 2
- 3


Question:
Given below are some algorithms, and some algorithm design paradigms.
List-I
A. Dijkstra’s Shortest Path
B. Floyd-Warshall algorithm to compute all pairs shortest path
C. Binary search on a sorted array
D. Backtracking search on a graph

List-II
1. Divide and Conquer
2. Dynamic Programming
3. Greedy design
4. Depth-first search
5. Breadth-first search

Match the above algorithms on the left to the corresponding design paradigm they follow

Codes:
    A B C D
(a) 1 3 1 5
(b) 3 3 1 5
(c) 3 2 1 4
(d) 3 2 1 5

Choices:
- a
- b
- c
- d


Question: Let an represent the number of bit strings of length n containing two consecutive 1s. What is the recurrence relation for an?

Choices:
- an–2 + an–1 + 2n–2
- an–2 + 2an–1 + 2n–2
- 2an–2 + an–1 + 2n–2
- 2an–2 + 2an–1 + 2n–2


Question:
Match the followingList-I
A. Prim’s algorithm for minimum spanning tree
B. Floyd-Warshall algorithm for all pairs shortest paths
C. Mergesort
D. Hamiltonian circuit
List-II
1. Backtracking
2. Greedy method
3. Dynamic programming
4. Divide and conquer
Codes:
    A B C D
(a) 3 2 4 1
(b) 1 2 4 3
(c) 2 3 4 1
(d) 2 1 3 4

Choices:
- a
- b
- c
- d


Question: Consider two strings A = "qpqrr" and B = "pqprqrp". Let x be the length of the longest common subsequence (not necessarily contiguous) between A and B and let y be the number of such longest common subsequences between A and B. Then x + 10y = ___.

Choices:
- 33
- 23
- 43
- 34


Question: Consider the weights and values of items listed below. Note that there is only one unit of each item.QuestionThe task is to pick a subset of these items such that their total weight is no more than 11 Kgs and their total value is maximized. Moreover, no item may be split. The total value of items picked by an optimal algorithm is denoted by Vopt. A greedy algorithm sorts the items by their value-to-weight ratios in descending order and packs them greedily, starting from the first item in the ordered list. The total value of items picked by the greedy algorithm is denoted by Vgreedy. The value of Vopt − Vgreedy is ______ .

Choices:
- 16
- 8
- 44
- 60


Question: What happens when the backtracking algorithm reaches a complete solution?

Choices:
- It backtracks to the root
- It traverses from a different route
- it continues searching for other possible solutions
- Recursively traverses through the same route


Question:
The following paradigm can be used to find the solution of the problem in minimum time:
Given a set of non-negative integer, and a value K, determine if there is a subset of the given set with sum equal to K:

Choices:
- Divide and Conquer
- Dynamic Programming
- Greedy Algorithm
- Branch and Bound


Question: Let A1, A2, A3, and A4 be four matrices of dimensions 10 x 5, 5 x 20, 20 x 10, and 10 x 5, respectively. The minimum number of scalar multiplications required to find the product A1A2A3A4 using the basic matrix multiplication method is

Choices:
- 1500
- 2000
- 500
- 100