Midterm1

Midterm1 - Solutions to Midterm 1 Peng Du University of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Solutions to Midterm 1 Peng Du University of California, San Diego 1 (10 points) 1.1 Part (a) The DFS forest is showed in Fig. 1 where pre and post numbers are written in the form [pre,post] beside each node. a b c f d e h g i [1,2] [3,6] [9,18] [7,8] [4,5] [14,15] [12,13] [11,16] [10,17] Fig.1. The DFS forest. 1.2 Part (b) The shortest path tree is showed in Fig. 2 where the distances are written next to each node. 2 (10 points) 2.1 Part (a) Polynomial time. We only need to output all nodes with zero in-degrees, which takes O ( | V | + | E | ) time. 2.2 Part (b) Exponential time. We have proved in homework 2-4 that graphs can have expo- nentially many cycles. It takes the computer at least exponential time to output all of them. 2 a b c e d f h g i 6 7 8 5 8 1 3 7 Fig.2. The shortest path tree. 2.3 Part (c) Exponential time. There are n ! many topological orderings for a graph with n nodes and no edges. Since n ! > 2 n when n is large enough, we need at least exponential time to output all of them.exponential time to output all of them....
View Full Document

This note was uploaded on 01/21/2010 for the course CSE 661930 taught by Professor Freund,yoav during the Fall '09 term at UCSD.

Page1 / 3

Midterm1 - Solutions to Midterm 1 Peng Du University of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online