
1) Write a Java program to implement Dijkstra’s
function Dijkstra(Graph, source):
create vertex set Q
for each vertex v in Graph: // Initialization
dist[v] - INFINITY // Unknown distance from source to v
prev[v] - UNDEFINED //Previous node in optimal path from source
add v to Q / All nodes initially in l (unvisited nodes)
dist[source) - o // Distance from source to source
while Q is not empty:
U - vertex in Q with min dist[u] // Source node will be selected first
remove u from Q
for each neighbor v of u: // where v is still in Q.
atl - dist[u] + length(u, v)
if alt ‹ dist[v): // A shorter path to v has been found
dist[v] - alt
prev[v] - u
return dist[], prev[]
2) The output of the program should be the arrays list and prev. Recalll that list [i] is the distance from the start of the vertex i. prev[I] is the vertex that immediately precedes vertex i on the shortest path from the start vertex to vertex i.
3) The vertices should be numbered as follows; a=0, b=1, c=2, d=3, e=4, f=5, and z=6.
to generate a solution
a solution
- The implementation of a queue in an array, as given in this chapter, uses the variable count to determine whether the queue is empty or full. You can also use the variable count to return the number of elements in the queue. On the other hand, class linkedQueueType does not use such a variable to keep track of the number of elements in the queue. Redefine the class linkedQueueType by adding the variable count to keep track of the number of elements in the queue. Modify the definitions of the functions addQueue and deleteQueue as necessary. Add the function queueCount to return the number of elements in the queue. Also, write a program to test various operations of the class you defined.arrow_forward(Program) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters, such as zerocount, onecount, twocount, and so forth, to 0. Then generate a large number of pseudorandom integers between 0 and 9. Each time 0 occurs, increment zerocount; when 1 occurs, increment onecount; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of time they occurred.arrow_forward(Practice) State whether the following are valid function names and if so, whether they’re mnemonic names that convey some idea of the function’s purpose. If they are invalid names, state why. powerdensity m1234 newamp 1234 abcd total tangent absval computed b34a 34ab volts$ a2B3 while minVal sine $sine cosine speed netdistance sum return stackarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningOperations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks ColeC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage




