Free Essay

Tree and Graphs

In:

Submitted By eodjesus1
Words 479
Pages 2
Phase 3 DB Graphs and Trees
Elie De Jesus
MATH203-1302A-01 – Discrete Mathematics
Professor Andrew Halverson
April 24, 2013

Part I
Graphs and trees are a little more complicated to understand than what I thought. Based on the information that I found they give you a way to visualize your sets and use the data that you have to find the shortest path. So because of this it shows that Trees cannot contain a cycle, so a set would be Y=COS(X); which can be a general graph but not a tree. The one example that I understood was the one about “the mileage on a bike”. Now I don’t quite understand the example but it shows that the graph would have a decrease in mileage where as it would increase in time. That is not how a tree is explained because there is no sequence to be shown for the data.
This is the examples graph:

So based on that example I understand that the tree encoding defines a root node or one path between two nodes that represent the output of a solution. A tree is still a graph but without multiple paths. So to be a tree it has to start from any node and be able to reach another, there can be no cycles, and you must have more nodes that edges.

Part II
To first answer this question one must know the meaning of a Breadth-first or a Depth-first. A Breadth-first search is a strategy for searching in a graph when search is limited to essentially two operations: (a) visit and inspect a node of a graph; (b) gain access to visit the nodes that neighbor the currently visited node. And a depth-first search is an algorithm for traversing or searching tree or graph data structures (Wikipedia encyclopedia, 2013).
So based on my definitions above I would choose the breadth-first search to select the best move. Breadth-first search would go to the end of the result in one move and then go on to the next move. Just like Pseudocode, you start with one section and then when you get to the end of that section you move on to the next. If we used the depth-first search it would use an alternative one time within the search then go onto another but it would make a loop and come back and go to the node again.
This was an example of how a breadth-first search tree looks:

References:
Breadth-First Search. (2013). Retrieved from Wikipedia Encyclopedia. http://en.wikipedia.org/wiki/Breadth-first_search
Breadth & Depth-First Search. (2013, March). In ISU. Retrieved April 24, 2013, from http://homepages.ius.edu/rwisman/C455/html/notes/Chapter22/BFS.htm
Johnsonbaugh, R. (2009). Discrete Mathematics 7th Ed. Retrieved April 24, 2013 from CTU Online Bookshelf

Similar Documents

Free Essay

The K-in-a-Tree Problem for Graphs of Girth at Least K

...elsevier.com/locate/dam The k-in-a-tree problem for graphs of girth at least k W. Liu a , N. Trotignon b,∗ a Université Grenoble 1, Joseph Fourier, France b CNRS, LIAFA, Université Paris 7, Paris Diderot, France article info Article history: Received 10 July 2009 Received in revised form 28 May 2010 Accepted 3 June 2010 Available online 1 July 2010 Keywords: Tree Algorithm Three-in-a-tree k-in-a-tree Girth Induced subgraph abstract For all integers k ≥ 3, we give an O(n4 )-time algorithm for the problem whose instance is a graph G of girth at least k together with k vertices and whose question is ‘‘Does G contains an induced subgraph containing the k vertices and isomorphic to a tree?’’. This directly follows for k = 3 from the three-in-a-tree algorithm of Chudnovsky and Seymour and for k = 4 from a result of Derhy, Picouleau and Trotignon. Here we solve the problem for k ≥ 5. Our algorithm relies on a structural description of graphs of girth at least k that do not contain an induced tree covering k given vertices (k ≥ 5). © 2010 Elsevier B.V. All rights reserved. 1. Introduction Many interesting classes of graphs are defined by forbidding induced subgraphs; see [1] for a survey. This is why the detection of several kinds of induced subgraph is interesting; see [5], where many such problems are surveyed. In particular, the problem of deciding whether a graph G contains as an induced subgraph some graph obtained after possibly subdividing ...

Words: 4554 - Pages: 19

Free Essay

Graphs and Trees

...Length: 3 Parts: See Assignment Details    Points Possible: 75 Graphs and Trees Task Background: Graphs and trees provide you with ways to visualize data sets, and the opportunity to do analysis on the data (e.g., shortest path). Knowing the structure of a database enables you to choose a proper algorithm for searching for data within a database. Primary Task Response: Within the Discussion Board area, write up to 3 paragraphs that respond to the following questions with your thoughts, ideas, and comments. This will be the foundation for future discussions by your classmates. Be substantive and clear, and use examples to reinforce your ideas. Part I (25 points – distributed as follows) Trees are somewhat less complicated than graphs, which makes things like data searching easier, when a data has the structure of a tree. However, not all data can be represented by a tree. Give an example of a data set that cannot be represented by a tree, but that can be represented by a more general graph. 1) Create, show, and describe your data set. (5 points) V = {Bill, John, Kim, James, Chris, Destiny, Noah, Paul} E = {(Bill, John), (Kim, James), (Chris, Destiny), (Noah, Paul), (Bill, Kim), (John, Chris), (Destiny, Noah)} These are people that are employees at a store. Some work on the same shift together and associate with each other. 2) Then, show by building a graph, how your data is represented by a graph. (5 points) Bill Bill John John Chris Chris Kim Kim ...

Words: 1054 - Pages: 5

Free Essay

Math

...What is the size of the largest induced Kn in Figure 6.9? A complete graph on n vertices is Kn n vertices v1, v2, . . . , vn with an edge for each pair of distinct vertices a. P3 no pair of vertices b. not complete c. not complete d. K2 or C2 e. C5 not complete Largest induced Kn is K2. 10. What can you say about a five vertex simple graph in which every vertex has degree four? Five vertices *4 degrees = 20 edges V = {1, 2, 3, 4, 5} E = {(1,2), (1,3), (1,4), (1,5), (2,1), (2,3), (2,4), (2,5), 3,1, 3,2, 3,4, 3,5, 4,1, 4,2, 4,3, 4,5, (5,1), (5,2), (5,3), (5,4)} I can say: 1. The simple graph is complete because all pairs of end points are joined by an edge. 2. I can say that it is not a tree because it contains a cycle. 3. That it is connected but undirected. 4. Adding all the degrees 4+4+4+4+4 for odd vertices and even degrees provides an even amount of edges =20. 14.  Are there graphs with v vertices and v-1 edges and no cycles that are not trees? No Give a proof to justify your answer. Let G be a graph with v vertices and e edges Let G1, G2, G3…,Gk be G's connected components Let vi be the number of vertices of Gi Let ei be the number of edges of Gi Prove G has e = v-1 and no cycles but is not a tree A tree T has v vertices and v-1 edges T=(V,E) v=V and vi=Vi v-1=E ei=E∩Vi2 Induce that ei=vi-1. A tree has v vertices and v-1 edges. vi=v-1 so E=ei+k= (vi-1)+k=(vi)=v-1 ...

Words: 1903 - Pages: 8

Free Essay

Mm250 Unit 7

...the following tree, name two vertices that are considered the following. Explain in your own words how you know: (a) parent-child (2 points). Answer: 202 - 401 Explanation: the parent of a vertex is the vertex connected to it on the path to the root, 202 is the parent and 401 is the child (b) sibling nodes (2 points): Answer: 301, 302, 303 Explanation: If two vertices are children of the same parent, then these two vertices are called siblings, 301, 302, 303 have the same parent that is 201 (c) leaf nodes (2 points) Answer: 301, 302, 303, 401 Explanation: the leaves are all terminal vertices 2. Determine if each of the following graphs is considered a tree. Explain why or why not, using what you learned in this unit. a. (2 points) Answer: not a tree Explanation: A tree is a connected graph with no cycles, and there is cycles in this graph b. (2 points) Answer: yes Explanation: A tree is a connected graph with no cycles, and there is no cycles in this graph c. (1 point) Answer: no Explanation: A tree is a connected graph with no cycles, and there a cycle in this graph 3. Determine and sketch two different spanning trees for this graph: a. (1 point) b. (1 point) 4. Consider this graph: a. Determine the total weight for this graph. Show your work. (1 point) Answer: 122 Explanation: 5 + 10 +5 +10 +17 +15 + 5 +4+4+8+5+6+13+7+8 b. Draw one spanning tree for this weighted graph and determine its...

Words: 717 - Pages: 3

Premium Essay

Adjacency Matrix and Shortest Path

...Part I: Adjacency Matrix and Shortest Path Construct a graph based on the adjacency matrix that appears below. Label all nodes with indices consistent with the placement of numbers within the matrix. ⌈0 6 0 5 0⌉ | 6 0 1 0 3 | | 0 1 0 4 8 | | 5 0 4 0 0 | ⌊0 3 8 0 0⌋ Describe the graph and why it is consistent with the matrix. How many simple paths are there from vertex 1 to vertex 5? Explain. Which is the shortest of those paths? The graph would look something like this: The graph is an undirected graph, consisting of five nodes and six edges. The graph is undirected due to the symmetry of the adjacency matrix about its main diagonal. The path between node i to node j has the same length in either direction, so the edges are shown as undirected edges. The length of each path between node i and node j corresponds with the value in the ith row and jth column of the adjacency matrix. The graph is not considered “connected” because the graph contains cycles. A simple path is a path between two vertices that does not repeat or revisit any vertex. There are four simple paths between vertex 1 and vertex 5. Those paths are: 1 → 2 → 5 1 → 2 → 3 → 5 1 → 4 → 3 → 5 1 → 4 → 3 → 2 → 5 The lengths of the paths are: 1 → 2 → 5 Length = 6 + 3 = 9 1 → 2 → 3 → 5 Length = 6 + 1 + 8 = 15 1 → 4 → 3 → 5 Length = 5 + 4 + 8 = 17 1 → 4 → 3 → 2 → 5 Length = 5 + 4 + 1 + 3 = 13 The shortest path is...

Words: 577 - Pages: 3

Premium Essay

Discrete Math Summary

...vertices distinct ==> different edges + no cycles G and H are isomorphic if there exists an isomorphism and γ = V(G) ---> V(H) such that if {u,v} edge in G then {γ(u), γ (v)} edge in H each vertex goes to another vertex degrees are the same shapes are mapped too to prove two graphs are isomorphic check the degree lists….if they match find a mapping between the two graphs Euler path = simple path which goes through each edge exactly once Euler circuit = closed Euler path Theorem: A graph that has an Euler circuit must have all vertices of even degree Graph: If 2 vertices of odd degree or ==> Euler path 0 vertices of odd degree...

Words: 384 - Pages: 2

Free Essay

The Data Structure

...queue 串 string 数组 array 树 tree 图 grabh 查找,线索 searching 更新 updating 排序(分类) sorting 插入 insertion 删除 deletion 前趋 predecessor 后继 successor 直接前趋 immediate predecessor 直接后继 immediate successor 双端列表 deque(double-ended queue) 循环队列 cirular queue 指针 pointer 先进先出表(队列) first-in first-out list 后进先出表(队列) last-in first-out list 栈底 bottom 栈定 top 压入 push 弹出 pop 队头 front 队尾 rear 上溢 overflow 下溢 underflow 数组 array 矩阵 matrix 多维数组 multi-dimentional array 以行为主的顺序分配 row major order 以列为主的顺序分配 column major order 三角矩阵 truangular matrix 对称矩阵 symmetric matrix 稀疏矩阵 sparse matrix 转置矩阵 transposed matrix 链表 linked list 线性链表 linear linked list 单链表 single linked list 多重链表 multilinked list 循环链表 circular linked list 双向链表 doubly linked list 十字链表 orthogonal list 广义表 generalized list 链 link 指针域 pointer field 链域 link field 头结点 head node 头指针 head pointer 尾指针 tail pointer 串 string 空白(空格)串 blank string 空串(零串) null string 子串 substring 树 tree 子树 subtree 森林 forest 根 root 叶子 leaf 结点 node 深度 depth 层次 level 双亲 parents 孩子 children 兄弟 brother 祖先 ancestor 子孙 descentdant 二叉树 binary tree 平衡二叉树 banlanced binary tree 满二叉树 full binary tree 完全二叉树 complete binary tree 遍历二叉树 traversing binary tree 二叉排序树 binary sort tree 二叉查找树 binary search tree 线索二叉树 threaded binary tree 哈夫曼树 Huffman tree 有序数 ordered tree 无序数 unordered tree 判定树 decision tree 双链树 doubly linked tree 数字查找树 digital search tree 树的遍历 traversal of tree 先序遍历 preorder traversal 中序遍历...

Words: 1522 - Pages: 7

Free Essay

Csc 331

...Assignments Section 9.1 Exercise 2 The graph is not a tree, because there more than one paths from one vertex to another. Exercise 3 The graph is not a tree, because not all of the vertices of the graph are connected. Thus, there is no an existing unique path between some vertices. Exercise 9 The height of the tree in the Exercise 8 is 4 Exercise 10 [pic] The height of this tree is 5 Exercise 12 An example of the hierarchical relationship is a family tree: [pic] Section 9.2 Exercise 5 Siblings of Ares: Hades, Poseidon and Zeus. Exercise 6 [pic] Exercise 8 The parent of c is b, while the parent of j is e. Exercise 9 The children of d are h and i, while the only child of e is j. Exercise 11 The siblings of f are e and g. The sibling of h is i. Exercise 12 The terminal vertices are: j, f, g, h, i. Exercise 18 If two vertices in a rooted tree have same ancestors, they must share same simple path to their parent, which means that they are siblings. Exercise 19 The only vertex in the rooted tree, that does not have ancestors, is a root itself. Exercise 20 By definition, a tree cannot have two vertices sharing a child, because this will create two possible paths to that child and will violate the definition of a tree. Exercise 21 A vertex in a rooted tree that has no decedents is a leaf (a terminal vertex). Exercise 29 According to the Theorem 9.2.3, if a graph is a tree, then it is acyclic and has n – 1 edges. The graph in this problem contains a cycle (v1...

Words: 374 - Pages: 2

Free Essay

Mth/221 Discrete Math for Information Technology Week 4

...text-pg:609 Exercise 12.5, problems 3 , text-pg:621 Chapter 11 Exercise 11.1 Problem 8: Figure 11.10 shows an undirected graph representing a section of a department store. The vertices indicate where cashiers are located; the edges denote unblocked aisles between cashiers. The department store wants to set up a security system where (plainclothes) guards are placed at certain cashier locations so that each cashier either has a guard at his or her location or is only one aisle away from a cashier who has a guard. What is the smallest number of guards needed? Figure 11.10 Problem 11: Let G be a graph that satisfies the condition in Exercise 10. (a) Must G be loop-free? (b) Could G be a multigraph? (c) If G has n vertices, can we determine how many edges it has? Exercise 11.2 Problem 1: Let G be the undirected graph in Fig. 11.27(a). a) How many connected subgraphs ofGhave four vertices and include a cycle? b) Describe the subgraph G1 (of G) in part (b) of the figure first, as an induced subgraph and second, in terms of deleting a vertex of G. c) Describe the subgraphG2 (ofG) in part (c) of the figure first, as an induced subgraph and second, in terms of the deletion of vertices of G. d) Draw the subgraph of G induced by the set of vertices U _ {b, c, d, f, i, j}. e) For the graph G, let the edge e _...

Words: 1159 - Pages: 5

Free Essay

Discriptive Statisticss

...vertices in a connected undirected graph G, the distance from a to b is defined to be the length of a shortest path from a to b (when a =b the distance is defined to be 0). For the graph in Fig. 11.9, find the distances from d to (each of) the other vertices in G. Sec 11.1 /8 Figure 11.10 shows an undirected graph representing a section of a department store. The vertices indicate where cashiers are located; the edges denote unblocked aisles between cashiers. The department store wants to set up a security system where (plainclothes) guards are placed at certain cashier locations so that each cashier either has a guard at his or her location or is only one aisle away from a cashier who has a guard. What is the smallest number of guards needed? a b c Sec 11.1 /11 10. Give an example of a connected graph G where removing any edge of G results in a disconnected graph. 11. Let G be a graph that satisfies the condition in Exercise 10. (a) Must G be loop-free? (b) Could G be a multigraph? (c) If G has n vertices, can we determine how many edges it has? Sec 11.1 /15 15. For the undirected graph in Fig. 11.12, find and solve a recurrence relation for the number of closed v-v walks of length n ≥ 1, if we allow such a walk, in this case, to contain or consist of one or more loops. Sec 11.1 /16 16. Unit-Interval Graphs. For n ≥ 1, we start with n closed intervals of unit length and draw the corresponding unit-interval graph on n vertices, as shown in Fig...

Words: 1858 - Pages: 8

Free Essay

Optimal Packet Routing Scheme with Multiple Sources and Multiple Destinations

...source, multiple, multiple destinations. Given ‘n’ Source points (Distribution centers), and ‘m’ destination/consumer points. Location of the distribution and destination points described in their (x,y) co-ordinates. The measure of cost is the distance metric (length of the route). Output The output of the problem would be, which distribution center would serve which destination points and how the packet would be routed to minimize cost. Note: If the routes are represented as a graph then the graph would be a disconnected graph, depending on what destination nodes are served by which distribution center node. What is known? The general case of this problem, without any restrictions, can be modeled as Steiner Tree problem. It is a well known problem and its computation has been shown to be NPHard, by Garey, Graham and Johnson (1976). Approach In this analysis, I am considering the following 3 problems. 1. Multiple source Minimum Spanning Tree (M ST) 2. Multiple source Steiner Tree 3. Multiple source Traveling Salesman Problem (TSP) Multiple source TSP problem refers to the case where we have only one vehicle per distribution center, and it has to cover all the customers or destination points. The other two problems refer to the case where we have...

Words: 2950 - Pages: 12

Free Essay

Algorithmics

...List  Table of Contents Analysis of the Problem 4 Graph Searching 4 BFS: 4 DFS 4 Comparison of Algorithms 5 Features of BFS and DFS Algorithms 5 Minimum Spanning Tree 6 Prim’s Algorithm: 6 Kruskal’s Algorithm: 6 Feature of Prim’s and Kruskal’s Algorithm 7 Application 7 Shortest Path Problem 7 Shortest Path Algorithms 7 Adjacency Matrix:- 8 Adjacency List:- 9 Unweighted and Undirected Breadth First Search (BFS) 10 Pseudo Code for Breadth First Search (BFS) 21 Analysis Complexity of BFS 21 Depth First Search (DFS) 22 Algorithm for DFS 31 Analysis Complexity of DFS 31 DIKSTRA’S SINGLE SOURCE SHORTEST PATH 32 Algorithm for Dijkstra 39 Analysis 39 How Dijkstra’s Efficiency could be improved? 40 Kruskal’s Algorithm 41 Algorithm for Krushkal Algorithm 51 Analysis Complexity of Kruskal’s Algorithm 51 Prim’s Algorithm 52 Pseudo Code for Prims Algorithm 61 Analysis 61 Comparison of Time complexities with their analysis 62 Adjacency List and Adjacency Matrix 62 Description and Justification of chosen class 62 Definition of classes 63 Assumptions 64 Assumption of BFS: 64 Assumption of Prim’s 64 Assumption of Kruskal’s 64 References and Citations 65 Books: 65 Websites 65   Analysis of the Problem There are various data structures are used to represent graphs in computer memory such as adjacency list, incidence list, adjacency matrix, incidence matrix. Different algorithms are applied on these graphs like Prim’s algorithm, Dijkstra’s algorithm, Kruskal’s...

Words: 8195 - Pages: 33

Premium Essay

Unit 3 Ip

...Task Background: Graphs and trees are useful in visualizing data and the relations within and between data sets. Conversely, it is also important to be able to represent graphs as databases or arrays, so that programs for processing the data can be written. Part I: Adjacency Matrix and Shortest Path Construct a graph based on the adjacency matrix that appears below. Label all nodes with indices consistent with the placement of numbers within the matrix. ⌈0 | 6 | 0 | 5 | 0⌉ | | 6 | 0 | 1 | 0 | 3 | | | 0 | 1 | 0 | 4 | 8 | | | 5 | 0 | 4 | 0 | 0 | | ⌊0 | 3 | 8 | 0 | 0⌋ | | | | | | * Describe the graph and why it is consistent with the matrix. The Graph above is an undirected graph. As the lines are not directed towards a particular node, the lines or edges go both ways. It is consistent with the matrix because the matrix is defining the edges. * How many simple paths are there from vertex 1 to vertex 5? Explain. There are 3 paths. 1-2-5, 1-2-3-5, 1-4-3-5. * Which is the shortest of those paths? That would be the 1-2 path. As the sum equals 9 and is the shortest path. 1-2-3-5=15 and 1-4-3-5=17 Part II: Trees * Construct and describe a tree that indicates the following: * A college president has 2 employees who answer directly to him or her, namely a vice president and provost. * The vice president and provost each have an administrative assistant. * Three deans answer to the provost, and the heads of finance and alumni relations...

Words: 396 - Pages: 2

Free Essay

First Upload

...Exercises For Exercises 1-10, indicate which structure would be a more suitable choice for each of the following applications by marking them as follows: A. Stack B. Queue C. Tree D. Binary search tree E. Graph |1. |A bank simulation of its teller operation to see how waiting times would be affected by | | |adding another teller. | | |B | |2. |A program to receive data that is to be saved and processed in the reverse order | | |A | |3. |An electronic address book ordered by name | | |D | |4. |A word processor to have a PF key that causes the preceding command to be redisplayed. | | |Every time the PF key is pressed, the program is to show the command that preceded the | | |one currently displayed | | |A | |5. |A dictionary of words used by a spelling checker to be built and maintained. | | |D ...

Words: 2128 - Pages: 9

Free Essay

Dpop

...A Scalable Method for Multiagent Constraint Optimization Adrian Petcu and Boi Faltings {adrian.petcu, boi.faltings}@epfl.ch http://liawww.epfl.ch/ Artificial Intelligence Laboratory Ecole Polytechnique F´ d´ rale de Lausanne (EPFL) e e IN (Ecublens), CH-1015 Lausanne, Switzerland Abstract We present in this paper a new, complete method for distributed constraint optimization, based on dynamic programming. It is a utility propagation method, inspired by the sum-product algorithm, which is correct only for tree-shaped constraint networks. In this paper, we show how to extend that algorithm to arbitrary topologies using a pseudotree arrangement of the problem graph. Our algorithm requires a linear number of messages, whose maximal size depends on the induced width along the particular pseudotree chosen. We compare our algorithm with backtracking algorithms, and present experimental results. For some problem types we report orders of magnitude fewer messages, and the ability to deal with arbitrarily large problems. Our algorithm is formulated for optimization problems, but can be easily applied to satisfaction problems as well. 1 Introduction Distributed Constraint Satisfaction (DisCSP) was first studied by Yokoo [Yokoo et al., 1992] and has recently attracted increasing interest. In distributed constraint satisfaction each variable and constraint is owned by an agent. Systematic search algorithms for solving DisCSP are generally derived from depth-first search algorithms based on...

Words: 5452 - Pages: 22