ECE242_final_2010_solution

ECE242_final_2010_solution - ECE242 Fall 2010 Final...

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

1 | P a g e ECE242 Fall 2010 Final Examination (120 Minutes, closed book) Name: ______________________ Student ID: ______________________ NOTE: For questions that involve coding, please make sure that you either generously comment your code or briefly describe your approach before you write your code. Any questions on writing code must be answered in Java using Data Structures topics covered in lectures 1-36. You can use Stacks and Queues to answer all questions without having to write their associated methods Question Score 1 (20) 2 (10) 3 (20) 4 (15) 5 (20) 6 (15) 8 Bonus 1 (5) 9 Bonus 2 (0)

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

View Full Document
2 | P a g e Functions in the ArrayList class you could use: boolean add( int element) Appends the specified element(element) to the end of this list. int remove( int index) Removes the element at the specified position(index) in this list. int get( int index), Returns the element at the specified position (index) in this list. int set( int index, int element), Replaces the element at the specified position (index) in this list with the specified element (element). int size(), Returns the number of elements in this list.
3 | P a g e 1. [20 pts] Given a weighted, undirected graph below. F A E G D B C 9 5 2 7 6 4 1 3 8 10 a) [6 pts] Apply Dijkstra’s shortest path algorithm to find the shortest paths from node A to all the other nodes. List the shortest paths and their total costs in each step, as well as the node selected in each step. Show all the steps for full credit. No java code required. Node From Vertex A to-> B 2 2 2 2 2 2 C 8 7 7 7 7 7 D 6 6 6 6 6 6 E 10 10 9 9 9 9 F Inf Inf Inf 16 16 14 G Inf Inf Inf Inf 10 10 Best selected B D C E G F

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

View Full Document
4 | P a g e b) [4 pts] Provide the adjacency matrix of the graph shown above. Please note that this graph is weighted. A B C D E F G A 0 2 8 6 10 0 0 B 2 0 5 7 0 0 0 C 8 5 0 0 0 9 0 D 6 7 0 0 3 0 0 E 10 0 0 3 0 0 1 F 0 0 9 0 0 0 4 G 0 0 0 0 1 4 0
5 | P a g e c) [8 pts] Construct a Minimum Spanning Tree (MST) of the graph shown above starting from node A. Highlight the path chosen in each step in the following figures. No java code required. F

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

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

This note was uploaded on 01/02/2012 for the course COMPUTER 101 taught by Professor Dr.kahan during the Spring '11 term at Akademia Ekonomiczna w Krakowie.

Page1 / 15

ECE242_final_2010_solution - ECE242 Fall 2010 Final...

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

View Full Document
Ask a homework question - tutors are online