Write a program that should accept a file as input

Assignment Help Data Structure & Algorithms
Reference no: EM131290607

Assignment

For this assignment, your program should accept a file as input. First line in the input file contains the label of the source node. Then each subsequent line has the edges of a directed graph. Nodes are labeled as integers from 1 to 500 (maximum 500 nodes). Each row indicates an edge, the node label in first column is the tail and the node label in second column is the head. For example, the 2nd row looks Mot "1 2". This means the node with label 1 has an outgoing edge to the node with label 2.

Your task is to write a code (using BFS or DFS) to compute the shortest path between a source note,to all other nodes. Your output should contain the label for each node, and the shortest distance to that node from the source. For example, first row in the sample output indicates that the shortest distance from source node to node 2 is 1. And the last line indicates that the shortest path from source node to node 6 is 4.

Reference no: EM131290607

Questions Cloud

Subcontractor to do the mowing : Jack owns a lawn mowing company. His company contracts to provide lawn mowing services to Rachel. Jack hires a subcontractor to do the mowing. Which of the below statements is correct?
How can we reduce poverty in the united states : How can we reduce poverty in the United States?Will receiving a college degree improve your career opportunities?
Explain the usefulness of motivation theories : Share examples of how these theories have been exemplified in your personal life. Finally, explain the usefulness of motivation theories in your work as an education professional.
Analyze and evaluate the website presentation of the issues : analyze one website and design a full-size poster presentation to analyze and evaluate the website presentation of the issues.
Write a program that should accept a file as input : For this assignment, your program should accept a file as input. First line in the input file contains the label of the source node. Then each subsequent line has the edges of a directed graph.
Business model generation : In reference the book "Business Model Generation" by Alexander Osterwalder & Yves Pigneur, how does "Brainstorming New Business Models" by answering the What if questions impact successful businesses?
Visit and experience your artifact : Develop an outline for a detailed description of the object and its setting. Help your reader visualize the object in detail. Avoid assumptions. This section requires close direct experience, not research. Include at least four observations.
Calculate the gross proceeds per share : Howett Pockett, Inc., plans to issue 10.4 million new shares of its stock. In discussions with its investment bank, Howett Pocket learns that the bankers recommend a net proceed of $34.60 per share and they will charge an underwriter's spread of 5..
Explain what nature is according to that philosopher : Nature and Western Philosophy : Meta­ physical aspects of the current crisis.Research any non­Western philosopher of your choosing (e.g. a Chinese, Japanese, Indian, African / African diaspora or indigenous philosopher)and explain what nature is ac..

Reviews

Write a Review

 

Data Structure & Algorithms Questions & Answers

  What is the largest x such that the protocol performs x-bit

What is the largest x such that the protocol performs x-bit correction and what algorithm would you use to perform this correction? Give me the pseudo-code (or a sensible explanation)

  Describe the jsp life cycle

Draw a diagram of the various events and transformations. Describe how you might implement logging in as used in the workshops using the session mechanism explaining what Java classes are involved and using code snippets.

  Create algorithm which will prompt for-accept four numbers

Create an algorithm which will prompt for and accept four numbers, sort them into ascending sequence and display them to the screen. Your algorithm is to include a module

  Linked list

Let A and B be two structures of type linked list. Write a function for creating new linked list C that contains elements alternately from A and B beginning with first element of A. If you run out of the elements in one of the lists then append the r..

  Explain the functions of a network node manager

Describe the processes that take place during network discovery and mapping

  Write a breadth-?rst search algorithm

Write an algorithm to classify the edges of a directed graph G into the four categories: tree edge, back edge, forward edge and cross edge (de?ned in De?nition 7.14, pages 342-343).

  Design algorithm to solve spectral assembly problem

Design an algorithm to solve the Spectral Assembly problem under the above conditions. Does the problem have a unique solution?

  Creating a database with asp.net

Make a database with a table called "MyUsers" and "MyRole" The table should have the following columns.

  Write a program that implements kruskals algorithm

Write a program that implements Kruskal's algorithm

  Telephone number as a string

Write a program that inputs a telephone number as a string in the form (555) 555-5555. The program should use an object of class StringTokenizer to extract the area code as a token, the first three digits of the phone number as a token and the las..

  Creating dataflow diagram

Think about the level of detail involved with creating a dataflow diagram, why should the narrative be prepared? Explain why do we need the questionnaire?

  Show that diverse subset is np-complete

We can now define the Diverse Subset Problem as follows: Given an m × n array A as defined above, and a number k ≤ m, is there a subset of at least k of customers that is diverse? Show that Diverse Subset is NP-complete

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd