You are on page 1of 18

Welcome To My Presentation

Submitted By: Submitted To:


Ra-Ad Arafin (183002035) Jargis Ahmed
Lecture Dept. of CSE

Department Of CSE
Green University Of Bangladesh
Presentation Topic:

BFS UVA 336 and Bellman Ford UVA 558

2
CONTENT:

 Introduction
 BFS Algorithm
 Example of BFS algorithm
 Bellman Ford Algorithm
 Concluding remark

3
Introduction:

 Algorithm means “a process or set of rules to be followed in


calculations or other problem-solving operations”.

4
BFS DFS (UVA 336)

5
Algorithm:


I read the number of edges while edges != 0.

Read the graph.

Read the node to search and the ttl while node !=0
and ttl != 0.

Call bfs(node) and init notReach = 0.

Traverse all the calculated distance from node. If
(distance > ttl) notReach+1;

Traverse the visited map. If an node is not visited.
notReach+1.

Print notReach.
6
Hint of Solution:


The nodes doesnot follow a correlative order.

Carefull with the nodes that are not connected in the
bfs request.(check my case)

7
Source Code:

8
9
10
Bellman Ford Algorithm:

The Bellman-Ford algorithm is one of the classic solutions to this


problem. It calculates the shortest path to all nodes in the graph from
a single source.

11
Bellman Ford Algorithm Graph:

12
Bellman Ford Algorithm :

 Start by considering that the shortest path to all nodes, less the source, is infinity.
Mark the length of the path to the source as 0

 Take every edge and try to relax it

 Relaxing an edge means checking to see if the path to the node the edge is
pointing to can’t be shortened, and if so, doing it. In the above graph, by checking
the edge 1 -> 2 of length 6, you find that the length of the shortest path to node
1 plus the length of the edge 1 -> 2 is less then infinity. So, you replace infinity
in node 2 with 6. 

13
Tricky Lines :

1. starting from our solar system, it is always possible to end up in any


star system by following a sequence of wormholes
2. Between any pair of star systems, there is at most one wormhole in
either direction.

14
Source Code:

15
16
17
Concluding remark:

The basic idea of implementing curiosity and boredom is not limited to the
particular algorithm described in the first section. Every model-dependent on-
line algorithm for learning goal directed behavior might be augmented by a
similar implementation of `the desire to improve the world model'. 

18

You might also like