Question paper (build 07.05.20.19)
void f3() - Suppose p is the 4-th node when performing the post-order traversal of the tree and f is the father of p. Delete the node f by copying. Output in the file f3.txt must be the following:(Η,1,7) (Κ,4,6) (1,5,5) (1,3,9) (F,2,3) (G,7,8) (D,6,1) (Ε,9,4) (C,8,2)
(Κ,4,6) (1,5,5) (1,3,9) (Η,1,7) (6,7,8) (D,6,1) (Ε,9,4) (C,8,2)
void f40) - Suppose p is the 4-th node when performing the post-order traversal of the tree. Calculate the height of sub-tree with root p and suppose this height is k, then set p.info.wing = k. Output in the file f4.txt must be the following:(Η,1,7) (Κ,4,6) (1,5,5) (1,3,9) (F,2,3) (6,7,8) (D,6,1) (Ε,9,4) (C,8,2)
(Η,1,7) (Κ,4,6) (1,5,5) (1,3,3) (F,2,3) (6,7,8) (D,6,1) (Ε,9,4) (C,8,2)
Question 3: (2 marks)
In this question you should complete some methods in Graph.java file.
The class Graph is the implementation of a graph. The following methods should be completed:
. void f1()-Perform breadth-first traversal (to the file f1.txt) from the vertex i=2 (the vertex C) but display 5 vertices from the 2nd vertex to the 6th vertex only. Hint: copy breadth(...) to breadth2(...) and modify the latter one. Content of the output file f1.txt must be:CAHBDEIGF
AHBDE
.
void f2() - Apply the Dijkstra's shortest path algorithm to find (1) the shortest path from vertext
2 (C) to vertex 5 (F), then (2) from vertex 1 (B) to vertex 6 (G). Write 3 lines to the file f2.txt: line
1 contains vertices in shortest path (1), line 2 contains the shortest distance in (1), line 3 contains
100%
X
2
Zoom
Close