[理工] [資結] hash&queue

看板Grad-ProbAsk作者 (小達)時間15年前 (2011/02/07 19:15), 編輯推噓5(5019)
留言24則, 6人參與, 最新討論串1/1
Q1.Suppose we implement a hash with number of buckets=100, denoted as B[0], B[2], B[99]. Let the hash function be h(i) = (i^2 + 1) % 100 . When two or more data are hashed into the same bucket, we use a singly-linked list to store these numbers in the bucket (no probing or rehashing). Let the number of data in bucket 'k' be denoted as "|B[k]|". If we insert in integral data from 1 to 1000 into the hash, which of the following is correct? (A) |B(2)|=10 (B) |B(3)|=0 (C) |B(26)|=100 (D) |B(15)|=15 (D) |B(37)|=40 知道題目在問什麼 但是不知道要怎樣去算出|B[k]| Q2.Use the double-ended queue(dequeue) to input:1,2,3,4,5,6 and 7 sequentially. In the following,what are the impossible outputs? (a)5174236 (b)1234567 (c)2143756 (d)7615243 (e)4213765 這題應該是怎麼選呢 沒有頭緒 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.124.60.24

02/07 19:31, , 1F
第一題在問當我們輸入1-1000後,各個bucket內有幾個個數
02/07 19:31, 1F

02/07 19:33, , 2F
第二題再問當我們把1-7輸入double-ended priority queue
02/07 19:33, 2F

02/07 19:34, , 3F
最後答案會輸出什麼?
02/07 19:34, 3F

02/07 20:35, , 4F
再問一下 第一題是卡在要怎樣算出|B[k]| 因為hash是取
02/07 20:35, 4F

02/07 20:36, , 5F
平方+1 mod100 這有什麼方法可以算出來嗎
02/07 20:36, 5F

02/08 00:35, , 6F
Q2: Double Ended 就說他可以輸出最大 也可以輸出最
02/08 00:35, 6F

02/08 00:36, , 7F
小 所以 可能只有 1 和 7先開頭 其他可以刪掉
02/08 00:36, 7F

02/08 00:36, , 8F
(B)你全部都輸出Min 答案就是1234567
02/08 00:36, 8F

02/08 00:37, , 9F
(d)大大小大小大大 輸出式 即是答案
02/08 00:37, 9F

02/08 00:40, , 10F
第一題 我只能化簡到 你必須檢查 1~99的值.....
02/08 00:40, 10F

02/08 00:42, , 11F
因為百位數 舉個例子 978^2 = 978*(900+78) = .......
02/08 00:42, 11F

02/08 00:43, , 12F
上面有點寫多了 978 = (a+b)^2 = a^2+2ab+b^2
02/08 00:43, 12F

02/08 00:44, , 13F
a = 900 b = 78, 因為百位數有兩個0 %之後=0
02/08 00:44, 13F

02/08 00:46, , 14F
所以 B[5] 裡面有2 還有 102 202 302 402....902
02/08 00:46, 14F

02/08 01:17, , 15F
謝謝~ Q1那題應該是可輸入邊輸出 所以答案是a
02/08 01:17, 15F

02/08 09:36, , 16F
如果可以邊輸入邊輸出 答案是 BCD吧@@? A是如何做的?
02/08 09:36, 16F

02/08 09:36, , 17F
輸出到4的話 就會發生問題呀~ 如果我有錯請糾正我@@~
02/08 09:36, 17F

02/08 20:22, , 18F
題目是問impossible 所以答案A 就是A做不出來
02/08 20:22, 18F

02/08 22:47, , 19F
請問Q1答案有幾個?我怎麼覺得bc都對
02/08 22:47, 19F

02/09 00:19, , 20F
B是要不行的喔 所以應該是AE
02/09 00:19, 20F

02/09 09:46, , 21F
Q1我這邊答案是BCE
02/09 09:46, 21F

02/09 09:48, , 22F
Q2之e 可以put1 左put2 右put3 左put4 全左pop put5
02/09 09:48, 22F

02/09 09:49, , 23F
左put6 左put7 全左pop
02/09 09:49, 23F

09/11 14:13, , 24F
最後答案會輸出什麼? https://daxiv.com
09/11 14:13, 24F
文章代碼(AID): #1DJzH9WJ (Grad-ProbAsk)