(E,9,4)(C,8,2) (D,6,1) (E,9,4) (F,2,-1) (G,7,3) (1,1,7) (K,-1,5) (J,3,9) (M,4,6) (L,5,10)
2
void f4() - Suppose p is the 3rd node having right-child when performing the pre-order traversal of the tree from the root. Rotate p to left. Output in the file f4.txt must be the following:
(C,8,2) (D,6,1) (E,9,4) (F,2,-1) (G,7,3) (H,10,8) (1,1,7) (J,3,9) (K,-1,5) (L,5,10) (M,4,6)
(C,8,2) (D,6,1) (E,9,4) (F,2,-1) (G,7,3) (J,3,9) (H,10,8) (L,5,10) (1,1,7) (Κ,-1,5) (Μ,4,6)
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 depth-first traversal (to the file f1.txt) from the vertex i=4 (the vertex E) but display 6 vertices with their degrees from the 2nd vertex to the 7th vertex only. Hint: copy depth(...) to depth2(...) and modify the latter one. The array int deg[] already declared in the class
Close
+ 100%
Zoom