Given a graph with integer edge weights between 1 and 5 (inclusive), you want to find the shortest weighted path between a pair of vertices. How would you reduce this problem to the shortest unweighted path problem, which can be solved with breadth-first search (BFS).
What will be an ideal response?
Answer: Replace each edge with weight i with a simple path of i edges each with weight 1. Then solve with BFS
You might also like to view...
Create a function that reverses the items in a list.
Note: Creating a new function is unnecessary as there is a built in reverse method for lists, but one could make a function that calls this one.
Which of the following is not a PHP data type?
a. integer b. float c. Boolean d. string e. array f. all are PHP data types
Which of the following is not true about text files which can be imported into Assess?
A) They are formatted consistently. B) They are normally created manually. C) The two most common are CSV and fixed-length text files. D) They are normally created by software.
Which of the following statements is false?
a. In Java SE 8, an interface may declare default methods—that is, public methods with concrete implementations that specify how an operation should be performed. b. When a class implements an interface, the class receives the interface’s default concrete implementations if it does not override them. c. When you enhance an existing interface with default methods—any class that implemented the original interface will break. d. With default methods, you can declare common method implementations in interfaces (rather than abstract classes), which gives you more flexibility in designing your classes.