Class: CSE 102 Subject: computer-science Date: 2026-01-07 Teacher: **Prof. Bailey
Sorting
Insertion Sort
def insert_sort(m):
for i in range(2, m): # c1 m
key = A[i] # c2 m - 1
# insert A[i] into sorted A[1: i - 1]
j = i - 1. # c1 m - 1
while j > 0 and A[j] > key:
A[j + 1] = A[j]
j -= 1
A[j + 1] = key
Worst Case
Divide and Conquer
- divide problem into one or more subsequences