Skip to content

GATE CS Algorithms questions

Practise Algorithms questions for GATE CS. Explore official PYQs and original subject-wise quizzes, check answers and view available solutions. Free, no sign-in.

Compare greedy choices, dynamic-programming states and graph algorithms. Identify the input size before analysing the time and space complexity of each solution.

Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.

20 on this page
Official PYQ1995AlgorithmsMinimum Spanning TreesNAT · 1 mark
How many minimum spanning trees does the following graph have? Draw them. (Weights are assigned to edges).
Official PYQ1995AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
A language with string manipulation facilities uses the following operations head(s): first character of a string tail(s): all but exclude the first character of a string concat(s1, s2): s1s2 For the string "acbcacbc" what will be the output of concat(head(s), head(tail(tail(s))))
Official PYQ1995AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Assume that XX and YY are non-zero positive integers. What does the following Pascal program segment do? while X <> Y do if X > Y then X := X - Y else Y := Y - X; write(X);
Official PYQ1995AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
For merging two sorted lists of sizes mm and nn into a sorted list of size m+nm+n, we require comparisons of
Official PYQ1995AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
In the following Pascal program segment, what is the value of X after the execution of the program segment? X := -10; Y := 20; If X > Y then if X < 0 then X := abs(X) else X := 2*X;
Official PYQ1995AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Merge sort uses:
Official PYQ1994AlgorithmsAsymptotic Worst Case Time and Space ComplexityMSQ · 1 mark
Consider the following two functions: g1(n)={n3 for 0≤n≤10,000n2 for n>10,000g_1(n) = \begin{cases} n^3 \text{ for } 0 \leq n \leq 10,000 \\ n^2 \text{ for } n > 10,000 \end{cases} g2(n)={n for 0≤n≤100n3 for n>100g_2(n) = \begin{cases} n \text{ for } 0 \leq n \leq 100 \\ n^3 \text{ for } n > 100 \end{cases} Which of the following is true?
Official PYQ1994AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
Which of the following statements is false?
Official PYQ1994AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Algorithm design technique used in quicksort algorithm is?
Official PYQ1994AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
The recurrence relation that arises in relation with the complexity of binary search is:
Official PYQ1993AlgorithmsAsymptotic Worst Case Time and Space ComplexityMSQ · 1 mark
∑1≤k≤nO(n)\displaystyle \sum_{1\leq k\leq n} O(n), where O(n)O(n) stands for order nn is:
Official PYQ1993AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
What does the following code do? var a, b: integer; begin a:=a+b; b:=a-b; a:=a-b; end;
Official PYQ1992AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Which of the following problems is not NP\text{NP}-hard?
Official PYQ1992AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Following algorithm(s) can be used to sort nn in the range [1…n3][1\ldots n^3] in O(n)O(n) time
Official PYQ1991AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Consider the following Pascal function: Function X(M:integer):integer; Var i:integer; Begin i := 0; while i*i < M do i:= i+1 X := i end The function call X(N)X(N), if NN is positive, will return
Official PYQ1991AlgorithmsMinimum Spanning TreesMSQ · 1 mark
Kruskal’s algorithm for finding a minimum spanning tree of a weighted graph GG with nn vertices and mm edges has the time complexity of:
Official PYQ1991AlgorithmsSearching, Sorting, HashingNAT · 1 mark
The minimum number of comparisons required to sort 55 elements is ______
Official PYQ1990AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
The complexity of comparison based sorting algorithms is:
Official PYQ1989AlgorithmsAlgorithm Design: Greedy TechniquesNAT · 1 mark
A language uses an alphabet of six letters, {a,b,c,d,e,f}\left\{a, b, c, d, e, f\right\}. The relative frequency of use of each letter of the alphabet in the language is as given below: …
Official PYQ1989AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
A hash table with ten buckets with one slot per bucket is shown in the following figure. The symbols S1S1 to S7S7 initially entered using a hashing function with linear probing. The maximum number of comparisons needed in searching an item that is not present is