How arrival order changes comparison costs

A registration audit processes eight records. The client identifiers are 114, 208, 351 and 476, with each identifier appearing exactly twice. The records may arrive in any order.


For each incoming record, the algorithm scans all previously processed records from earliest to latest. Each equality check between two identifiers contributes one to the operation count, the total number of checks performed.


The scan stops at the first matching identifier or after checking every previous record. When a match is found, only the inner scan stops; processing continues with the remaining incoming records. After its scan, every incoming record is appended to the processed list, including duplicates. The first record requires no comparisons.


Across all possible arrival orders of these same eight records, find the minimum total comparison count and the maximum total comparison count. Enter exact integers, measured in identifier comparisons.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Data Algorithms Questions: