Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b4HkWoC7hLzk61vZa8
13 lines
617 B
Plaintext
13 lines
617 B
Plaintext
Problem 6: merge k sorted lists
|
|
===============================
|
|
|
|
[1,4,5] [1,3,4] [2,6] [] -> [1, 1, 2, 3, 4, 4, 5, 6]
|
|
offering the head of an empty list (null) without the check: NullPointerException
|
|
|
|
comparisons, each list holding 1,000 random values (seed 5):
|
|
k N heap of heads merge one by one merge in pairs
|
|
2 2,000 1,998 1,998 1,998
|
|
10 10,000 61,857 53,944 35,983
|
|
100 100,000 1,270,358 5,045,132 687,813
|
|
1,000 1,000,000 18,739,107 500,034,011 9,982,020
|