CSC148H1 Lecture Notes - Lecture 11: Timsort, Mersenne Prime, Sorting Algorithm

32 views12 pages
13 Nov 2017
School
Course
Professor
katrinasavvy and 38715 others unlocked
CSC148H1 Full Course Notes
1
CSC148H1 Full Course Notes
Verified Note
1 document

Document Summary

This describes an adaptive, stable, natural mergesort, modestly called timsort (hey, i earned it ). It has supernatural performance on many kinds of partially ordered arrays (less than lg(n!) comparisons needed, and as few as n-1), yet as fast as python"s previous highly tuned samplesort hybrid on random arrays. In a nutshell, the main routine marches over the array once, left to right, alternately identifying the next run, then merging it into the previous runs intelligently. Everything else is complication for speed, and some hard-won measure of memory efficiency. + timsort can require a temp array containing as many as n//2 pointers, which means as many as 2*n extra bytes on 32-bit boxes. It can be expected to require a temp array this large when sorting random data; on data with significant structure, it may get away without using any extra heap memory.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents