Thursday, December 8, 2016

Merge Sort vs. Bubble Sort

I wrote a program that creates 500,000 random strings and sort them twice, once using Merge Sort, and once using Bubble Sort. The Merge Sort completed almost immediately. The Bubble Sort ran for hours ... I started it before lunch, and it just finished.

I added code to calculate the elapsed time for each sort. The Merge Sort was faster by a factor of 3533.

We can code this project together on Monday night. It's 150 lines of code, so bring your computer and be prepared to type fast.


No comments:

Post a Comment