[理工] 演算法 排序
1.You are given n bolts of different width and their corresponding nuts.
Each time, you can try one bolt and one nut together and determine
whether the nut is too large, too small or an exact fit.
You cannot compare the width of two bolts or two nuts.
Design an algorithm to match each bolt to its corresponding nut
with average running time O(n log n)
請問這題是類似quick sort的想法嗎?
2.Given n numbers a1,a2,...an Design a liner time algo to find all numbers
that occur more than floor(n/5) times.
目前這題只想到暴力解,但顯然不是出題者要的答案。
希望高手解惑
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.116.62.228
→
10/20 15:05, , 1F
10/20 15:05, 1F
→
10/20 15:07, , 2F
10/20 15:07, 2F
→
10/20 15:08, , 3F
10/20 15:08, 3F
→
10/20 15:19, , 4F
10/20 15:19, 4F
→
10/20 15:22, , 5F
10/20 15:22, 5F
→
10/20 15:24, , 6F
10/20 15:24, 6F
→
10/20 15:25, , 7F
10/20 15:25, 7F
→
10/20 15:25, , 8F
10/20 15:25, 8F
討論串 (同標題文章)