码迷,mamicode.com
首页 > 其他好文 > 详细

CC150 9.4

时间:2014-12-05 11:00:30      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:interview

9.4 If you have a 2 GB file with one string per line, which sorting algorithm would you use to sort the file and why?


What are the common sorting algorithms?

http://en.wikipedia.org/wiki/Sorting_algorithm


Merge sort, divide and conquer

Quick sort, using a pivot. all numbers bigger than pivot goes one side.

Insert sort

bubble sort, swap. shell sort.

Heap sort?

...


If a 2 GB file, with one string per line.

Properly using a merge sort with multiple threads. (not spliting to 2 parts, but N parts. And Merge from N.


)

This is because we don‘t need to load the 2GB data into memory all the time.

And multi-threads helps speed up.

CC150 9.4

标签:interview

原文地址:http://7371901.blog.51cto.com/7361901/1586516

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!