A developer compares three sorting implementations using the guarantees below. All space bounds include active function calls. Which statements follow from the information provided? Select every correct statement.
Implementation
Stable
Worst-case time bound
Auxiliary space
A
Yes
O(n2)O(n^2)O(n2)
O(1)O(1)O(1)
B
O(nlogn)O(n\log n)O(nlogn)
O(n)O(n)O(n)
C
No
O(logn)O(\log n)O(logn)
B's stable classification guarantees that its total running time is linear.
A meets both a stability requirement and a constant-auxiliary-space requirement.
C can change the relative order of records whose sort keys are equal.
B is guaranteed to finish faster than A for every possible input size.
Unlock full course notes by signing up
Finding the input limit from total memory
A record-sorting service has a total memory budget of 1000000 bytes. Its input occupies 24n24n24n bytes for nnn records. During sorting, an auxiliary buffer occupies another 8n8n8n bytes and a fixed stack occupies 4096 bytes. All three allocations are live simultaneously, and no other memory is charged to this budget. What is the maximum number of records that fit? Answer in records, as an integer with zero decimal places.
Tracing two stable sorting passes
A dispatch system uses a stable sort, which preserves the incoming relative order of records with equal values of the key used in that pass. The records initially appear in this order:
The system first sorts stably by priority in ascending order. It then sorts that result stably by region, placing North before South.
Complete the table with each record's position after the first pass and after the second pass. Use exact integers from 1 to 5, with position 1 at the beginning of the sequence.
Resolving competing sorting constraints
A scheduling service must preserve arrival order among records with equal priority. It permits batch sizes of only 256, 512, or 1024 records. Its policy accepts an implementation only if its documented worst-case operation bound is at most 500000 operations and its auxiliary-memory requirement is at most 9000 bytes.
For this planning problem, use the following bounds exactly. They include all auxiliary allocations; input storage is funded separately.
Find the largest permitted batch size that meets every requirement. Then find the smallest increase in the auxiliary-memory limit that would permit a batch of 1024 records while keeping the other requirements unchanged. Give the batch size in records and the increase in bytes, both as exact integers.
Counting the information a sorter needs
A deterministic comparison sort determines record order solely by comparing pairs of keys. A warehouse uses this model to sort six labelled parcels by mass. Their masses are initially unknown, all six masses are distinct, and every relative mass ordering of the parcels is possible. Each comparison reports either less than or greater than.
You may use the fact that a method making at most ccc comparisons on every input can distinguish at most 2c2^c2c possible input orders.
Find the number of possible relative mass orders and the strongest integer lower bound on worst-case comparisons obtained from this counting argument. Enter both as exact integers. Also enter true or false: does this counting argument alone guarantee that a sorting method achieving that bound exists?