{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

problemset6 solutions

# Constructing our dependency graph requires time

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: pendencies between comparators. The shortest path is the one with the most edges, or the most dependencies between comparators. Constructing our dependency graph requires ¢´Ö ¾ µ time because we consider all pairs of comparators once. The graph is a dag since we only have edges ´Ú Ú µ if . Thus, we can run Ç´Ö · Ö ¾ µ Thus, we have a total DAG -S HORTEST-PATHS, which has a running time of ¢´Î · µ running time of ¢´Ö ¾ µ. Deﬁne a comparison network as standard if Õ Õ for Õ ½¾ Ö. (b) Give an algorithm to convert a comparison network with Ò inputs and Ö comparators into an equivalent standard comparison network with Ò inputs and Ö comparators. Solution: We iterate over all the comparators in order. At a comparator ´ Õ Õ µ, if Õ Õ , we do not perform any action and continue with the next comparator. If Õ Õ , then we need to standardize the comparator by changing it to ´ Õ Õ µ. Note that now the output that used to be on Õ is on Õ and viceversa. Thus, we also need to reverse Õ and Õ in all subsequent comparators. That is to say, we consider all comparators ´ Õ· Õ· µ for ½ Ö Õ. If Õ· Õ , then we change the comparator to be ´ Õ Õ · µ. If Õ · Õ , then we change the comparator to be ´ Õ Õ · µ. We perform similar actions for Õ· Õ and Õ · Õ . We then continue on to the next comparator. The proof of correctness is just a simple induction argument over the number of comparators iterated over. To be equivalent, we simply need that after ﬂipping the Õ Ø co...
View Full Document

{[ snackBarMessage ]}