Decrease and Conquer

Screenshot 2025-02-09 at 4.30.35 PM.png

Insertion Sort

Algorithm InsertionSort(A[0..n-1])
// sorts a given array by insertion sort

	for i <- 1 to n-1 do:
		v <- A[i]
		j <- i-1
		
		while j >= 0 and A[j] > v do:
			A[j+1] <- A[j]
			j <- j-1
		A[j+1] <- v

Topological Sorting