Data Structures & AlgorithmsHardGATE CS · ICPC regional

Which data structure supports inserting values and reporting the k-th smallest value in O(log n) time each?

  1. A. Order-statistic tree or Fenwick tree over compressed values
  2. B. Plain singly linked list
  3. C. Stack
  4. D. Hash set alone

Correct answer: A. Order-statistic tree or Fenwick tree over compressed values

A Fenwick tree (or order-statistic tree) keeps counts per value and descends to locate the k-th element in logarithmic time. A hash set has no order information.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic