# 1. Using Bellman-Ford, find the shortest path tree from the node 3 (20points) - PowerPoint PPT Presentation

PPT – 1. Using Bellman-Ford, find the shortest path tree from the node 3 (20points) PowerPoint presentation | free to view - id: 1d1251-ZDc1Z

The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
Title:

## 1. Using Bellman-Ford, find the shortest path tree from the node 3 (20points)

Description:

### Midterm preparation. 1. Using Bellman-Ford, find the shortest path tree from the ... 2.Write the content of the queue Q/ the set S/ keys d(v) after 5 iterations of ... – PowerPoint PPT presentation

Number of Views:312
Avg rating:3.0/5.0
Slides: 20
Provided by: paulak4
Category:
Tags:
Transcript and Presenter's Notes

Title: 1. Using Bellman-Ford, find the shortest path tree from the node 3 (20points)

1
• 1. Using Bellman-Ford, find the shortest path
tree from the node 3 (20points)
• - the shortest-path tree consists of edges
________________________
• the number of iterations of BF is ___________

Runtime O(VE), for /- edges, Detects existence
of neg. loops After V iterations.
2
2.Write the content of the queue Q/ the set S/
keys d(v) after 5 iterations of the Dijkstra
algorithm for the graph G below and source s
(weights are on edges) Q __________
S _______________ d(s) _____ d(v1)____
d(v2) ____ d(v3) ____ d(v4) ____
d(v5) ____ d(v6) ___ d(v7) ___ d(v8)
.
2
8
v6
3
v3
v1
8
5
9
1
v4
7
v8
s
12
10
11
5
7
v2
13
v7
15
v5
14
(20points)
Runtime O(EVlgV), for edges, Does not detect
neg. loops. Similar to Prims for MST.
3
Mistake from the previous class
0 2 5 -1
3 0 0 5
0 4 0 3
7 0 -4 0
0 2 5 -1
3 0 8 5
8 4 0 3
7 8 -4 0

A
correct
wrong
4
AllPairs Shortest paths Matrix Multiplication
0 8 8 8
8 0 8 8
8 8 0 8
8 8 8 0
0 2 5 -1
3 0 8 5
8 4 0 3
7 8 -4 0
A
D(0)
5
AllPairs Shortest paths Matrix Multiplication
0 8 8 8
8 0 8 8
8 8 0 8
8 8 8 0
0 2 5 -1
3 0 8 5
8 4 0 3
7 8 -4 0
D(1) D(0)A

D(0) Identity Matrix for new operations
D(1) D(0)A IA A
D(k) A(k)
6
3. Find all shortest path weights with the matrix
multiplication method for the graph on the right
side.(15pts) - give all matrices that are
obtained on the way, - are there any negative
cycles in the graph
10
2
1
7
5
-5
-7
3

4
3
M D(0) A A , D(0) initial dist. Matrix,
1
M
M2
M4
M8
M16
M32
7
1. Sorting Algorithms,(Radix Sort, Quick Sort, Merge
Sort, Heapsort, Insertion sort).
2. Binary Search Trees.
3. Graph representation. DFS. BFS. Topological Sort.
Strongly connected components.
4. Algorithms for finding MST (Prim's, Kruskal),
their applicability, limitations and running
time.
5. Algorithms for finding Single source shortest
paths (Dijkstra,Bellman-Ford), their
applicability, limitations and running time.
6. Matrix Multiplication Algorithm for finding
All-pairs shortest paths, applicability,
limitations and running time.

8
2. For Quicksort (from slides) for the sequence
35,17, 32, 10 the last swap is
___________, the first swap is _________
the number of swaps is ______, the number of
comparisons is_______ (15pts)
9
3. Show first 5 swaps of heapsort (deletions of
max) with the input heap below (10pts)
10
Given a set of numbers, show first 3 iterations
of Radix sort after alignment (5pts)
353466 345 4365 236547 4364 3467 67
11
4
4.Given a graph G
8
10
2
5
12
1
9
11
3
6
1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ?
10 ? 11 ? 12 ?
7
Give adjacency list representation (5 pts)
12
4.Given a graph G in matrix representation
(5pts) 1 2 3 4 5 6 7 8 9 10 11
12 1 0 0 1 1 0 1 0 0 0 1 0 0 2
0 0 0 1 1 0 1 1 1 0 0 0 3 1
0 0 0 0 1 0 0 0 1 1 0 4 0 1 1
0 0 0 0 0 0 0 1 0 5 1 0 1 1 0
1 0 0 1 0 0 1 6 0 0 0 0 0 0 0
0 0 0 0 0 7 0 0 0 0 0 1 0 0 0
0 0 0 8 1 0 0 0 0 0 0 0 1 0
0 0 9 1 1 1 0 0 0 1 1 0 0 1
1 10 0 1 0 1 1 0 0 0 1 0 0 0 11 0
0 0 0 0 0 0 0 0 0 0 1 12 0 0 0
0 1 0 0 1 0 1 0 0
1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ?
10 ? 11 ? 12 ?
b) Give edge list representation
representation
13
1.Given a graph G
8
4
10
2
5
12
9
1
11
3
6
7
Give the order in which nodes are traversed with
BFS from source 5 ____________________________
(10 Pts)
14
4
2.Given a graph G
8
10
2
5
12
9
1
11
3
6
7
Give the order in which nodes are traversed with
DFS _______________________________________ Give
the nodes of the second cycle found by
DFS ____________________________ (10 Pts)

15
Provide Topological Sort of the following
dependency graph
4
8
10
2
5
9
12
1
11
3
6
7
_______________________________________ (10 Pts)

16
• 4. Given a graph below(15 pts)
• What are the neighbors in the minimum spanning
tree (MST) of the node C___________ and the node
Y__________
• By how much the weight of edge (I,G) should be
decreased to make this edge added to MST? At
least by_______ . Out of MST will go the
edge _______
• By how much the weight of edge (Y,E) should be
increased to push this edges out of MST? At
least by_______ . Inside MST will go the
edge _______

P
22
3
H
X
35
10
21
16
J
15
B
2
4
29
Y
E
5
16
L
8
A
6
I
6
7
7
13
14
9
1
F
8
G
K
C
1
2
2
D
17
3. Given Binary Search Trees (10pts)
a
k
c
b
6
e
j
x
4
m
r
2
5
d
i
y
p
v
f
z
What are the children of k after deletion of b ?
Give both possible variants or
. What is the successor of d .
What is the successor of E . What is the
predecessor of B . What is the successor of
C . What is the predecessor of D .
18
Binary Search Tree
• Enumerate all operations
• Runtime for
• Finding Min or Max
• Finding any element
• Insertion
• Deletion

(5pts)
19
1. Sorting Algorithms,(Radix Sort, Quick Sort, Merge
Sort, Heapsort, Insertion sort).
2. Binary Search Trees.
3. Graph representation. DFS. BFS. Topological Sort.
Strongly connected components.
4. Algorithms for finding MST (Prim's, Kruskal),
their applicability, limitations and running
time.
5. Algorithms for finding Single source shortest
paths (Dijkstra,Bellman-Ford), their
applicability, limitations and running time.
6. Matrix Multiplication Algorithm for finding
All-pairs shortest paths, applicability,
limitations and running time.