Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 29.5, Problem 29.5.5CP
Program Plan Intro
Weighted Graph:
A graph is termed as weighted graph if each edge of the graph is assigned a weight. The weighted edges stored in the weighted graphs can be stored in adjacency lists.
Weighted edges can be represented using a two-dimensional array. An weighted edge can be represented as “WeightedEdge(u,v,w)”, where “u” and “v” are edges and “w” represents the weight between them.
Example of storing edge in a weighted graph:
Object[][] edges =
{ new Integer(0), new Integer(1), new SomeTypeForWeight(8) };
Spanning Tree:
In computer science, a Spanning Tree for a graph “G” is a subgraph of “G” that it is a free tree connecting all vertices in “V”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
C
C
î
î
↑
7
8
E
A
6
8
9
D
4
B
Starting at vertex B, what is the shortest path length to each vertex?
A: Ex: 1
B:
C:
D:
E:
Fill in the blank
Dijkstra's algorithm works because, on every shortest path p from a source vertex u to a target vertex v, there is a (predecessor) vertex w in p immediately before v such that removing v from p yields the shortest path from u to w. In other words, the path through the previous vertex is also the shortest path. Thus, choosing an edge from the previous vertex that brings us to v with the __ cost always yields the shortest path to v.
When a vertex Q is connected by an edge to a vertex K, what is the term for the relationship between Q and K? *a) Q and K are "insecure."b) Q and K are "incident."c) Q and K are "adjacent."d) Q and K are "isolated."
Chapter 29 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 29.2 - Prob. 29.2.1CPCh. 29.2 - Prob. 29.2.2CPCh. 29.3 - Prob. 29.3.1CPCh. 29.3 - Prob. 29.3.2CPCh. 29.3 - Show the output of the following code: public...Ch. 29.4 - Prob. 29.4.1CPCh. 29.4 - Prob. 29.4.2CPCh. 29.4 - Prob. 29.4.3CPCh. 29.4 - Prob. 29.4.4CPCh. 29.4 - Show the output of the following code: public...
Ch. 29.5 - Prob. 29.5.2CPCh. 29.5 - Prob. 29.5.3CPCh. 29.5 - Prob. 29.5.4CPCh. 29.5 - Prob. 29.5.5CPCh. 29.5 - Prob. 29.5.6CPCh. 29.5 - Show the output of the following code: public...Ch. 29.6 - Prob. 29.6.1CPCh. 29.6 - Prob. 29.6.2CPCh. 29.6 - Prob. 29.6.3CPCh. 29 - (Modify weight in the nine tails problem) In the...Ch. 29 - (Find a minimum spanning tree) Write a program...Ch. 29 - (Create a file for a graph) Modify Listing 29.3,...Ch. 29 - Prob. 29.11PECh. 29 - Prob. 29.12PE
Knowledge Booster
Similar questions
- Show what the final distance and previous array values will be after running the shortest path algorithm from class on the following graph, starting at vertex 2: 1 6 5 4 4 4 2 7 0 5 5 6 2 2 3 13 6arrow_forwardstruct Neighbors { VertexT vertex; WeightT weight; }; map<VertexT, vector<Neighbors>> adjList; What is the worst case time complexity for this version of addEdge? bool addEdge(VertexT from, VertexT to, WeightT weight) { if ((adjList.count(from) == 0) && (adjList.count(to) == 0)) { return false; } Neighbors temp; temp.vertex = to; temp.weight = weight; for (auto &e: adjList.at(from)) { if (e.vertex == to) { e.weight = weight; return true; } } adjList[from].push_back(temp); return true; } V is the number of total vertices in the graph, E is the average number of edges per vertex. O(logV + E) O(E+V) O(ElogV) O(logV) O(1) O(V)arrow_forward3. What is the shortest path from vertex 'd' to 'h'? You may use Dijkstra's algorithm or any other method. Answer in this format: a-b-c-d-e-f (h 3 b 2 2. 4 2 5 1 3arrow_forward
- Question 1. Find the shortest paths from a vertex with the remainder when the last digit of your student number is divided by 9 to all other vertices using Dijsktra's Algorithm. Construct a table as shown in the class. You can consider an undirected edge as two opposite directed edges. (20P) 8 -7 4 0 -11 N 8 6 6 4 2 5 14 S 10arrow_forward3. Step through Dijkstra's algorithm to calculate the single-source shortest paths from A to every other vertex. Show your steps by filling in the tables shown below. 14 D E Step 0: Step 3: V E V B ID E A d[V] Pred[V] nil Color[V]W B IC ID IF A d[V] Pred[V] Color[V] Inil nil Inil W Inil nil W W W JA IB IC D E IF V d[V] Step 1: Step 4: Iv A. B. D E JA IB ID E d[V] Pred[V] Color[V] Pred[V] Color[ V] V V d[V] [AlP Step 2: Step 5: V d[V] Pred[V] Color[V] IB IC ID E IF V JA IB IC ID E d[V] Pred[V] Color[V] V V d[V] d[V] Step 6: Iv A d[V] Pred[V] IB IC ID E Color[V]arrow_forwardAlert dont submit AI generated answer. Write a program that reads a weighted graph and an initial vertex.The program must print on the screen the minimum paths obtained by Dijkstra's algorithm. Input: Receives n, m and s; n is the total number of vertices, m the total number of arcs and s is the initial vertex.Next, m lines, each line with a trio of integers, corresponding to the beginning and end of the arc, followed by the weight of the arc.(Vertices are identified from 0 to n-1.) Output: Prints the shortest paths obtained by Dijkstra's algorithm. Exemple: Input: 5 10 00 1 100 4 51 2 11 4 22 3 43 2 63 0 74 1 34 2 94 3 2 Output: [0, 8, 9, 7, 5][-1, 4, 1, 4, 0]arrow_forward
- Input: 6 8 -> n, m ( vertices, edges ) 1 2 3 1 ( first two numbers specify end-point vertices, 3rd number is the weight, and fourth 0 or 1. 1 = edge belongs to F, 0 edge doesn't belong to F 2 3 7 0 1 4 4 0 3 6 3 0 3 4 2 0 4 5 2 1 5 6 6 1 4 6 1 0 Ouput: 17arrow_forwardDijkstra's shortest path algorithm is run on the graph, starting at vertex C. A: Pick B: C: D: E: Pick Pick Pick E Pick 7 Upon completion, what is each vertex's predecessor? 5 B A 1 9 1 D 5 Carrow_forwardUse your assigned number of vertices from “Part 3” of the “Finite Math Assignment Form: Task 3” supporting document to do the following: Assigned number : 11 F. Create a weighted connected graph with the following characteristics: • The assigned number of vertices are alphabetically labeled starting with A. • Vertex A is not adjacent to vertex G. • At least two vertices have a degree greater than 2. • All weights are greater than 0. • No weights are the same. 1. Identify the degree of each vertex in your graph. 2. Explain whether the graph has an Euler trail, using definitions, properties, or theorems. 3. Describe a path from vertex A to G. 4. Find the total weight of the path from part F3. Show all work. Use the weighted graph I attached please.arrow_forward
- To help jog your memory, here are some definitions: Vertex Cover: given an undirected unweighted graph G = (V, E), a vertex cover Cy of G is a subset of vertices such that for every edge e = (u, v) = E, at least one of u or v must be in the vertex cover Cy. Set Cover: given a universe of elements U and a collection of sets S = {S₁, ..., Sm}, a set cover is any (sub)collection C's whose union equals U. In the minimum vertex cover problem, we are given an undirected unweighted graph G = (V, E), and are asked to find the smallest vertex cover. For example, in the following graph, {A, E, C, D} is a vertex cover, but not a minimum vertex cover. The minimum vertex covers are {B, E, C} and {A, E, C}. A B E с F D Then, recall in the minimum set cover problem, we are given a set U and a collection S = {S₁, ..., Sm} of subsets of U, and are asked to find the smallest set cover. For example, given U := {a, b, c, d}, S₁ := {a, b,c}, S₂ = = {b,c}, and S3 := {c, d), a solution to the problem is C's…arrow_forwardCorrect answer will be upvoted else downvoted. Computer science. There is another fascination in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be addressed by a chart with a limitless number of vertices marked 1,2,3,… . There is a guided edge from vertex u to vertex u+v if and provided that u&v=v, where and indicates the bitwise AND activity. There could be no different edges in the chart. Animal specialist has q inquiries. In the I-th question she will inquire as to whether she can venture out from vertex ui to vertex vi by going through coordinated edges. Input The main line contains an integer q (1≤q≤105) — the number of inquiries. The I-th of the following q lines will contain two integers ui, vi (1≤ui,vi<230) — an inquiry made by Zookeeper. Output For the I-th of the q inquiries, output "YES" in a solitary line if Zookeeper can head out from vertex ui to vertex vi. In any case, output "NO". You can print your reply regardless. For…arrow_forwardDynamic Programming - Finding the Best Delivery Route Problem: Assume that you work for a pizza bakery as a delivery boy/girl. You are responsible for delivering pizzas prepared based on online orders. You collect orders once an hour, then start delivering. You would like to determine the route where you deliver all pizzas in minimum time. You can illustrate this problem as follows: The bakery and customers are vertices and all of them are connected (there is no pair of vertices that are not connected with an edge. The weight of edges is the time that you need to take to travel between vertices. The edges are two-way (your graph is undirected). Please solve this problem using the DP technique. Show five steps of DP.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education