Professional Documents
Culture Documents
CREATED BY :
A graph ‘G’ is a set of vertex, called nodes ‘v’ which are connected by edges,
called links ‘e'. Thus G= (v , e).
Edge (Link): An edge e is a link between two nodes. A link denotes movements
between nodes. It has a direction that is generally represented as an arrow. If an arrow
is not used, it means the link is bi-directional.
Graphs are ubiquitous in computer science because they provide a handy way
to represent a relationship between pairs of objects. The objects represent items of
interest such as programs, people, cities, or web pages, and we place an edge between
a pair of nodes if they are related in a certain way. For example, an edge between a
pair of people might indicate that they like (or, in alternate scenarios, that they don’t
like) each other. An edge between a pair of courses might indicate that one needs to
be taken before the other.
Binary Tree
In computer science, a binary tree is a tree data structure in which each node
has at most two children, which are referred to as the left child and the right child.In
computing, binary trees are used in two very different ways. First, as a means of
accessing nodes based on some value or label associated with each node. Binary trees
labelled this way are used to implement binary search trees and binary heaps, and are
used for efficient searching and sorting. Second, as a representation of data with a
relevant bifurcating structure. In such cases, the particular arrangement of nodes
under and/or to the left or right of other nodes is part of the information (that is,
changing it would change the meaning).
Graph Theory Example From Real Life Problem
E = ((1,2),(2,3),(3,4),(4,5),(1,9),(2,9),(3,8),(4,7),(5,13),(5,6),(7,13),(13,7),(7,12),(8,11),(10,9),
(9,8),(8,7),(10,11),(11,12),(12,13),(13,6),(10,10))
= (e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22)
On the sides e11 (7, 13) and e12 (13,7) are double sides, you can use the return or go
route. On the sides e22(10, 10) are loop, because starts and end at the same point.
We’re trying to find the most optimal route for sending orders to customers using graph
theory, we start delivering orders from our outlets to our customers' house’s.Our outlets are
marked with 1, then our customer's houses are marked with 6,7 and 10.When we departed,
there were 2 road junctions namely e1(1,2) and e5(1,9) we chose path e5(1,9) to point 9 then
continued to path e15(9,10) and arrived at our first customer's house, which was point 10. On
the next trip we passed path e18(10,11) to point 11 then crossed path e19(11,12) to point 12
then took path e13(12,7) and got to the house our second customer is at point 7. Our last trip
took the e12(7,13) path to point 13 then passed the e21(13,6) path and finally got to our last
customer's house. That's the most optimal path we've got from using graph theory to solve
this problem.
Binary Tree Example From Real Life Problem
Data Item Drink Eat Sleep Sit Walk Run Play Watch Jump Hit Kick
Weight 20 18 15 19 12 16 22 25 21 27 24
Procedure:
If the target data X is found immediately (key value = C element). Then the process will stop
and display the data found.
If the target data X < key value, then the search will only be performed on the left subtree.
If the target data X > key value, the search will only be performed on the right subtree.
If target X data is not found anywhere it will display an error
.
We use the binary tree method to find the word we want. First of all, we want to search word
Run.
The key = Run with weight = 16.
Root key value 1 = 20.
Checks whether 16 = 20. because it is not the same, it checks whether 16 > 20 or 16 < 20. 16
< 20. because < then the search for data continues to the left subtree.