Searching & Sorting Algorithms
262 past exam problems with worked solutions.
Practise them on GATE DA →
Asymptotic Analysis & Recurrences
- UGC-NET Dec 2012: Let T(n) be a function defined by T(n) =1 and T(n)=2T (n/2) + √(n), which of the following is true?
- UGC-NET Jun 2014: Big- O estimates for the factorial function and the logarithm of the factorial function i.e. n! and log n! is given by
- UGC-NET Jun 2014: An algorithm is made up of 2 modules M_1 and M_2. If time complexity of modules M_1 and M_2 are h(n) and g(n)…
- UGC-NET Dec 2012: Suppose there are lceil log nrceil sorted lists of lfloor n/log nrfloor elements each. The time complexity of…
- UGC-NET Sep 2013: The time complexity of reccurence relation T(n) = T(n/3) + T(2n/3) +O(n) is
- UGC-NET Dec 2012: The time complexities of some standard graph algorithms are given. Match each algorithm with its time complexity? ( n…
- UGC-NET Dec 2014: Match the following: List – I List – II; a. Bucket sort i. O(n^3lg n); b. Matrix chain multiplication ii. O(n^3); c.…
- UGC-NET Oct 2020: If algorithm A and another algorithm B take log_2 n and √(n) microseconds, respectively, to solve a problem of size n,…
- UGC-NET Sep 2013: The time complexity of an efficient algorithm to find the longest monotonically increasing subsequence of n numbers is
- UGC-NET Jun 2012: The post order traversal of a binary tree is DEBFCA. Find out the pre-order traversal
- UGC-NET Oct 2020: Given below are two statements: Statement I: A genetic algorithm is a stochastic hill-climbing search in which a large…
- UGC-NET Dec 2015: In Activity-Selection problem, each activity i has a start time s_i and a finish time f_i where s_i ≤ f_i. Activities…
- UGC-NET Jan 2017: Which of the following is true for computation time in insertion, deletion and finding maximum and minimum element in…
- UGC-NET Jul 2016: Let A[1,...,n] be an array of n distinct numbers. If i<j and A[i]>A[j], then the pair (i,j) is called an inversion of…
- UGC-NET Dec 2013: Big-O estimate for f(x)=(x+1) log(x^2 +1) + 3x^2 is given as
- UGC-NET Dec 2013: Let A and B be two n × n matrices. The efficient algorithm to multiply the two matrices has the time complexity
- UGC-NET Jan 2017: The asymptotic upper bound solution of the recurrence relation given by T(n) = 2T ( n/2) +(n)/(lg n) is
- UGC-NET Jun 2014: Given the following equalities: E_1: n^K+∈ + n^K lg n = θ (n^K+∈) for all fixed K and ∈, K ≥ 0 and ∈ >0.…
- UGC-NET Jun 2015: Let f(n) and g(n) be asymptotically non-negative functions. Which of the following is correct?
- UGC-NET Dec 2014: Any decision tree that sorts n elements has height
- UGC-NET Jan 2017: Dijkstra’s algorithm is based on
- UGC-NET Dec 2013: The longest common subsequence of the sequences X=<A, B, C, B, D, A, B> and Y=<B, D, C, A, B, A> has length
- UGC-NET Jul 2016: A triangulation of a polygon is a set of T chords that divide the polygon into disjoint triangles. Every triangulation…
- UGC-NET Jun 2012: The strategy used to reduce the number of tree branches and the number of static evaluations applied in case of a game…
- UGC-NET Jul 2016: Consider a source with symbols A, B, C, D with probabilities 1/2, 1/4, 1/8, 1/8 respectively. What is the average…
- UGC-NET Jun 2015: 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…
- UGC-NET Jun 2014: Consider the fractional knapsack instance n = 4, (p_1, p_2, p_3, p_4) = (10, 10, 12, 18), (w_1, w_2, w_3, w_4) = (2,…
- UGC-NET Sep 2013: Given 0-1 knapsack problem and fractional knapsack problem and the following statements: S_1: 0-1 knapsack is…
- UGC-NET Dec 2015: Given two sequences X and Y: X=langle a, b, c, b, d, a, b rangle Y=langle b, d, c, a, b, a rangle A longest common…
- UGC-NET Dec 2014: Consider the problem of a chain langle A_1, A_2, A_3rangle of three matrices. Suppose that the dimensions of the…
- UGC-NET Jan 2017: The minimum number of scalar multiplication required, for parenthesization of a matrix-chain product whose sequence of…
- UGC-NET Sep 2013: The number of possible paranthesizations of a sequence of n matrices is
- UGC-NET Oct 2020: Match List I with List II With reference to CMM developed by Software Engineering Institute (SEI) List I List II; (A)…
- UGC-NET Dec 2014: We can show that the clique problem is NP -hard by proving that
- UGC-NET Jun 2015: The travelling salesman problem can be solved in
- UGC-NET Dec 2015: For the recurrence relation T(n)≤ Θ(1) if n≤ 80; T(n/5)+T(7n/10+6)+O(n) if n>80 the tightest upper bound on T(n) is
- UGC-NET Dec 2018: The solution of recurrence relation: T(n) = 2T (√(n)) + lg(n) is
- UGC-NET Jun 2014: The solution of the recurrence relation of T(n)=3T(floor (n/4))+n is
- UGC-NET Dec 2011: Which of the following is a bad example of recursion?
- UGC-NET Jan 2017: Red-black trees are one of many search tree schemes that are “balanced” in order to guarantee that basic dynamic-set…
- UGC-NET Oct 2020: Match List I with List II List I List II; (A) Greedy Best-First Search (I) Space complexity is O(d) where; d=depth of…
- UGC-NET Jun 2015: Which of the following statements is true for Branch-and-Bound search?
- UGC-NET Sep 2013: α - β cutoffs are applied to
- UGC-NET Jun 2013: Give as good a big-O estimate as possible for the following functions: (n log n+ n^2)(n^3 +2) and (n! +2^n) (n^3 + log…
- UGC-NET Dec 2012: The number of bit strings of length eight that will either start with a 1 bit or end with two bits 00 shall be
- UGC-NET Jun 2012: Consider the following Pseudo-code segment: k:=0 for i_1:=1 to n for i_2:= 1 to i_1::: for i_m:=1 to i_m-1 k:=k+1 The…
- UGC-NET Jun 2019: Consider the following steps: S_1: Characterize the structure of an optimal solution S_2: Compute the value of an…
- GATE CS 2026 · Set-2: Consider a table T, where the elements T[i][j], 0 ≤ i, j ≤ n, represent the cost of the optimal solutions of different…
- GATE CS 2026 · Set-2: Which of the following can be recurrence relation(s) corresponding to an algorithm with time complexity Θ(n)?
- GATE CS 2026 · Set-2: Consider the following functions, where n is a positive integer. n^1 / 3, log (n), log (n!), 2^log (n) Which one of…
- GATE CS 2026 · Set-1: Consider the following recurrence relations: For all n>1, T_1(n)=4 T_1(n/2)+T_2(n); T_2(n)=5 T_2(n/4)+Θ(log _2 n)…
- GATE CS 2025 · Set-1: Consider the following recurrence relation: T(n) = 2T(n-1) + n2^n for n > 0, T(0) = 1 Which ONE of the following…
- GATE CS 2024 · Set-2: Let T(n) be the recurrence relation defined as follows: T(0)=1,; T(1)=2, text and; T(n)=5 T(n-1)-6 T(n-2) text for n ≥…
- GATE CS 2024 · Set-1: Consider the following recurrence relation: T(n)={ √(n) T(√(n))+n text for n ≥ 1,; 1 text for n=1.. Which one of the…
- GATE CS 2024 · Set-1: Given an integer array of size N, we want to check if the array is sorted (in either ascending or descending order).…
- GATE CS 2023: Consider functions Function 1 and Function 2 expressed in pseudocode as follows: Function 1: while n > 1 do for i = 1…
- GATE CS 2023: Let f and g be functions of natural numbers given by f(n)=n and g(n)=n^2. Which of the following statements is/are TRUE?
- GATE CS 2022: Which one of the following statements is TRUE for all positive functions f(n)?
- GATE CS 2021 · Set-2: For constants a≥ 1 and b gt 1, consider the following recurrence defined on the non-negative integers: T(n) = a · T…
- GATE CS 2021 · Set-2: Consider the string abbccddeee. Each letter in the string must be assigned a binary code satisfying the following…
- GATE CS 2021 · Set-1: Define R_n to be the maximum amount earned by cutting a rod of length n meters into one or more pieces of integer…
- GATE CS 2021 · Set-1: Consider the following recurrence relation. T ( n)={ lcl T(n/2)+T(2n/5)+7n if n > 0; 1 if n=0. Which one of the…
- GATE CS 2021 · Set-1: Consider the following three functions. f_1=10^n f_2=n^log n f_3=n^sqrt n Which one of the following options arranges…
- ISRO 2020: Consider product of three matrices M_1, M_2 and M_3 having w rows and x columns, x rows and y columns, and y rows and…
- ISRO 2020: Huffman tree is constructed for the following data:A,B,C,D,E with frequency 0.17, 0.11, 0.24, 0.33 and 0.15…
- ISRO 2020: The master theorem
- GATE CS 2020: For parameters a and b, both of which are ω(1), T(n)=T(n^1/a)+1, and T(b)=1. Then T(n) is
- GATE CS 2019: There are n unsorted arrays: A_1,A_2,...,A_n. Assume that n is odd. Each of A_1,A_2,...,A_n contains n distinct…
- GATE CS 2019: Consider a sequence of 14 elements: A = [-5, -10, 6, 3, -1, -2, 13, 4, -9, -1, 4, 12, -3, 0]. The sequence sum…
- ISRO 2018: The running time of an algorithm is given by: T(n)={ T(n-1)+T(n-2)-T(n-3), text if n>3; n, otherwise. Then what should…
- GATE CS 2018: Consider the weights and values of items listed below. Note that there is only one unit of each item. hline Item…
- GATE CS 2018: Assume that multiplying a matrix G1 of dimension pxq with another matrix G2 of dimension pxq requires pqr scalar…
- GATE CS 2017 · Set-2: A message is made up entirely of characters from the set X={P,Q,R,S,T}. The table of probabilities for each of the…
- GATE CS 2017 · Set-2: Consider the following C function: int fun(int n) int i, j; for (i = 1; i <= n; i++) for (j = 1; j < n; j += i)…
- GATE CS 2017 · Set-2: Consider the recurrence function T(n)={ 2T(√(n))+1, n gt 2; 2, 0 lt n≤ 2. Then T(n) in terms of θ notation is
- GATE CS 2017 · Set-1: Consider the following functions from positive integers to real numbers: 10,√(n),n, log_2n,100/n. The CORRECT…
- ISRO 2016: Consider the following recurrence: T(n)=2T ( √(n))+1, T(1)=1 Which one of the following is true?
- GATE CS 2016 · Set-2: Let A1,A2,A3, and A4 be four matrices of dimensions 10x5, 5x20, 20x10, and 10x5, respectively. The minimum number of…
- GATE CS 2016 · Set-1: Consider a carry lookahead adder for adding two n-bit integers,built using gates of fan-in at most two. The time to…
- GATE CS 2015 · Set-3: Let f(n)=n and g(n)=n^1+sin n where n is a positive integer. Which of the following statements is/are correct? I.…
- GATE CS 2015 · Set-3: Consider the equality Σ_i=0^ni^3=X and the following choices for X I. Θ (n^4) II. Θ (n^5) III. O (n^5) IV. Ω (n^3) The…
- GATE CS 2015 · Set-2: A Young tableau is a 2D array of integers increasing from left to right and from top to bottom. Any unfilled entries…
- GATE CS 2015 · Set-1: Consider the following C function. int fun1(int n) int i, j, k, p, q = 0; for (i = 1; i < n; ++i) p = 0; for (j = n; j…
- GATE CS 2014 · Set-3: Suppose you want to move from 0 to 100 on the number line. In each step, you either move right by a unit distance or…
- GATE CS 2014 · Set-2: Suppose P, Q, R, S, T are sorted sequences having lengths 20, 24, 30, 35, 50 respectively. They are to be merged into…
- GATE CS 2014 · Set-2: Consider two strings A="qpqrr" and B="pqprqrp". Let x be the length of the longest common subsequence (not necessarily…
- GATE CS 2014 · Set-2: Which one of the following correctly determines the solution of the recurrence relation with T(1) = 1? T(n)=2T(n/2)+logn
- GATE CS 2014 · Set-1: The minimum number of comparisons required to find the minimum and the maximum of 100 numbers is _________________.…
- GATE CS 2013: Consider the following function: int unknown(int n) int i, j, k = 0; for (i = n/2; i <= n; i++) for (j = 2; j <= n; j…
- GATE CS 2012: The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with n discs is
- ISRO 2011: Let T(n) be defined by T(1)=10 and T(n+1)=2n+T(n) for all integers n ≥ 1. Which of the following represents the order…
- GATE CS 2011: Four matrices M1, M2, M3 and M4 are dimensions p x q, q x r, r x s and s x t respectively can be multiplied in several…
- GATE CS 2011: Which of the given options provides the increasing order of asymptotic complexityoffunctions f1, f2, f3 and f4?…
- GATE CS 2011: An algorithm to find the length of the longest monotonically increasing sequence of numbers in an array A[0:n-1] is…
- GATE CS 2010: Two alternative packages A and B are available for processing a database having 10^k records. Package A requires…
- GATE CS 2009: A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We…
- GATE CS 2009: A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We…
- GATE CS 2009: The running time of an algorithm is represented by the following recurrence relation: T(n)={ n n≤ 3; T(n/3)+cn…
- ISRO 2008: Which one of the following algorithm design techniques is used in finding all pairs of shortest distances in a graph?
- GATE IT 2008: When n=2^2 k for some k geqslant 0, the recurrence relation T(n)=√(() 2) T(n / 2)+√(n), T(1)=1 evaluates to:
- GATE IT 2008: Arrange the following functions in increasing asymptotic order: a. n^1/3 b. e^n c. n^7/4 d. n log^9n e. 1.0000001^n
- GATE CS 2008: The subset-sum problem is defined as follows. Given a set of n positive integers, S= a_1,a_2,...,a_n and positive…
- GATE CS 2008: The subset-sum problem is defined as follows. Given a set of n positive integers, S= a_1,a_2,...,a_n and positive…
- GATE CS 2008: Let x_n denote the number of binary strings of length n that contain no consecutive 0s. The value of x_5 is
- GATE CS 2008: Let x_n denote the number of binary strings of length n that contain no consecutive 0s. Which of the following…
- GATE CS 2008: Consider the following C functions: int f1(int n) if (n == 0 || n == 1) return n; else return (2*f1(n-1) + 3*f1(n-2));…
- GATE CS 2008: The subset-sum problem is defined as follows: Given a set S of n positive integers and a positive integer W, determine…
- GATE CS 2008: Consider the following functions: f(n)=2^n g(n)=n! h(n)=n^log n Which of the following statements about the asymptotic…
- ISRO 2007: Consider a job scheduling problem with 4 jobs J_1, J_2, J_3 and J_4 with corresponding deadlines: (d_1, d_2, d_3, d_4)…
- GATE IT 2007: Consider n jobs J_1, J_2 … J_n such that job J_i has execution time t_i and a non-negative integer weight w_i. The…
- GATE IT 2007: Exponentiation is a heavily used operation in public key cryptography. Which of the following options is the tightest…
- GATE CS 2007: Suppose that a robot is placed on the Cartesian plane. At each step it is allowed to move either one unit up or one…
- GATE CS 2007: Suppose that a robot is placed on the Cartesian plane. At each step it is allowed to move either one unit up or one…
- GATE CS 2007: 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…
- GATE CS 2007: 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…
- GATE CS 2007: Consider the following C code segment: int IsPrime(n) int i, n; for (i = 2; i <= sqrt(n); i++) if (n % i == 0)…
- GATE CS 2007: What is the time complexity of the following recursive function? int DoSomething (int n) if (n <= 2) return 1; else…
- GATE CS 2007: 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); How many…
- GATE IT 2006: The characters a to h have the set of frequencies based on the first 8 Fibonacci numbers as follows a:1, b:1, c:2,…
- GATE CS 2006: Consider the following C-program fragment in which i, j,and n are integer variables. for (i = n, j = 0; i > 0; i/=2, j…
- GATE IT 2005: Let T(n) be a function defined by the recurrence T(n) = 2T(n/2) + sqrt n for n ≥ 2 and T(1) = 1 Which of the following…
- GATE CS 2005: We are given 9 tasks T_1, T_2, …, T_9. The execution of each task requires one unit of time, and only one task can be…
- GATE CS 2005: We are given 9 tasks T_1, T_2, …, T_9. The execution of each task requires one unit of time, and only one task can be…
- GATE CS 2005: Consider the following C function: double foo (int n) int i; double sum; if (n == 0) return 1.0; else sum = 0.0; for…
- GATE CS 2005: Consider the following C function: double foo (int n) int i; double sum; if (n == 0) return 1.0; else sum = 0.0; for…
- GATE CS 2005: Suppose T (n) = 2T(n/2) + n, T(0)=T(1)=1 Which one of the following is FALSE?
- GATE CS 2005: The Asymptotic Notation of computing the transitive closure of a binary relation on a set of n elements is known to be:
- GATE IT 2004: Let f(n), g(n) and h(n) be functions defined for positive integers such that f(n) = O(g(n)), g(n) ≠ O(f(n)), g(n) =…
- GATE CS 2004: The recurrence equation T(1) = 1 T(n) = 2T(n - 1) + n, n ≥ 2 evaluates to
- GATE CS 2004: The Asymptotic Notation of the following C function is (assume n gt 0) int recursive (int n) if (n == 1) return (1);…
- GATE CS 2004: Let A[1..n] be an array storing a bit (1 or 0) at each location, and let f(m) be a function whose time complexity is…
- GATE CS 2003: The cube root of a natural number n is defined as the largest natural number m such that m^3≤ n. The complexity of…
- GATE CS 2003: Consider the following recurrence relation T(1)=1 T(n+1)=T(n)+ lfloor √(n+1) rfloor for all n ≥ 1 The value of T( m^2)…
- GATE CS 2003: Consider the following three claims 1. (n+k)^m=ominus (n^m), where k and m are constants 2. 2^n+1=O(2^n) 3.…
- GATE CS 2002: The running time of the following algorithm Procedure A(n) If n ≤ 2 return (1) else return (A( √(n))); is best…
- GATE CS 2002: The solution to the recurrence equation T(2^k)=3T(2^k-1)+1,T(1)=1 is
- GATE CS 2000: Consider the following functions f(n) = 3n^√(n) g(n) = 2^√(n)log_2n h(n) = n! Which of the following is true?
- GATE CS 2000: Let S be a sorted array of n integers. Let T(n) denote the time taken for the most efficient algorithm to determined…
- GATE CS 1999: If T_1 = O(1), give the correct matching for the following pairs: hline text(M) T_n = T_n-1 + n (U) T\_n = O(n); hline…
- GATE CS 1999: The minimum number of record movements required to merge five files A (with 10 records), B (with 20 records), C (with…
- GATE CS 1999: If n is a power of 2, then the minimum number of multiplications needed to compute a^n is
- GATE CS 1997: Let T(n) be the function defined by T(1) =1, T(n) = 2T (lfloor n/2 rfloor) + √(n) for n ≥ 2. Which of the following…
- GATE CS 1996: The recurrence relation T(1) = 2 T(n) = 3T (n/4) +n has the solution T(n) equal to
- GATE CS 2001: Let f (n) =n^2 logn and g(n) = n(logn)^10 be two positive functions of n. Which of the following statements is correct?
- GATE CS 2025 · Set-2: Consider a stack data structure into which we can PUSH and POP records. Assume that each record pushed in the stack…
- GATE CS 2023: Consider the C function foo and the following binary tree. The root holds 10; its left child holds 5 and its right…
- GATE CS 2023: Let A be a priority queue for maintaining a set of elements. Suppose A is implemented using a max-heap data structure.…
- GATE CS 2023: Let SLLdel be a function that deletes a node in a singly-linked list given a pointer to the node and a pointer to the…
- GATE CS 2022: Consider the problem of reversing a singly linked list. For example, the list 1→2→3→4→5→6rightarrowNULL should become…
- GATE CS 2021 · Set-2: Let H be a binary min-heap consisting of n elements implemented as an array. What is the worst case time complexity of…
- GATE CS 2021 · Set-1: A binary search tree T contains n distinct elements. What is the time complexity of picking an element in T that is…
- GATE CS 2020: In a balanced binary search tree with n elements, what is the worst case time complexity of reporting all elements in…
- GATE CS 2020: What is the worst case time complexity of inserting n elements into an empty linked list, if the linked list needs to…
- GATE CS 2020: What is the worst case time complexity of inserting n^2 elements into an AVL-tree with n elements initially?
- GATE CS 2019: Consider the following statements: I. The smallest element in a max-heap is always at a leaf node. II. The second…
- GATE CS 2018: A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer: the…
- GATE CS 2017 · Set-2: A circular queue has been implemented using a single linked list where each node consists of a value and a single…
- ISRO 2016: Access time of the symbolic table will be logarithmic if it is implemented by
- GATE CS 2016 · Set-2: N items are stored in a sorted doubly linked list. For a delete operation, a pointer is provided to the record to be…
- GATE CS 2016 · Set-1: An operator delete(i) for a binary heap data structure is to be designed to delete the item in the i-th node.Assume…
- GATE CS 2016 · Set-1: A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. Which one of…
- GATE CS 2015 · Set-2: Consider a complete binary tree where the left and the right subtrees of the root are max-heaps. The lower bound for…
- GATE CS 2015 · Set-2: An unordered list contains n distinct elements. The number of comparisons to find an element in this list that is…
- GATE CS 2015 · Set-1: An algorithm performs (log N)^1/2 find operations, N insert operations, (log N)^1/2 delete operations, and (log N)^1/2…
- GATE CS 2015 · Set-1: What are the worst-case complexities of insertion and deletion of a key in a binary search tree?
- ISRO 2014: Consider a single linked list where F and L are pointers to the first and last elements respectively of the linked…
- GATE CS 2014 · Set-3: 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…
- GATE CS 2014 · Set-1: Consider rooted n node binary tree represented using pointers. The best upper bound on the time required to determine…
- GATE CS 2013: Consider the following operation along with Enqueue and Dequeue operations on queues, where k is a global parameter.…
- GATE CS 2013: Which one of the following is the tightest upper bound that represents the time complexity of inserting an object into…
- GATE CS 2012: The worst case running time to search for an element in a balanced binary search tree with n2^n elements is
- ISRO 2011: The average depth of a binary search tree is
- GATE CS 2003: Let T(n) be the number of different binary search trees on n distinct elements. Then T(n)=Σ_k=1^nT(k-1)T(x), where x is
- GATE CS 1997: The concatenation of two lists is to be performed on O(1) time. Which of the following implementations of a list…
- Curated: Consider an array of n integer with all numbers are repeated once except one number. Example: array of size 7 as…
Divide & Conquer: Mergesort
- UGC-NET Jun 2015: Which of the following is asymptotically smaller?
- UGC-NET Sep 2013: The amortized time complexity to perform ____ operation(s) in Splay trees is O(Ig n)
- UGC-NET Dec 2018: Consider a singly linked list. What is the worst case time complexity of the best-known algorithm to delete the node…
- UGC-NET Jan 2017: Match the following with respect to algorithm paradigms: List-I List-II; a. Merge sort i. Dynamic programming; b.…
- UGC-NET Dec 2004: How much extra space is used by heapsort?
- Curated: Consider the following Python code. c = 0 def msort(a): global c if len(a) <= 1: return a L, R = msort(a[:len(a) //…
Divide & Conquer: Quicksort
- UGC-NET Jul 2016: Match the following: (a) Huffman Code (i) O(n^2); (b) Optical Polygon Triangulation (ii) θ(n^2); (c) Activity…
- Curated: Consider the following Python code (Lomuto partition, last element as pivot). def partition(a, lo, hi): p, i = a[hi],…
- GATE DA 2024: Consider sorting the following array of integers in ascending order using an in-place Quicksort algorithm that uses…
- GATE DA 2026: Consider that the quick sort algorithm is used to sort an array of n distinct randomly ordered elements. In every…
Linear Search & Binary Search
- Curated: Binary search is run on a sorted array of 8 distinct elements. Each comparison checks whether the middle element of…
- UGC-NET Jun 2015: The average case occurs in Linear Search Algorithm when
- GATE DA 2024: Let F(n) denote the maximum number of comparisons made while searching for an entry in a sorted array of size n using…
- GATE DA 2025: For which of the following inputs does binary search take time O(log n) in the worst case?
- GATE DA 2026: Let A be a sorted array containing 1000 distinct integers. You perform a recursive binary search on A to find an…
- GATE DA 2025 · Set 2: For x ∈ ℝ, the floor function is denoted by f(x)=lfloor x rfloor and defined as follows lfloor x rfloor = k, k ≤ x < k…
- ISRO 2007: The time taken by binary search algorithm to search a key in a sorted array of n elements is
- GATE CS 1994: The recurrence relation that arises in relation with the complexity of binary search is:
- GATE CS 2025 · Set-2: An array A of length n with distinct elements is said to be bitonic if there is an index 1 ≤ i ≤ n such that A[1..i]…
- GATE CS 2021 · Set-2: What is the worst-case number of arithmetic operations performed by recursive binary search on a sorted array of size n?
- GATE CS 2017 · Set-1: Let A be an array of 31 numbers consisting of sequence of 0's followed by a sequence of 1's. The problem is to find…
- GATE CS 2007: Consider the process of inserting an element into a Max Heap, where the Max Heap is represented by an array. Suppose…
Heap Sort & Non-Comparison Sorts
- UGC-NET Jun 2014: Mergesort makes two recursive calls. Which statement is true after these two recursive calls finish, but before the…
- UGC-NET Jun 2014: Suppose that the splits at every level of quicksort are in the proportion (1 – α) to α, where 0<α≤1/2 is a constant.…
- UGC-NET Dec 2013: Assuming there are n keys and each key is in the range [0, m-1]. The run time of bucket sort is
- UGC-NET Dec 2015: If there are n integers to sort, each integer had d digits and each digit is in the set {1, 2, …, k}, radix sort can…
- UGC-NET Jun 2019: Which of the following is best running time to sort n integers in the range 0 to n^2-1?
- UGC-NET Sep 2013: Suppose that the splits at every level of Quicksort are in proportion 1-β to β, where 0 < β ≤ 0.5 is a constant. The…
- GATE CS 2026 · Set-2: Consider an array A=[10,7,8,19,41,35,25,31]. Suppose the merge sort algorithm is executed on array A to sort it in…
- GATE CS 2021 · Set-1: Consider the following array. hline 23 32 45 69 72 73 89 97; hline Which algorithm out of the following options uses…
- GATE CS 2019: An array of 25 distinct elements is to be sorted using quicksort. Assume that the pivot element is chosen uniformly at…
- ISRO 2018: Given two sorted list of size m and n respectively. The number of comparisons needed the worst case by the merge sort…
- GATE CS 2006: Which one of the following in-place sorting algorithms needs the minimum number of swaps?
- GATE CS 2017 · Set-2: Match the algorithms with their time complexities: Algorithm Time complexity; (P) Towers of Hanoi with n disks (i)…
- ISRO 2016: Algorithm design technique used in quicksort algorithm is?
- ISRO 2015: If one uses straight two-way merge sort algorithm to sort the following elements in ascending order: 20, 47, 15, 8, 9,…
- ISRO 2015: A machine needs a minimum of 100 sec to sort 1000 names by quick sort. The minimum time needed to sort 100 names will…
- GATE CS 2015 · Set-3: Assume that a mergesort algorithm in the worst case takes 30 seconds for an input of size 64. Which of the following…
- GATE CS 2015 · Set-2: Suppose you are provided with the following function declaration in the C programming language. int partition(int a[…
- GATE CS 2015 · Set-1: Which one of the following is the recurrence equation for the worst case time complexity of the Quicksort algorithm…
- ISRO 2014: Consider the following sorting algorithms. I. Quicksort II. Heapsort III> Mergesort Which of them perform in least…
- GATE CS 2014 · Set-3: You have an array of n elements. Suppose you implement quick sort by always choosing the central element of the array…
- GATE CS 2014 · Set-1: Let P be a quick sort program to sort numbers in ascending order using the first element as the pivot. Let t1 and t2…
- ISRO 2013: Which of the following sorting algorithms has the minimum running time complexity in the best and average case?
- GATE CS 2013: The number of elements that can be sorted in Θ (log n) time using heap sort is
- GATE CS 2012: A list of n strings, each of length n, is sorted into lexicographic order using the merge-sort algorithm. The worst…
- GATE CS 2012: Let W(n) and A(n) denote respectively, the worst case and average case running time of an algorithm executed on an…
- ISRO 2011: Which of the following algorithm design technique is used in merge sort?
- GATE CS 2009: In quick sort, for sorting n elements, the (n/4)th smallest element is selected as pivot using an O(n) time algorithm.…
- GATE IT 2008: If we use Radix Sort with decimal digits (base 10) to sort n integers in the range (n^k/2, n^k], for some k>0 which is…
- GATE CS 2008: Consider the Quicksort algorithm. Suppose there is a procedure for finding a pivot element which splits the list into…
- ISRO 2007: The average case and worst case complexities for Merge sort algorithm are
- GATE CS 2007: Which of the following sorting algorithms has the lowest worst-case complexity?
- GATE CS 2006: The median of n elements can be found in O(n) time. Which one of the following is correct about the complexity of…
- GATE IT 2004: Consider a list of recursive algorithms and a list of recurrence relations as shown below. Each recurrence relation…
- GATE CS 2004: The tightest lower bound on the number of comparisons, in the worst case, for comparison-based sorting is of the order…
- GATE CS 1999: A sorting technique is called stable if
- GATE CS 1996: Quick-sort is run on two inputs shown below to sort in ascending order taking first element as pivot (i). 1, 2, 3, … n…
- GATE CS 1995: Merge sort uses:
- GATE CS 2001: Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case…
- GATE CS 1992: Choose the correct alternatives (more than one may be correct) and write the corresponding letters only: Following…
- GATE CS 1990: Choose the correct alternatives (More than one may be correct). The complexity of comparision based sorting algorithms…
- GATE CS 1987: Let P be a quicksort program to sort numbers in ascending order. Let t_1 and t_2 be the time taken by the program for…
- GATE CS 1995: Which of the following statements is true? I. As the number of entries in a hash table increases, the number of…
- Curated: Merge sort divides an array into two halves, sorts them recursively and merges them. Its running time on n elements in…
Selection Sort
- UGC-NET Dec 2014: You have to sort a list L, consisting of a sorted list followed by a few ‘random’ elements. Which of the following…
- UGC-NET Dec 2015: An ideal sort is an in-place-sort whose additional space requirement is
- GATE DA 2024: Consider the following sorting algorithms: (i) Bubble sort (ii) Insertion sort (iii) Selection sort Which ONE among…
- ISRO 2020: Of the following sorting algorithms, which one runs in Θ(nlog n) time whatever the initial ordering of the input?
- ISRO 2018: Of the following sorting algorithms, which one has a running time of Θ(nlog n) for every initial ordering of the input?
- GATE CS 2013: Which one of the following is the tightest upper bound that represents the number of swaps required to sort n numbers…
- GATE CS 2009: What is the number of swaps required to sort n elements using selection sort, in the worst case?
- ISRO 2008: How many comparisons are needed to sort an array of length 5 if a straight selection sort is used and array is already…
- ISRO 2007: Selection sort algorithm design technique is an example of
- GATE CS 1998: Give the correct matching for the following pairs: hline (A) O (log n) (P) Selection sort; hline (B) O (n) (Q)…
- Curated: What could be the best algorithm from the following when the time complexity is measured based on the number of swaps…
Insertion Sort
- GATE DA 2025: Suppose that insertion sort is applied to the array [1, 3, 5, 7, 9, 11, x, 15, 13] and it takes exactly two swaps to…
- GATE CS 2016 · Set-2: Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in…
- GATE CS 2016 · Set-1: The worst case running times of Insertion sort, Mergesort and Quicksort, respectively, are:
- GATE CS 2003: In a permutation a_1.....a_n of n distinct integers, an inversion is a pair (a_i, a_j) such that i lt j and a_i gt…
- GATE CS 2003: The usual Θ (n^2) implementation of Insertion Sort to sort ab array uses linear search to identify the position where…
- ISRO 2020: If an array A contains the items 10, 4, 7, 23, 67, 12 and 5 in that order, what will be the resultant array A after…
- Curated: Consider a modification of the insertion sort algorithm, which performs a binary search instead of sequential to find…
Bubble Sort
- GATE DA 2026: Consider the problem of sorting the given array in ascending order: P=[1,2,3,5,4] Consider two sorting algorithms…
- GATE DA 2026: Consider the given Python program. def fun(L, i=0): if i >= len(L)-1: return 0 if L[i] > L[i+1]: L[i+1], L[i] = L[i],…
- ISRO 2017: The number of swappings needed to sort the numbers 8, 22, 7, 9, 31, 5, 13 in ascending order using bubble sort is
- Curated: Suppose the given array of size n is sorted other than first 10 element and last 50 elements. Find the sorting…
GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com