Question

An algorithm performs (log⁡N)1/2(\log N)^{1/2} find operations, NN insert operations, (log⁡N)1/2(\log N)^{1/2} delete operations, and (log⁡N)1/2(\log N)^{1/2} decrease-key operations on a set of data items with keys drawn from a linearly ordered set. For a delete operation, a pointer is provided to the record that must be deleted. For the decrease-key operation, a pointer is provided to the record that has its key decreased. Which one of the following data structures is the most suited for the algorithm to use, if the goal is to achieve the best total asymptotic complexity considering all the operations?

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2015 answer key

Solution

Evaluate the cumulative asymptotic complexity across all operations for each candidate data structure.

Given operation counts with k=(log⁡N)1/2k = (\log N)^{1/2}:

  • Find: k=(log⁡N)1/2k = (\log N)^{1/2} operations
  • Insert: NN operations
  • Delete: k=(log⁡N)1/2k = (\log N)^{1/2} operations (record pointer provided)
  • Decrease-Key: k=(log⁡N)1/2k = (\log N)^{1/2} operations (record pointer provided)

Analyzing each data structure:

  1. Unsorted Array:

    • Insert: O(1)  ⟹  N×O(1)=O(N)O(1) \implies N \times O(1) = O(N).
    • Find: O(N)  ⟹  (log⁡N)1/2×O(N)=O(N(log⁡N)1/2)O(N) \implies (\log N)^{1/2} \times O(N) = O(N (\log N)^{1/2}).
    • Delete (with pointer): O(1)O(1) by swapping target element with last element   ⟹  O((log⁡N)1/2)\implies O((\log N)^{1/2}).
    • Decrease-Key (with pointer): O(1)O(1) direct update   ⟹  O((log⁡N)1/2)\implies O((\log N)^{1/2}).
    Total Cost=O(N(log⁡N)1/2).\text{Total Cost} = O(N (\log N)^{1/2}).
  2. Min-Heap:

    • Insert: O(log⁡N)  ⟹  N×O(log⁡N)=O(Nlog⁡N)O(\log N) \implies N \times O(\log N) = O(N \log N).
      Since Nlog⁡N>N(log⁡N)1/2N \log N > N (\log N)^{1/2}, Min-Heap is asymptotically slower.
  3. Sorted Array / Sorted Doubly Linked List:

    • Insert takes O(N)O(N) time, leading to N×O(N)=O(N2)N \times O(N) = O(N^2) total cost, which is strictly worse.

Therefore, the unsorted array achieves the best total asymptotic complexity of O(N(log⁡N)1/2)O(N (\log N)^{1/2}) (option A).

Final answer

A

Common trap

Assuming Min-Heap is always best for priority queue operations without calculating total costs against the given operation counts.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2015 Computer Science and Information Technology (CS) Session 1
Question
50 of 65, printed as CS Q.40
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.