Data Structures & AlgorithmsHard

What is the largest difference between two CONSECUTIVE values after sorting 3 6 9 1 2 15 in ascending order?

  1. A. 6
  2. B. 14
  3. C. 5
  4. D. 7

Correct answer: A. 6

Sorting places each consecutive pair next to each other, so the maximum gap is the largest of the n−1 adjacent differences. The overall range or the wrong neighbouring pair gives different values.

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

Exams that ask this topic