GATE CS Searching, Sorting, Hashing questions
Practise Searching, Sorting, Hashing questions for GATE CS. Explore official PYQs and original topic-wise quizzes, check answers and view available solutions. Free, no sign-in.
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
The median of elements can be found in time. Which one of the following is correct about the complexity of quick sort, in which median is selected as pivot?
Which one of the following in place sorting algorithms needs the minimum number of swaps?
Suppose there are sorted lists of elements each. The time complexity of producing a sorted list of all these elements is: (Hint:Use a heap data structure)
The tightest lower bound on the number of comparisons, in the worst case, for comparison-based sorting is of the order of
In a permutation , of distinct integers, an inversion is a pair such that and What would be the worst case time complexity of the Insertion Sort algorithm, if the inputs are restricted to permutations of with at most inversions?
In a permutation , of n distinct integers, an inversion is a pair such that and . If all permutations are equally likely, what is the expected number of inversions in a randomly chosen permutation of ?
The usual implementation of Insertion Sort to sort an array uses linear search to identify the position where an element is to be inserted into the already sorted part of the array. If, instead, we use binary search to identify the position, the worst case running time will
Consider the following algorithm for searching for a given number in an unsorted array having distinct values: Choose an at random from If , then Stop else Goto 1; Assuming that is present in , what is the expected number of comparisons made by the algorithm before it terminates?
Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case complexity of sorting n numbers using Randomized quicksort?
If one uses straight two-way merge sort algorithm to sort the following elements in ascending order: then the order of these elements after second pass of the algorithm is:
A sorting technique is called stable if
Give the correct matching for the following pairs: …
Quick-sort is run on two inputs shown below to sort in ascending order taking first element as pivot Let and be the number of comparisons made for the inputs (i) and (ii) respectively. Then,
The average number of key comparisons required for a successful search for sequential search on items is
For merging two sorted lists of sizes and into a sorted list of size , we require comparisons of
Merge sort uses:
Algorithm design technique used in quicksort algorithm is?
Following algorithm(s) can be used to sort in the range in time
The minimum number of comparisons required to sort elements is ______
The complexity of comparison based sorting algorithms is:
