Questions
Complete the Tree class within the following program: BalancingTrees.zip. There are three two classes and one...

Complete the Tree class within the following program: BalancingTrees.zip. There are three two classes and one driver in this program. You just need to complete or add the Tree class code.

In java please.

The code for tree class:

public class Tree {
   Node root;

   public Tree() {
       root = null;
   }
  
public int getHeight(Node node) {
if (node == null)
return 0;
return node.height;
}
  
public Node insertANDbalance(Node node, int element) {
  
   // base case
if (node == null)
return (new Node(element));
  
// inserting new elements into tree following Binary tree rules
if (element < node.key)
node.left = insertANDbalance(node.left, element);
else if (element > node.key)
node.right = insertANDbalance(node.right, element);
else
return node;
  
// updating heights of left and right
if (getHeight(node.left) > getHeight(node.right))
   node.height = 1 + getHeight(node.left);
else
   node.height = 1 + getHeight(node.right);
  
// balance tree as each new element is added to it
int balance;
if (node == null)
   balance = 0;
else
   balance = getHeight(node.left) - getHeight(node.right);
  
// left -> left
if (balance > 1 && element < node.left.key)
return rightRotate(node);
// right -> right
else if (balance < -1 && element > node.right.key)
return leftRotate(node);
// left -> right
else if (balance > 1 && element > node.left.key) {
node.left = leftRotate(node.left);
return rightRotate(node);
}
// right -> left
else if (balance < -1 && element < node.right.key) {
node.right = rightRotate(node.right);
return leftRotate(node);
}
  
return node;
}

   public Node rightRotate(Node root) {
       Node newRoot = root.left;
       Node Temp = newRoot.right;

       // Rotate
       newRoot.right = root;
       root.left = Temp;
      
       // Update
       if (getHeight(root.left) > getHeight(root.right))
           root.height = getHeight(root.left)+1;
       else
           root.height = getHeight(root.right)+1;

       if (getHeight(newRoot.left) > getHeight(newRoot.right) + 1)
           newRoot.height = getHeight(newRoot.left)+1;
       else
           newRoot.height = getHeight(newRoot.right)+1;
      
       return newRoot;
   }

   public Node leftRotate(Node root) {
       Node newRoot = root;
      
       // for students to complete for an assignment

       return newRoot;
   }
  


   public static void printTree(Node node, int n) {
   n += 5;

   // Base case
   if (node == null)
   return;
        
   printTree(node.right, n);
   for (int i = 5; i < n; i++)
   System.out.print(" ");
   System.out.println(node.key);
   printTree(node.left, n);
   }
}

The code for node class:

public class Node {
   protected int key, height;
   protected Node left, right;

   public Node(int item) {
       key = item;
       height = 1;
       left = right = null;
   }
}

The driver:

public class TreeDriver{
   public static void main(String[] args) {
       Tree tree = new Tree();

       /* 6
       * / \
       * 2 7
       * / \   
       * 1 4   
       * / \   
       * 3 5
       *   
       */
       tree.root = tree.insertANDbalance(tree.root, 6);
tree.root = tree.insertANDbalance(tree.root, 2);
tree.root = tree.insertANDbalance(tree.root, 1);
tree.root = tree.insertANDbalance(tree.root, 4);
tree.root = tree.insertANDbalance(tree.root, 3);
tree.root = tree.insertANDbalance(tree.root, 5);
tree.root = tree.insertANDbalance(tree.root, 7);
      
tree.printTree(tree.root, 0);
      
   }
}

In: Computer Science

sleep data analysis: a) What is the dataset “sleep” in R? and its description? b) Draw...

sleep data analysis:

a) What is the dataset “sleep” in R? and its description?

b) Draw boxplots for two drug groups in ONE plot.

c) Set up a hypothesis (null and alternative) for testing whether there exists an effect difference between two drugs. Using both words and symbols for hypothesis settings. (Hint: this is a paired sample test, rather than a general two sample t test.)

d) Use an appropriate formula to calculate the test statistic and find its p-value for part c) and draw a conclusion at the significance level α=0.05.

e) Check the function “t.test”in R, i.e, read the description of this function and its usage, values, and even play the examples provided at the end of the help page. What is the function description?

f) Use the function “t.test” in R to answer c) with the significance level α=0.05. (Hint: you need to change the “paired” status from FALSE to TRUE) g) Compare the conclusions in d) and f) Attach all the R code you used for this problem.

In: Computer Science

Java Program Make an interface called interface1 that has tow data fields- default_length=1 and Pi=3.14 Make...

Java Program

Make an interface called interface1 that has tow data fields- default_length=1 and Pi=3.14

Make a second interface called interface2 that has one method: double getPerimeter(),

Make an abstract class GeometricObject that implements the 2 interfaces. And make one method getArea as an abstract method.

Make a subclass of GeometricObject called Square. The square class will inherit the superclass methods and implements the required abstract methods.

Make a subclass of GeometricObject called Triangle. (This is an equilateral triangle.) Triangle class will inherit the superclass methods and implements the required abstract methods.

In another class called test,using polymorphism call, declare 6 objects. The objects should be enclosed in an ArrayList of GeometricObject.

GeometricObject obj1=new Square(2);

Geometric Object obj2= new Triangle(4);

ArrayList<GeometricObject> arr=new ArrayList();

Write a for loop to extract the objects and print out their data.

In: Computer Science

Matlab work. Pleaae dont copy from any source. Write a function that will accept a structure...

Matlab work. Pleaae dont copy from any source.

Write a function that will accept a structure as an argument and return two cell arrays containing the names of the fields of that structure and the data types of each field. Be sure to check that the input argument is a structure, and generate an error message if it is not.

In: Computer Science

This is in JAVA Shapes2D Write the following four classes to practice using an abstract class...

This is in JAVA

Shapes2D

Write the following four classes to practice using an abstract class and polymorphism. Submit all four classes.

Shape2D class

For this class, include just an abstract method name get2DArea() that returns a double.

Rectangle2D class

Make this class inherit from the Shape2D class. Have it store a length and a width as fields. Provide a constructor that takes two double arguments and uses them to set the fields. Note, the area of a rectangle is the length times the width.

Circle2D class

Also make this class inherit from the Shape2D class. Have it store a radius as a field. Provide a constructor that takes a double argument and uses it to set the field. Note, the area of a circle is PI times it's radius times it's radius.

Shape2DDriver class

Have this class provide a method named displayName() that takes an object from just any of the above three classes (you can't use an Object type parameter). Have the method display the area of the object, rounded to one decimal place.

In: Computer Science

In C++ Design an Essay class that is derived from the GradedActivity class: class GradedActivity{ private:...

In C++

Design an Essay class that is derived from the GradedActivity class: class GradedActivity{ private: double score; public: GradedActivity() {score = 0.0;} GradedActivity(double s) {score = s;} void setScore(double s) {score = s;} double getScore() const {return score;} char getLetterGrade() const; }; char GradedActivity::getLetterGrade() const{ char letterGrade; if (score > 89) { letterGrade = 'A'; } else if (score > 79) { letterGrade = 'B'; } else if (score > 69) { letterGrade = 'C'; } else if (score > 59) { letterGrade = 'D'; } else { letterGrade = 'F'; } return letterGrade; } The Essay class should determine the grade a student receives on an essay. The student's essay score can be up to 100, and is made up of four parts: Grammar: up to 30 points Spelling: up to 20 points Correct length: up to 20 points Content: up to 30 points The Essay class should have a double member variable for each of these sections, as well as a mutator that sets the values of these variables. It should add all of these values to get the student's total score on an Essay. Demonstrate your class in a program that prompts the user to input points received for grammar, spelling, length, and content, and then prints the numeric and letter grade received by the student.

In: Computer Science

Data Structures Homework – Singly Linked Lists Create a singly linked that represents a school. The...

Data Structures Homework – Singly Linked Lists

Create a singly linked that represents a school. The school has multiple classes. Each class has a different number of students.

class student

{

Long ID;

string Name;

string Address;

float grades[3];

student *below;

};

class Node // the node represents a class in school

{

int ID;

int NoOfStudents;

int NoOfQuizes;

student *t;// a linked list of students is allocated dynamically

Node *Next;

};

class school {

string Name;

Node *Head;

int n;//number of classes in school

};

First, you need to implement the following constructors and destructors:

1- School constructor: Creates an empty school. It takes the school name as a parameter and sets the number of classes to zero.

2- Class (Node) constructor: Sets the class ID, sets the number of students to zero, the NoOfQuizes to zero and the pointers to NULL.

3- Student constructor: Sets the student’s ID, Name and address which are passed as parameters once a student is created.

4- Student destructor: contains the cout statement: ”student destructor is called”

5- Class (Node) destructor: deletes all students in class.

6- School destructor: deletes all the classes in the school.

In your main function create an empty school by entering the name of the school from keyboard (this calls the school constructor), then display the following menu to the user and perform tasks accordingly.

In addition to constructors and destructors, you need to define a function to perform each of the following tasks.

Your program must keep on displaying this list until the user chooses Exit (12).

1. Create a class: This function creates a new class in the school by reading the class information from a text file that has the following format. The class is added to the end of the school linked list. Note that this will call the Node constructor (once)+ the student constructor (multiple times).

Class ID

NoOfStudents

Student ID Student Name Student Address

Student ID Student Name Student Address

Student ID Student Name Student Address

……..

2. Read quiz grades: This function takes the class ID and the number of the quiz (first:0, second:1, Final:2) from keyboard and reads the grades for all students in the class in a certain quiz. Sort the students alphabetically then read their grades (this calls the function sort students (8)).

3. Compute student’s average: Take a student’s ID and return his average

4. Add student: Enter class ID, read a student’s information (ID & name & address from keyboard), add a student to the beginning of the class list. Note that this calls the student’s constructor. Also, read (NoOfQuizes) grades for this student.

5. Delete student: Enter student’s ID, search for the student in the school and delete the student from his class (if found).

6. Delete class: Enter class ID, find the class, delete the list of students in the class (this uses class destructor) then delete the class node from the list (the rest of the school list should remain intact).

7. Sort students: Enter class ID and sort the students of that class based on their names in alphabetical order.

8. Find the student with maximum average in a certain class: Enter class ID, find student with maximum average, then display the student (name + ID).

9. Display student given his name: enter student’s name, find the student and display his ID, grades and average.

10. Display a class given its ID: enter a class ID, find the class and neatly display the information of all the students in that class.

11. Display school: Display all classes in a school. Display each class ID together with its students (ID, name and address of each student).

12. Exit .

In your main function, create a school and test all your work above.

make it clearly thanks..!!

In: Computer Science

Create a C++ project called RobberyLanguage. Ask the user to enter a word. Write a function...

Create a C++ project called RobberyLanguage. Ask the user to enter a word. Write a function that will receive the word, use the word to compile a new word in Robbery language and return the new Robbery language word. In the function: Use a while loop and a newline character (‘\0’) to step through the characters in the original string. How to compile a word in Robbery language: Double each consonant and put the letter ‘o’ between the two consonants. For example:" ENTER THE WORD: Welcome

original word is welcome , Robbery language: wowelolcocomome

process returned 0 (0*0) execution time :

press any key to continue "

Example of the definition of the function: string compileRobLanWord(char word[50]) Hints: Declare a new character string for the Robbery language word. A word in Robbery language has more characters than the original word. Therefor the new string must have its own index value. How it looks like in memory: Original word: S a m \0 2 0 1 2 3 Robbery language: S o S a m o m \0 0 1 2 3 4 5 6 7 Note: Remember to add the \0 character as the last character of the new word. In the main function: Example of the call statement in the main function: newWord = compileRobLanWord(word); Display the original word and the Robbery language word.

C#(VISUAL STUDIO)

In: Computer Science

Operating system ******Preemptive SJF************ The newly arrived process with shorter CPU burst will preempt the currently...

Operating system

******Preemptive SJF************

The newly arrived process with shorter CPU burst will preempt the currently executing process.

Draw the Gantt Chart and calculate the average waiting time.

Process

Arrival Time

Burst Time

Turn Around Time

Waiting Time

P4

0

5

P3

1

9

P2

2

4

P1

3

8

In: Computer Science

Run the following Java code and explain what it does. Show the image created by the...

Run the following Java code and explain what it does.

Show the image created by the code.

public class Main{

public static void main(String[] args) {

new MyFrame();

}

}

import javax.swing.*;

public class MyFrame extends JFrame{

MyPanel panel;

MyFrame(){

panel = new MyPanel();

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.add(panel);

this.pack();

this.setLocationRelativeTo(null);

this.setVisible(true);

}

}

import java.awt.*;

import javax.swing.*;

public class MyPanel extends JPanel{

//Image image;

MyPanel(){

//image = new ImageIcon("sky.png").getImage();

this.setPreferredSize(new Dimension(500,500));

}

public void paint(Graphics g) {

Graphics2D g2D = (Graphics2D) g;

//g2D.drawImage(image, 0, 0, null);

g2D.setPaint(Color.blue);

g2D.setStroke(new BasicStroke(5));

g2D.drawLine(0, 0, 500, 500);

//g2D.setPaint(Color.pink);

//g2D.drawRect(0, 0, 100, 200);

//g2D.fillRect(0, 0, 100, 200);

//g2D.setPaint(Color.orange);

//g2D.drawOval(0, 0, 100, 100);

//g2D.fillOval(0, 0, 100, 100);

//g2D.setPaint(Color.red);

//g2D.drawArc(0, 0, 100, 100, 0, 180);

//g2D.fillArc(0, 0, 100, 100, 0, 180);

//g2D.setPaint(Color.white);

//g2D.fillArc(0, 0, 100, 100, 180, 180);

//int[] xPoints = {150,250,350};

//int[] yPoints = {300,150,300};

//g2D.setPaint(Color.yellow);

//g2D.drawPolygon(xPoints, yPoints, 3);

//g2D.fillPolygon(xPoints, yPoints, 3);

//g2D.setPaint(Color.magenta);

//g2D.setFont(new Font("Ink Free",Font.BOLD,50));

//g2D.drawString("U R A WINNER! :D", 50, 50);

}

}

In: Computer Science

Science Model One share of Global Core Development Systems, Inc (an imaginary company with the abbreviation:...

Science Model

One share of Global Core Development Systems, Inc (an imaginary company with the abbreviation: Go-CDS) stock was priced at $14.59 on January 1, 2015. Your tasking in this problem is to determine how long does it take for a stockholder to double their money who has invested in Go-CDS? In other words, how long until the price per share has doubled.

Here are some facts about Go-CDS:

  • Very stable company with a proven track record of manufacturing.
  • The normal growth of Go-CDS's stock has averaged a monthly growth rate of 1.0000% in the share price. (This means that the price per share goes up by 1.0000% each month over the last month's price.)
  • Beginning in March 2015, each time Go-CDS releases a quarterly report (on the 15th of the months of March, June, September and December each year), the stock share price increased immediately by 2.5000% due to the continuing, favorable outlook for Go-CDS's products in the marketplace. This trend continues throughout the time period.
  • Due to a merger with another manufacturing company in the 15th month after 1/1/2015, the monthly growth rate increased to 1.1000% until the end of THAT calendar year (the last month of that year is the 24th month). Since then, the monthly growth rate increased to 1.5000% per month.
  • Unfortunately, due to a bad set of business decisions in 2017, the Board fired the CEO which instantly cut the share price on July 5, 2017 to $7.30 (the 31st month). A new CEO was immediately hired on July 10, 2017.
  • The company growth rate reset to 1.0500% per month after the new CEO was hired due to bad press.

Write a MATLAB program to solve the following questions: Use matlab to make plot

1. In what month does the stock exceed 2 times the price of $14.59?

2. Prepare a plot of the stock's per-month price movement over the course starting from the first month of year 2017 until the price has exceeded 2 times the price of $14.59. (You plot should start from month 25, and should cover the month that is the answer to Question #1.) You will need to adjust the plot routine to ONLY show these months.

To limit the plot to these months, add the following command after your xlabel and ylabel commands:

axis ([25, 56, 19, 31])
xticks (0:4:length(P))
yticks (0:2:31)

In: Computer Science

I need the java code for a 4-function calculator app on android studio (do this on...

I need the java code for a 4-function calculator app on android studio (do this on android studio). Please make sure all the requirements shown below are followed (such as the error portion and etc). The topic of this app is to simply create a 4 function calculator which calculates math expressions (add, subtract, multiply, and divide numbers).

The requirements are the following :

- The only buttons needed are 0-9, *, /, +, -, a clear, and enter button

- Implement the onclicklistener on the main activity

- The calcuator should use order of operations (PEMDAS)

- It should be able to continue from a previous answer (Ex: If you type 2+6 the calculator will display 8. If you then multiple by 2 the current result will simply be multiplied by 2)

- It should read the entire sequence of numbers and operators and save them into a String. The information can be read out of the String using a StringTokenizer. The delimiters will be the operators on the calculator.

- The entire mathematical expression will be displayed on the screen before the equal button is clicked.

- The equation will simply be evaluated in the order that the user types in the numbers rather than the precedence

- If the user enters an equation with invalid syntax, the output should display “error”. The calculator should also display “error” for any mathematical calculations that are impossible.

In: Computer Science

Java/JavaFX: Write up some simple sample code to demonstrate indirect recursion.  You can just use print statements...

Java/JavaFX: Write up some simple sample code to demonstrate indirect recursion.  You can just use print statements to demonstrate how they call one another.  

Submit your working .java file here for credit.

In: Computer Science

***************************************************** * USE UBUNTU (Linux) TERMINAL MODE COMMANDS ONLY * * DO NOT USE ANY EDITORS...

*****************************************************
   *   USE UBUNTU (Linux) TERMINAL MODE COMMANDS ONLY  *
   *   DO NOT USE ANY EDITORS TO CREATE THIS PROGRAM   * 
   *****************************************************
   
1) Create a file called lastNameFirstNameInitialpgm3.sh  ex: robinsonMpgm1.sh

2) Append to the above file the necessary commands that when this file is executed 
   it will display the following:

- Using your own set of multi-line comments enter your program identification 
  as described in the Syllabus, example:
  
  <<ID
  ************************************************** 
  Author   : Your Name 
  Course   : Course Name and Times 
  Professor: Michael Robinson 
  Program  : Program Number, Purpose/Description 
             A brief description of the program 
  Due Date : mm/dd/yyyy 

  I certify that this work is my own alone. 
  **************************************************
  ID
  
- Append to the file the following commands that when this file is executed it will do the following:
  
 1) Display Hello my name is:
 2) Display My user name is:
 3) Display Todays date and time is:
 4) Display This file has x lines
 5) Display This file has x words
 6) Display this file has x bytes
 7) Display Please enter any number
 8) Display Your number $number * 2 = XXX and display press any key to continue
 9) Display a new clean screen      
10) Display Enter a line of numbers to be added
11) Using enhanced for loop, display all numbers entered delaying the output
    of each number by 1 second each and then the total of adding thoses numbers:
    ex: 20 5 3 = 28
12) Using a while true loop request, accept and display data until it ends on 
    input mod 5 = 0
    using -lt and -gt comparison commands
    this uses if else 

In: Computer Science

Translate the recursive C function below to a recursive RISC-V procedure. long long int fun(long long...

Translate the recursive C function below to a recursive RISC-V procedure.
long long int fun(long long int x, long long int y)
{if (x == 0)
return (y);
else
return(fun(x-1, x+y));}
Write a non-recursive C version of the function from the previous question by eliminating the tail recursion using a goto statement. Then translate to a non-recursive RISC-V version.

In: Computer Science