Heapsort:Sort With a Heap When You Need O(n log n) and Little Extra Memory
Build a max-heap and extract the max into the tail — guaranteed O(n log n), little extra memory, and why PriorityQueue poll-all is not this procedure.
Read MoreBrowse the full archive. Use topics in the sidebar to explore by tag.
Build a max-heap and extract the max into the tail — guaranteed O(n log n), little extra memory, and why PriorityQueue poll-all is not this procedure.
Read MoreUse Collections and Arrays for sort, binarySearch, shuffle, nCopies, emptyXxx, synchronized wrappers, and asList — the static methods around the types, not a fourth List implementation.
Read MorePartition around a pivot and recurse — and why last-element vs random vs median-of-three vs dual-pivot is the algorithm, not textbook Lomuto as Arrays.sort.
Read MoreUse List.of, Set.of, Map.of, and copyOf for unmodifiable collections that reject nulls — Java 9 factories, not Collections.unmodifiableList wrapping a live ArrayList.
Read MoreHands-on sudo and sudoers recipes — run commands as root or another user, edit policy safely with visudo, and delegate fine-grained privileges without handing out full root.
Read MoreSplit, sort the halves, merge two sorted runs — why the extra array buys a guaranteed O(n log n) bound and stability, and what object Arrays.sort actually runs.
Read MoreInsertion still earns a seat on small or nearly-sorted ranges; selection swaps the min into place; bubble is a whiteboard name — none of them are the production default.
Read MoreUse IdentityHashMap when keys are compared with ==, and WeakHashMap when the GC should drop entries whose keys are otherwise unreachable — two unusual maps, two different jobs.
Read MoreUse EnumSet and EnumMap when the key universe is an enum — a bit vector and an ordinal array, not a hash table.
Read MoreSort by start, sweep, and merge overlapping calendar or busy ranges — and when this is not interval scheduling.
Read More