CS 161 Fall 2013 Homework 8, due Nov. 24
1. [Goodrich & Tamassia, C-7.3] Consider a greedy strategy for nding a path from vertex start
to vertex goal in a given connected graph, that performs the following steps:
(a) path = [start ]
(b) visited = cfw_star
1. In class we saw the formula
(value > (i*x) & (1 < x) - 1)
for extracting the i'th digit of the base-2^x representation of the given value, where i=0 means the 1's digit, etc. Write pseudocode (or code) for a function replace_digit(value,x,i,d). This f
1. Construct a decision tree that performs the same comparisons as merge sort, on inputs of four items. (You may assume that no two items have the same key. Use drawing software to show the tree - do not draw it by hand.)
2. When merge sort is used to sor