Question: Question 5 . [ programming question ] [ 2 5 marks ] You are given the tree below. You are given the Java code template

Question 5.[programming question]
[25 marks]
You are given the tree below.
You are given the Java code template in A1_Q5_yourstudentID. Java.
Replace yourStudentID in both the file name and the class name.
Write down your name and student ID as comments at the top of the Java file.
Complete the Java program to print the node labels with pre-order traversal.
We will test your program by the following commands in Windows command prompt:
javac A1_Q5_
// Name :
// Student ID :
//// Complete your code for Question 5 in
this file
// note: the number of the underscore symbol
(_) does not represent the number of
// characters that you need to fill
class Node {
String key;
Node left;
Node right;
public Node(String key){
// Fill the gaps
this.key =
---_;
this.left =
-----;
this.right =
-----i
}
}
class Traversal {
public static void preOrder(Node node)
{
traversal
// hints: about 4 lines
}
}
// Change
Question 5.[programming question]
[25 marks]
You are given the tree below.
You are given the Java code template in A1_Q5_yourstudentID. Java.
Replace yourStudentID in both the file name and the class name.
Write down your name and student ID as comments at the top of the Java file.
Complete the Java program to print the node labels with pre-order traversal.
Question 5 . [ programming question ] [ 2 5 marks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!