Add heap module: array min/max heap with dry runs and bottom-up heapify, PriorityQueue comparators and traps, heap sort, 10 interview problems with brute-force cross-checks (17 tests, 23 transcripts)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b4HkWoC7hLzk61vZa8
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
Problem 7: median of a stream
|
||||
=============================
|
||||
|
||||
add( 5) lower(max-heap)=[5] upper(min-heap)=[] median=5.0
|
||||
add(15) lower(max-heap)=[5] upper(min-heap)=[15] median=10.0
|
||||
add( 1) lower(max-heap)=[1, 5] upper(min-heap)=[15] median=5.0
|
||||
add( 3) lower(max-heap)=[1, 3] upper(min-heap)=[5, 15] median=4.0
|
||||
add( 8) lower(max-heap)=[1, 3, 5] upper(min-heap)=[8, 15] median=5.0
|
||||
add( 7) lower(max-heap)=[1, 3, 5] upper(min-heap)=[7, 8, 15] median=6.0
|
||||
|
||||
values 2147483647 and 2147483645:
|
||||
(a + b) / 2.0 in int arithmetic : -2.0
|
||||
((long) a + b) / 2.0 : 2147483646.0
|
||||
Reference in New Issue
Block a user