Data Structures & AlgorithmsVery hard

Split 8 3 5 1 9 2 7 4 into consecutive blocks of 4 (positions 0–3 and 4–7). For each block take (max − min), and add these two numbers. What is the total?

  1. A. 15
  2. B. 4
  3. C. 8
  4. D. 14

Correct answer: D. 14

Each block's spread is its largest value minus its smallest, which is independent of the order inside the block. Using the second smallest, or the spread of the whole array, measures different things.

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

Exams that ask this topic