Educational Cards
Learn from video content, text, and interactive tasks
Filters
synchronized and monitors
synchronized in Java locks a monitor (object). Only one thread holds the lock. Visibility and...
Merge Sort
Merge Sort divides the array, sorts recursively, and merges two sorted halves. Time Theta(n log n),...
Quicksort Idea
Quicksort chooses a pivot, partitions into smaller/larger, and recursively sorts the sides....
Arrays.sort in Java
Arrays.sort: primitive types use Dual-Pivot Quicksort; objects use TimSort (merge-based, stable)....
Implementation: Hoare/Lomuto-light Partition
Implement a simple Lomuto partition using the last element as the pivot. | Variant | Return value |...
Partition
Partition arranges the subarray so that elements <= Pivot are on the left and elements >=...
Lower Bound Comparison Sorting
Every comparison-based sorter requires at least logarithmically many comparisons relative to n! in...
Insertion Sort
Insertion Sort builds a sorted prefix and inserts the next element in the correct position...
Stability
A sorter is stable if equal keys maintain their relative order. Insertion Sort is stable; Selection...
When simple sorters
Simple algorithms are worthwhile for small n, for teaching purposes, and as a base case in hybrids...
Comparisons and Swaps
Analyze separately: Comparison (reading) and write/swap costs. Selection Sort: many comparisons,...
Selection Sort
Selection Sort searches for the minimum in the unsorted area and swaps it to the next position....