midterm_a_w13.pdf

# midterm_a_w13.pdf - CSE 101 Midterm Name February 7 2013...

• Test Prep
• 7

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

CSE 101 Midterm February 7, 2013 Name: Student ID: Question Points Score 1 10 2 10 3 10 4 10 Total: 40 INSTRUCTIONS: Be clear and concise. Write your answers in the space provided. Use the backs of pages, and/or the scratch page at the end, for your scratchwork. All graphs are assumed to be simple. Good luck! You may freely use or cite the following subroutines from class 1 : explore ( G, s ) This returns three arrays of size | V | : pre , post , and visited . dfs ( G ) This returns three arrays of size | V | : pre , post , and cc . If the graph has k connected components, then the cc array assigns each node a number in the range 1 to k . scc ( G ) This returns an array scc of size | V | . If the graph has k strongly connected components, then the scc array assigns each node a number in the range 1 to k . bfs ( G, s ), dijkstra ( G, ‘, s ), bellman-ford ( G, ‘, s ) These all return two arrays of size | V | : dist and prev . dag-sp ( G, ‘, s ) This returns two arrays of size | V | : dist and prev . The array dist contains the shortest paths from s to all other reachable nodes in G . The algorithm is similar to dag-lp which instead returns the longest paths. These only work on directed acyclic graphs with and without negative edges. 1 We recall from class/text the following time complexities. (1) dfs / explore : O ( | V | + | E | ). (2) scc : O ( | V | + | E | ). (3) bfs : O ( | V | + | E | ). (4) dijkstra : O (( | V | + | E | ) log | V | ) assuming a simple binary heap implementation of the priority queue.(5) bellman-ford : O ( | V | · | E | ) (6) dag-sp : O ( | V | + | E | ).

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

1. (10 points) For the directed graph below with non-negative edges, list the order in which nodes are processed by each of the following algorithms. Start all algorithms from node A and ignore edge lengths if they are not commonly used by an algorithm (e.g., dfs ). Break any ties alphabetically (alphabetically-lowest first).
This is the end of the preview. Sign up to access the rest of the document.
• Fall '08
• staff
• Sample Midterm

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern