卷別
資料結構與演算法
選擇國立臺灣大學 2023 · 考試 · 第 7 題
考科資料結構
(5 points)(單選)Given a list of binary trees where each node is 0 or 1 shown as below, we would like to insert these trees into a linear-probing hash table of length . The hash function , where is the binary sequence obtained from in-order traversal of tree and converts a binary sequence to a decimal number. For instance, . Here's the question: how many collisions occur during the insertion process?
七棵樹皆為 7 節點完全二元樹(根;左子 cL、右子 cR;cL 的左右葉 a,b;cR 的左右葉 c,d),中序序列為 [a, cL, b, root, c, cR, d]:
- :root=0, cL=0, cR=1, a=0,b=1,c=1,d=0
- :root=0, cL=0, cR=0, a=0,b=0,c=1,d=0
- :root=1, cL=0, cR=1, a=0,b=0,c=1,d=1
- :root=1, cL=0, cR=0, a=0,b=1,c=1,d=0
- :root=0, cL=0, cR=0, a=0,b=1,c=0,d=1
- :root=1, cL=0, cR=0, a=1,b=1,c=0,d=0
- :root=1, cL=1, cR=0, a=0,b=1,c=1,d=0
- (A)0
- (B)1
- (C)2
- (D)3
- (E)4