Try   HackMD

113 交大資演 Part 2 參考詳解

採用 CC BY-NC-SA 4.0 許可協議共享,轉載請註明來源,禁止任何營利使用。
SayASun, Feb 4, 2024 9:33 AM

1. B-Tree of order M

  • (A) The answer is not unique
    • trv1: level order(BFS)
    • trv2: preorder(DFS, DLR)
      Image Not Showing Possible Reasons
      • The image was uploaded to a note which you don't have access to
      • The note which the image was originally uploaded to has been deleted
      Learn More →
  • (B)
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →
  • (C)
    We can sort sequence of any order, and sorted sequence will be inorder of BST, so it implies inorder.
    Ans: preorder, postorder, level-order
  • (D)
    • In Horowitz's definition of a B-Tree, the new key participates in the split. So M-way Search Tree at most contains
      M
      keys and
      M+1
      pointers before balancing process.
    • Notice that
      M
      keys store in
      [0,...,M1]
      , and
      M+1
      childs stroe in
      [0,...,M]
    • Ans:
       all keys in child[0]<key[0]key[i1]< all keys in child[i]<key[i],i,0<i<M1key[M1]< all keys in child[M]
  • (E)
    • B-Tree of order M have
      ceil(M/2)
      -node to
      M
      -node, and a M-node has
      M1
      keys after balancing.
    • For example, there are 2-node, 3-node, 4-node in 2-3-4 Tree (B-Tree of order 4).
    • Ans:
      ceil(M/2)1

2. Bellman-Ford

  • (A)
    • (1)
      INF
    • (2)
      0
    • (3)
      <
    • (4)
      <
  • (B)
    4
  • (C)
    1
  • (D)
    0
A B C D
initial INF INF INF INF
round 1 0 -1 -4 3
round 2 0 -1 -4 0
round 3 0 -1 -4 0

3. Longest Palindrome Bimodal Subsequence Problem (LPBS)

  • 長度為
    m
    的LPBS,其 pivot
    ak,k=(m+1)2
    。也就是以
    ak
    為中點,前半段是Increasing,後半段是Decreasing。
  • 因此求以
    i
    為pivot的LPBS,可以將問題分隔成以
    ai
    結尾的LIS,和以
    ai
    開始的LDS兩個部分。
  • ai
    結尾的LIS即為
    T(i)
    ,令以
    ai
    開始的LDS為
    T2(i)

    T2(i)={0if i>nmaxi<jn+1ai>aj(Ti(j)+1)if 1in
    • 註:題目的
      T(i)
      中implies
      a0
      inf
      ,我這裡定義的
      T2(i)
      也假設
      an+1
      inf
  • 因為兩段長度要相同,且
    ai
    重疊於兩段,故所求為
    PV(i)=min(T(i),T2(i))×21
  • (A) 由勘根定理證存在性
    • f(r)=Σi=1kaibir
      g(r)=f(r)1
      • rinf
        時,
        f(r)inf
        g(x)>0
      • rinf
        時,
        f(r)0
        g(x)<0
    • 由勘根定理知
      g(r)
      有實數解,故
      r0f(r0)=1
  • (B) 證明單調性,可二分
    ai>0,bi>1,i,1ikf(r)>0As r increases, f(r) decreasesAs r decreases, f(r) increases
    • 所以
      f(r)
      為嚴格遞減函數,具有單調性
    • 因此可以透過Binary Seach縮小答案範圍,when
      f(r)1<106
      , return r