Write down the in-order, pre-order, and post-order traversal output of the following BST, then also add your answer to BSTManual.java in a string format: (number, comma, space, number, comma, space etc, like this: "66, 77, 88" In-order Pre-order Post-order 19 39 93 22 64 96 28 56 68 95 98 97

icon
Related questions
Question
/**
 * TODO: file header
 */
 
import java.util.*;
 
public class BSTManual {
 
/**
 * TODO
 * @author TODO
 * @since  TODO
 */
 
// No style for this file.
 
public static ArrayList<String>  insertElements() {
 
ArrayList<String> answer_pr1 = new ArrayList<>(11);
 
/*
* make sure you add your answers in the following format:
* answer_pr1.add("1"); --> level 1 (root level) of the output BST
* answer_pr1.add("2, X"); --> level 2 of the output BST
* answer_pr1.add("3, X, X, X"); --> level 3 of the output BST 
* the above example is the same as the second pictoral example on your
* worksheet
*/
 
//TODO: add strings that represent the BST after insertion. 
return answer_pr1;
 
}
 
public static ArrayList<String>  deleteElements() {
 
ArrayList<String> answer_pr2 = new ArrayList<>(11);
 
/*
* Please refer to the example in insertElements() if you lose track
* of how to properly enter your answers
*/
 
//TODO: add strings that represent the BST after 5 deletions. 
return answer_pr2;
 
}
 
public static ArrayList<String>  traversals() {
 
ArrayList<String> answer_pr3 = new ArrayList<>(11);
 
/*
* In this one, you will add ONLY and EXACTLY 3 strings to answer_pr3
* here's how you do it:
* answer_pr3.add("1, 2, 3, 4, 5") --> in-order traversal result
* answer_pr3.add("1, 2, 3, 4, 5") --> pre-order traversal result
* answer_pr3.add("1, 2, 3, 4, 5") --> post-order traversal result
* replace "1, 2, 3, 4, 5" with your actual answers
*/
//TODO: add 3 strings that represent 3 traversals. 
return answer_pr3;
 
}
 
 
}
Write down the in-order, pre-order, and post-order traversal output of the
following BST, then also add your answer to BSTManual.java in a string format:
(number, comma, space, number, comma, space etc, like this: "66, 77, 88"
In-order
Pre-order
Post-order
19
39
93
22
64
96
28
56
68
95
98
97
Transcribed Image Text:Write down the in-order, pre-order, and post-order traversal output of the following BST, then also add your answer to BSTManual.java in a string format: (number, comma, space, number, comma, space etc, like this: "66, 77, 88" In-order Pre-order Post-order 19 39 93 22 64 96 28 56 68 95 98 97
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer