首页 > 代码库 > CC150 20.6
CC150 20.6
20.6 Describe an algorithm to find the largest 1 million numbers in 1 billion numbers. Assume that the computer memory can hold all one billion numbers.
// can hold all numbers. // Cheating! // Do we know the max or min? // Consider using bitmap // If 1 billion numbers also spread a lot. // 1. Hash-split into K smaller pieces. Just % n. Thinking about how to handle negative numbers. // Dealing with the small files. // Maintain a min heap with 1 million. (so said) // Random select K as pivok. // Track numbers bigger than K. // If # > 1m, pivot right, to find 1m // else, pivot left, (1m - #)
CC150 20.6
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。