CSE 326 Selected Practice Problem Solutions 2 6 As discussed in class the answer to the first part is 22 part is O log log D N 1 and the answer to the second 2 10 a O N b O N 2 c The answer depends on how many digits past the decimal point are computed Each digit costs O N 3 22 Pseudocode Create stack Read in first token while token is not if token is a number push the token onto the stack else if token is pop a pop b push a b if token is pop a pop b push a b if token is pop a pop b push a b if token is pop a pop b push a b read next token 1 4 1 a A b G H I L M and K 4 8 a a b c d e b a b c d e c a b c d e 4 27 See Figures 1 4 Figure 1 4 27 After accessing 3 4 28 See Figure 5 2 Figure 2 4 27 After accessing 9 Figure 3 4 27 After accessing 1 6 2 See Figure 6 6 3 The result of three deleteM ins starting with both of the heaps in Exercise 6 2 is in Figure 7 6 30 Clearly the claim is true for k 1 Suppose it is true for all values i 1 2 k A Bk 1 tree is formed by attaching a Bk tree to the root of a Bk tree Thus by induction it contains a B0 through Bk 1 tree as well as the newly attached Bk tree proving the claim 3 Figure 4 4 27 After accessing 5 Figure 5 4 28 Figure 6 6 2 4 Figure 7 6 3 5
View Full Document
Unlocking...