cp7_10_ps09_sol

# cp7_10_ps09_sol - Home Work 9 The problems in this problem...

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

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

View Full Document

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

View Full Document

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

View Full Document

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.

Unformatted text preview: Home Work 9 The problems in this problem set cover lectures C7, C8, C9 and C10 1. What is the Minimum Spanning Tree of the graph shown below using both Prim’s and Kruskal’s algorithm. Show all the steps in the computation of the MST (not just the final MST). Prim’s Algorithm Step 1. MST 1 1 4 5 2 1 4 5 30 Parent Fringe Set Step 2 1 2 1 MST Parent Fringe Set Step 3 1 2 1 5 2 MST Parent 1 4 5 3 3 6 2 2 2 5 5 1 4 3 6 2 2 5 3 5 3 5 Fringe Set Step 4 1 2 1 5 2 6 2 5 MST Parent 6 4 2 3 5 3 5 Fringe Set Step 5 1 2 1 5 2 3 5 3 5 6 2 5 4 2 MST Parent Fringe Set Minimum Spanning Tree MST 1 2 1 5 2 3 3 5 6 2 5 4 2 Weight of the MST = 10 + 20 + 25 + 20 + 35 = 110 Kruskals Algorithm Initialization 1 4 5 3 6 2 1 35 5 45 30 25 5 5 20 20 1 4 5 3 6 2 Step 1 1 4 5 3 6 2 35 5 45 30 25 5 5 20 20 1 4 5 3 6 2 35 5 45 30 25 5 5 20 20 1 1 4 5 3 6 2 1 1 4 5 3 6 2 Step 2 1 4 5 3 6 2 35 5 45 30 25 5 5 20 1 4 5 3 6 2 35 5 45 30 25 5 5 20 1 20 1 4 5 3 6 2 1 20 1 4 5 3 6 2 Step 3 1 4 5 3 6 2 35 5 45 30 25 5 5 1 4 5 3 6 2 35 5 45 30 25 5 5 1 20 20 1 4 5 3 6 2 1 20 20 1 4 5 3 6 2 Step 4 1 4 5 3 6 2 35 5 45 30 5 5 1 4 5 3 6 2 35 5 45 30 5 5 1 25 20 20 1 4 5 3 6 2 1 25 20 20 1 4 5 3 6 2 Step 5 1 4 5 3 6 2 5 45 30 5 5 1 4 5 3 6 2 5 45 30 5 5 1 35 25 20 20 1 4 5 3 6 2 1 35 25 20 20 1 4 5 3 6 2 Weight of the MST = 10 + 20 + 20 + 25 + 35 = 110 2. Compute the computation complexity of the bubble sort algorithm. Show all the steps in the computation based on the algorithm. Algorithm Procedure Bubble_Sort(Input_Output_Array) for I in 1 .. My_Array_Max loop for J in I+1 .. My_Array_Max loop N-1 N if (Input_Output_Array(I) <= Input_Output_Array(J)) then Temp := Input_Output_Array(I); Input_Output_Array(I) := Input_Output_Array(J); Input_Output__Array(J) := Temp; end if; end loop; end loop; end Bubble_Sort; O(N(N-1)) = O(N 2 ) 3. What are the best case and worst case computation complexity of: a. Inserting a node into an unsorted singly linked list Inserting into an unsorted singly linked list is carried out using the add_to_front operation....
View Full Document

{[ snackBarMessage ]}

### Page1 / 12

cp7_10_ps09_sol - Home Work 9 The problems in this problem...

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

View Full Document
Ask a homework question - tutors are online