PART1: RECURSION

REQUIREMENT:

Write an application that allows users to work with the recursion algorithm to calculate values of the following. The recursion algorithm of each one will be defined in a static function of a data type class

n! Factorial of an integer n where n provided from the keyboard
an a power n, where a and n are int numbers provided from the keyboard
Sum(n) Sum(n) = 1 + 2 + 3 + .. + n where n is an int provided from the keyboard
Sum (m, n) Sum(m, n) = m + (m+1), (m+2) + + n where m and n are int numbers provided from the keyboard
Fn Fibonacci sequence Fn = Fn-1 + F n-2; F0 = 0 and Fn1 = 1
GCD (n,m) The greatest common divisor (GCD) of two integers m and n; m n
where m, n are provided from the keyboard

The application will allow users to select the task to do. After finishing one task, users can select to work with another task until they want to exit

1. n! ( Factorial of an integer n)
2. an (a power n)
3. Sum(n) = 1 + 2 + 3 + .. + n
4. Sum(m, n) = m + (m+1), (m+2) + + n
5. Fibonacci sequence Fn
6. GCD (The greatest common divisor of m and n)

The m and n are integer number that are read from the keyboard The output should be, for example:

Factorial of n = 5 is 120
2 to the power 3 is 8
Sum from 1 to 10 is: 55
Sum from 5 to 7 is 18
The Fibonacci at 10 is 55
Greatest Common Divisor (GCD) of 120 and 90 is 30

PSEUDO-CODE

Provide the pseudo-code or flowchart of main

WHAT YOU NEED TO KNOW TO DO THIS LAB

The data type class only contains static methods to calculate the values of the above formula

How to write a static method:
To create a static method, you just need to add the keyword static to the heading of the method. For example:
public static int factorial (int n) { .. }

You have to apply recursion algorithm write the code of all static methods

How to access static members of other class in main()

PART2: BINARY SEARCH TREE DATA STRUCTURE

REQUIREMENT

Create an application that allows users can work on the information of students with the following tasks:

1. Insert
2. Fetch
3. Encapsulation
4. Update
5. Delete
6. Show all

INSERT

  • Allow users to enter the information of a candidate or a candidate with experience from the keyboard
  • Create the object then insert to the data structure

FETCH

  • Allow users to type a candidate id then search in the date structure for looking for the candidate or the candidate with experience. If it is found, print out the information on the screen otherwise display the message: "The candidate cannot be found"

ENCAPSULATION

  • Allow users to type a candidate id from the keyboard. Search in the date structure. If the candidate (or candidate with experience) is found, ask for new phone number from the keyboard and change the phone of the candidate (or candidate with experience).
  • Fetch the candidate (or candidate with experience) with the same provided id. Then compare the phone of the candidate (or candidate with experience) just fetched with the new phone.

If both the phone numbers are the same then display the message "Binary Search Tree structure is not encapsulated" otherwise display the message Binary Search Tree structure is encapsulated =[

UPDATE

Display the message to ask users to enter the candidate id. Using the candidate id to read the node out the data structure as a candidate (or a candidate with experience). Asking for the new degree from the keyboard and change the degree of the candidate (or the candidate with experience) with the new degree to have a new node. Update the data structure with the new node with the same candidate id.

Display the message to see if update successfully or not

DELETE

  • Display the message to ask users to enter the candidate id. Remove the node with the entered id
  • Display the message to see if delete successfully or not

SHOW ALL

Display all the candidate (or candidate with experience) are currently stored in the data structure

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.