Algorithm Analysis (CSC 301 2015F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning]
Current: [Outline] [EBoard] [Reading] [Lab] [Assignment]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Readings]
Reference: [Algorist]
Related Courses: [Walker (2014F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker]
Overview
Is this Sam's normal: "Use any reasonable resource, but no posting questions?"
Yes.
Lower Bounds on Comparison-Based Sorting
n! leaves = Theta(2^(nlogn))
Weak proof by induction:
Base cases: n = 1, n = 2
Inductive cases:
Proof by Authority: According to famous people like Knuth, n! =~ 2^(nlogn)
The tree has 2^(nlogn) leaves. The minimum height of a tree with k leaves is log(k). So, the tree has minimum height log(2^(nlogn)) = nlogn.
Key ideas:
Turn the array into a heap by calling swap-up from postions 1 to n-1
for k = n-1 down to 1
swap(A, 0, k)
swapDown(A, 0)
This requires us to be able to identify the indices of children and parent
left child of value at position k: 2k+1
right child of value at position k: 2k+2
parent of value at position k: floor((k-1)/2)