[理工] 演算法

看板Grad-ProbAsk作者 (東京熱死胖子)時間11年前 (2012/11/13 23:05), 編輯推噓2(205)
留言7則, 3人參與, 最新討論串2/11 (看更多)
各位大大好,第一次來這邊問問題,以後請多指教:> Suppose that we are given a sequence of n unsorted values, say x1,x2,..., xn, and at the same time, we are asked to qucikly answer repeated queries defined as follows: Given i and j, where 1<=i<j<=n, find the smallest value in xi, xi+1,....,xj. (a) Please design a data structure that uses O(n^2) space and answers the queries in O(1) time. (b) Please design a data structure that uses O(n) space and answers the queries in O(logn) time. 以上,求解,感恩 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.123.237.64 ※ 編輯: TokiyoHot 來自: 140.123.237.64 (11/13 23:11)

11/13 23:29, , 1F
a.建A=n*n矩陣,A(i,j)=smallest value in xi, xi+1,....,xj
11/13 23:29, 1F

11/13 23:33, , 2F
b.建BST,找最小in xi, xi+1,....,xj則坐中序追蹤,直到找到xt
11/13 23:33, 2F

11/13 23:33, , 3F
存在滿足i<=t<=j
11/13 23:33, 3F

11/14 00:34, , 4F
這是哪裡的考題阿?
11/14 00:34, 4F

11/14 00:35, , 5F
中序追蹤不一定可以在O(lg n)的時間內做完..
11/14 00:35, 5F

11/16 23:24, , 6F
喔~抱歉這幾天比較忙.. 這是交大生資的考題
11/16 23:24, 6F

11/16 23:27, , 7F
ddczx大大我看不太懂您的解法...
11/16 23:27, 7F
文章代碼(AID): #1Gec6af7 (Grad-ProbAsk)
討論串 (同標題文章)
文章代碼(AID): #1Gec6af7 (Grad-ProbAsk)