阿摩線上測驗 登入

申論題資訊

試卷:109年 - 109國立臺灣大學_碩士班招生考試_資訊工程學研究所:資料結構與演算法(A)#106053
科目:台大◆資工◆資料結構與演算法(A)
年份:109年
排序:0

申論題內容

6. (3 points) A randomized quick sort works as follows. For ease of discussion we assur me that the sequence we want to sort, K = (k1,... .,kn), is a pernutution of 1 to n. We randomly and uniformly pick a key & from K. Then we partition K into two subsets - Ki that has keys less than k and K1 that has keys greater than k. Then we recursively sort K1and K2, and combine the results with k to get the sorted sequence.
 1. The number of key comparisons will always be max aunized when the keys in K are already sorted.
 2. Let |K1| and|K2|be the number of keys in K1 and K2 respectively. The expected value of max(|K1|,|K2|) is 6202113be9b85.jpgn.
3. The algorithm will compare two keys &: and ky at most ouce, so the numnber of key comparisons is O(n2). 4. The probability that the algorithm will compare ky and ly (n2i> jZ 1) is 6202119a997ce.jpg
5. Let P= {(i,j)|1≤i,,j ≤ni≠j}. The expected total number of key comparisons is 6202123dca3a3.jpg