Questions
Implement two methods, find() and replace() relating to Binary Search Trees. Both of these methods must...

Implement two methods, find() and replace() relating to Binary Search Trees. Both of these methods must be recursive functions. The signatures for the functions must be:

 /* This method takes a tree node and a key as an argument and returns the tree node if the key is found and returns null if the key is not found. */ 
BST find(BST T, char key)
/* This method takes a tree node and a key as an argument and inserts the tree node if the key is already in the tree it does not insert the node. */
BST insert(BST T, char key)

You will also implement the preOrder(), inOrder(), and postOrder() tree traversal methods. These methods must also be recursive functions. The input for this program will be from the keyboard and accept single-character keys, labeled 'A' - 'Z'.

Rules:

1) You cannot delete any code in the BST class, adding code is okay.

2) All 5 methods MUST be RECURSIVE. No credit is given if a method is not recursive, even if it works correctly.

3) Do not assume any maximum length for any input string.

4) Do not need to test for an empty string or null case.

5) You are not allowed to add any arrays or ArrayLists or any Java built-in (ADTs), such as Lists, Sets, Maps, Stacks, Queues, Deques, Trees, Graphs, Heaps, etc. or add any class that inherits any of those ADTs.

6) The use of Java Generics is also not allowed.

Starter code which must be used:

import java.util.Scanner; // Import the Scanner class

public class BST {
  
public char key;
public BST left;
public BST right;

public BST(char c) {
key = c;
left = null;
right = null;
}
  
public static BST find(BST T, char key) {
// put your solution here
}

public static BST insert(BST T, char key) {
// put your solution here
}
  
public static void preOrder(BST T) {
// put your solution here
}
  
public static void inOrder(BST T) {
// put your solution here
}
  
public static void postOrder(BST T) {
// put your solution here
}
  
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
BST t = null;
String stream = input.nextLine();
for (int i = 0; i < stream.length(); i++)
t = insert(t, stream.charAt(i));
System.out.print("Preorder: ");
preOrder(t);
System.out.println();
System.out.print("Inorder: ");
inOrder(t);
System.out.println();
System.out.print("Postorder: ");
postOrder(t);
System.out.println();
System.out.println("Enter a character to search for: ");
char c = input.nextLine().charAt(0);
if (find(t, c) == null)
System.out.println("The character " + "'" + c + "' was not found.");
else
System.out.println("The character " + "'" + c + "' was found.");
}

In: Computer Science

On Android Studio, create a 4 function calculator. The only buttons you need are 0-9, *,...

On Android Studio, create a 4 function calculator. The only buttons you need are 0-9, *, /, +, -, a clear, and enter button. Use StringTokenizer or String.split for the calculator code.

In: Computer Science

Write a function which lets the user enter English words. The user can keep entering English...

Write a function which lets the user enter English words. The user can keep entering English words as long as the user has not entered the word “exit”. Once the user enters “exit” the function will return and print the list of all distinct words starts with English alphabets. Like: A: Ali, apple, … B: Bob, book … until Z. Write a python program for this question. Use main function.

In: Computer Science

assume n = 2^100. consider the following problem. given an unsorted list of size n you...

assume n = 2^100. consider the following problem. given an unsorted list of size n you can choose to sort it or not first. after this step, you get m queries q1, q2, ... qm. one by one of the form "is qi in the list?" Describe whether you would sort and what algorithm you would use if 1.) m= 10, and 2) m = 1000

In: Computer Science

Can you please explain loop invariant for Heapsort, in which Min-Heapify and Build-Min-Heap are correct

Can you please explain loop invariant for Heapsort, in which Min-Heapify and Build-Min-Heap are correct

In: Computer Science

state the input and output of the traveling salesman problem. give the best lower bound on...

state the input and output of the traveling salesman problem. give the best lower bound on length of optimal tour and prove

In: Computer Science

please use C++ Create a class named Byte that encapsulates an array of 8 Bit objects....

please use C++

Create a class named Byte that encapsulates an array of 8 Bit objects. The Byte class will provide the following member functions:

Byte - word: Bit[8] static Bit array defaults to all Bits false

+ BITS_PER_BYTE: Integer16 Size of a byte constant in Bits; 8

+ Byte() default constructor

+ Byte(Byte) copy constructor

+ set(Integer): void sets Bit to true

+ clear(): void sets to 0

+ load(Byte): void sets Byte to the passed Byte

+ read(): Integer16 returns Byte as Integer

+ place(Integer): Bit Return Bit& at passed Base2 place

+ NOT(): Byte returns this Byte with its bits not'ed

+ AND(Byte): Byte returns this Byte and'ed with passed Byte

+ OR(Byte): Byte returns this Byte or'ed with passed Byte

+ NAND(Byte): Byte returns this Byte nand'ed with passed Byte

+ NOR(Byte): Byte returns this Byte nor'ed with passed Byte

+ XOR(Byte): Byte returns this Byte xor'ed with passed Byte

+ XNOR(Byte): Byte returns this Byte xnor'ed with passed Byte

In: Computer Science

List the policies thst a small business woupd need to develop. Include in each of these...

List the policies thst a small business woupd need to develop. Include in each of these policies what its contents would address. Provide a summarry of the business, its operations, and a list of the major risks the policies are to address

In: Computer Science

This assignment requires you to use at least one loop and an array. You can refer...

This assignment requires you to use at least one loop and an array. You can refer to our book and any programs you have written so far. Make sure that your work is your own. Write a comment at the beginning of your program with your name and your birthday (month and day, does not need to include year). For example: John Doe, May 23. Create an array that will store whole numbers. The size of the array should be ten more than the month number of your birthday. Continuing the example, for a birthday in May, the array will be of size 15 since May is the fifth month and 5 + 10 = 15. Then let the user enter each value to store in the array. Perform input validation that the user enters numbers between 1 and the day of the month that is your birthday. (That is, a value is invalid if is less than 1. Similarly, a value is invalid if it is greater than the day of the month that is your birthday.) Continuing the example, for a birthday on the 23 of the month, the valid values the user can enter are 1 through 23. Go through the array and collapse the array into a single representative number as follows: i. First replace every three adjacent integers with the sum of the two numbers. For example, if the first three elements of the array are 1, 2, and 3, they become the single value of 6. For example [1, 2, 8, 9, 4, 13, 7, 1, 9, 10, 5] becomes [11, 26, 17, 15] ii. Go through the new array and modify any number that is larger than 12 to be the difference between it and 12. (You can use either subtraction or modulus for this.) Continuing the example, [11, 26, 17, 15] becomes [11, 14, 5, 3] Then iteratively continue collapsing the array until you have a single representative integer. Continuing the example: Add adjacent three integers in [11, 14, 5, 3] to get [30, 3] Then change it to become [18, 3] Add adjacent three integers in [18, 3] to get the single value of 21 which is modified to be 9 and the result is displayed to the user

In: Computer Science

In C++ Define enumeration data type menuItemName with enumerators of PlainEgg, BaconAndEgg, Muffin, FrenchToast, FruitBasket, Cereal,...

In C++

Define enumeration data type menuItemName with enumerators of PlainEgg, BaconAndEgg, Muffin, FrenchToast, FruitBasket, Cereal, Coffee, and Tea.

Use an array, menuList, of the struct menuItemType, with tree components: menuItem of type menuItemName, menuPrice of type double, and Count of type int.

Write a program to help a local restaurant automate its breakfast billing system. The program should do the following:

a. Show the customer the different breakfast items offered by the restaurant.

b. Allow the customer to select more than one item from the menu.

c. Calculate and print the bill

Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item):

Plain Egg​$1.45

Bacon and Egg​$2.45

Muffin​$0.99

French Toast​$1.99

Fruit Basket​$2.49

Cereal​$0.69

Coffee​$0.50

Tea​$0.75

Use an array, menuList, of the struct menuItemType, with three components: menuItem of enummenuItemName as described above, menuPrice of type double, and Count of type int. Your program must contain at least the following functions:

● Function showMenu: This function shows the different items offered by the restaurant and tells the user how to select the items.

● Function printCheck: This function calculates and prints the check. (Note that the billing amount should include a 5% tax.)

A sample output is:

Welcome to Johnny’s Restaurant

Bacon and Egg​1​$2.45

Muffin​1​$0.99

Coffee​2​$1.00

Amount Total​​$4.44

Tax​​$0.22

Amount Due​​$4.66

In: Computer Science

For the Boolean function F = x + yz’+ x’z Show the truth table. Simplify F...

For the Boolean function F = x + yz’+ x’z

  1. Show the truth table.
  2. Simplify F by using k-map as SoP form.

In: Computer Science

1. Load the cpus dataset from the MASS package. Use syct, mmin , mmax , cach...

1. Load the cpus dataset from the MASS package.

Use syct, mmin , mmax , cach , chmin, chmax as the predictors (independent variables) to predict performance (perf)
Perform the best subset selection in order to choose the best predictors from the above predictors.
What is the best model obtained according to Cp, BIC, and adjusted R2?
Show some plots to provide evidence for your answer, and report the coefficients of the best model obtained for each criterion.
Repeat using forward stepwise selection and also using backward stepwise selection. How does your answer compare to the best subset results?

In: Computer Science

You want to identify the purpose of a malware and possible damages that it has done...

You want to identify the purpose of a malware and possible damages that it has done to a computer network, after the executable file is discovered. Explain step-by-step approach that you will follow to reverse engineer the executable file by using static analysis tools. List all the tools that you will use and what type of information you will be able to gather by using that tool.

In: Computer Science

Must be written in C++ in Visual studios community In this lab, you will modify the...

Must be written in C++ in Visual studios community

In this lab, you will modify the Student class you created in a previous lab. You will modify one new data member which will be a static integer data member. Call that data member count. You also add a static method to the Student class that will display the value of count with a message indicating what the value represents, meaning I do not want to just see a value printed to the screen.

Change main so that it calls this new method towards the end of the program. Call the method using the static syntax; do not use one of the instances of the Student class.

You will also need to change the Student constructor so that it increments the new data member you added, count.

Explain why you get the value it displays. Use codes below.

FIRST CODE

#include <iostream>

#include "Student.h"

using namespace std;

int main()

{

Student rich(2);

rich.DisplayStudent();

Student mary(3);

mary.DisplayStudent();

return 0;

}

SECOND CODE

#include "Student.h"

Student::Student(int numGrades)

{

quanity = numGrades;

grades = new int[numGrades];

name = "rich";

grades[0] = 88;

grades[1] = 96;

}

Student::~Student()

{

delete[] grades;

}

void Student::DisplayStudent()

{

cout << "Grades for " << name << endl;

for (int index = 0; index < quanity; index++)

{

cout << *(grades + index) << endl;

}

}

THIRD CODE

#pragma once

#include <string>

#include <iostream>

using namespace std;

class Student

{

public:

Student(int numGrades);

~Student();

void DisplayStudent();

private:

string name;

int* grades;

int quanity;

};

In: Computer Science

Write a function matchSuit() that simulates repeatedly drawing a pair of playing cards from a shuffled...

Write a function matchSuit() that simulates repeatedly drawing a pair of playing cards from a shuffled deck (of 52 cards) until the pair of cards share the same suit (or you run out of cards). The function should return the total number of cards drawn. Use a while loop. To draw each card, call the drawCard function you wrote above.

In: Computer Science