ECE242_final_2010_solution - ECE242 Fall 2010 Final...

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

View Full Document Right Arrow Icon
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)
Image of page 1

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

View Full Document Right Arrow Icon
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.
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
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
Image of page 4
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.
Image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern