Tree Data Structure – Binary Search Tree Time To Complete
Tree Data Structure – Binary Search Tree Time to complete Two weeks
Liem Le | COSC2436 #1 School of Engineering and Technology COSC2436 – LAB 7 Title Tree Data Structure – Binary Search Tree Time to complete Two weeks COURSE OBJECTIVES LEARNING OUTCOME LAB OBJECTIVES -Apply Object Oriented programming -Complete the lab on time (Time Management) -Do the lab by following the project process: analysis, design, write the code, test, debug, implement -UML of data type class -Write comments -Write the code of data type classes including data members, no-argument constructor, parameter constructors, mutator methods, assessor methods, toString and other methods -INHERITANCE: write the code of child classes including, data members, constructors and other methods inherited from parent class -apply Polymorphism: using object of the parent class to point to object of child classes -control structure: if..else, switch, do..while -create object, access members of data type class -format the output in columns and double numbers with 2 decimal digits -display message box -create and access 4 operations of the tree data structure -Create a new project, add source file to the project, compile and run the program without errors and qualified to the requirement -Declare variables of int, double, String; -provide UML of data types -Create data types with data members, constructors, mutator methods -Apply Inheritance relationship -Apply polymorphism in the project -provide the pseudo-code of program -create and manage the menu to loop back to re-display after each task: using do.. while -Use switch statement to determine and define the action for each task -Format the output in columns and double numbers with 2 decimal digits -Display message box -can figure out the base case, reduce problem, general solution and recursion algorithm to write the recursion code for some problems, such as, * factorial (int n), sum(int n), sum (int m, int n), fibonacci(int n), and some other cases in real life, etc. -can create the tree and access operations of the tree: insert, fetch, delete, update and showAll Liem Le | COSC2436 #2 Skills required to do the Lab To do this lab, students have to know: -Review to create the pseudo-code or a flowchart of a lab -Review the syntax to create a data type class with data members, constructors, mutator accessor methods, method toString -Review how to define a child class including data member, constructor, toString and other methods inheriting from parent class: -Review how to declare an object in main(), how to access the methods of data type classes from main() -Review how to apply polymorphism -Review control structure: if..else, switch, do..while loop -How to set the decimal digits (2) of a double number -How to display the message box -How to recognize base case, reduce problem, general solution an recursion algorithm to help writing the recursion code -Understand the code of class BinarySearchTree and know how to access its operatons LAB INSTRUCTION REQUIREMENT PART 1 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 separated 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 + Fn-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 In 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 to the power 3 is 8 Liem Le | COSC2436 #3 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 HOW TO DO PART 1 Step: Write the code -start editor create the project, add RecursionStaticMethods_yourLastName file and write Recursion static methods -Add the driver class DemoRecursion_yourLastName and follow the pseudo-code and use java to write the code of the program Step3: compile and run the program Step4: debug if there is any errors to complete the program LAB7 PART2 REQUIREMENT PART 2: Create an application that allows users can work on the information of BankCustomer with the following tasks: 1.
Insert 2. Fetch 3. Uncapsulation 4. Update 5. Delete 6.
Show all INSERT -Allow users to enter the information of a BankCustomer from the keyboard -Create the object then insert to the data structure FETCH -Allow users to type a customer id then search in the data structure to look for the BankCustomer. If it is found, print out the information on the screen otherwise display the message: “The customer cannot be found†ENCAPSULATION -Allow users to type a customer id from the keyboard. Search in the date structure. If the customer is found, ask for new address from the keyboard and change the address of the customer -Fetch the customer with the same provided id to a different object. Then compare the their address.
If both the addresses 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 customer id. Using the customer id to read the node out from the data structure as a customer. Liem Le | COSC2436 #4 Asking for the new phone number from the keyboard and change the phone of the customer Update the data structure with the new node with new phone with the same customer id. Display the message “Update successful†or Updte failed†DELETE Display the message to ask users to enter the customer id. Remove the node with the entered id Display the message to see if delete successfully or not SHOW ALL Display all the BankCustomers are currently stored in the data structure HOW TO DO PART 2 Step1: Write the pseudo-code Step2: Write the code -start editor create the project, add BankCustomer_yourLastName that you had in lab 6 and add class BinarySearchTree (use the code on the page for your reference ON THE PAGE 396 LINE 110 return true CHANGE TO return false) --Also, the current code on page 396 does not take care deleting the rood, you should add the code to delete the root in 3 cases: root has no child, has one child and has two children -Add the driver class Demo_TreeDataStructure_yourLastName and follow the pseudo- code and use java to write the code of the program Step3: compile and run the program Step4: debug if there is any errors to complete the program HOW TO TURN IN RecursionStaticMethods_yourLastName.java Demo_Recursion_yourLastName.java RecursionStaticMethods_yourLastName.class Demo_Recursion_yourLastName.class Pseudo-code of part 1 BankCustomer_yourLastName.java BinarySearchTree.java Demo_TreeDataStructure_yourLastName.java BankCustomer_yourLastName BinarySearchTree.java Demo_TreeDataStructure_yourLastName Pseudo-code of part 2 IF YOU GET ANY PROBLEM TO SUBMIT FILE .class, YOU CAN SUBMIT ALL PROJECT INTO ONE FILE .zip or .rar TO SEND Liem Le | COSC2436 #5
Paper For Above instruction
This assignment involves developing two comprehensive Java applications focused on recursion algorithms and binary search tree data structures, designed to enhance students' understanding of object-oriented programming, data management, and algorithm implementation. The first part of the project emphasizes creating a calculator for various recursive functions such as factorial, exponentiation, sum calculations, Fibonacci sequence, and GCD, utilizing static methods within dedicated classes. Students are instructed to follow a systematic process of pseudo-coding, coding, compiling, and debugging, ensuring the application interacts effectively with users through menus and input validation.
The second part extends these concepts to managing bank customer data using a binary search tree (BST). Students will implement insert, fetch, update, delete, and display functionalities, emphasizing encapsulation, inheritance, and polymorphism in object-oriented design. A particular focus is placed on correctly deleting nodes, especially handling the root node with different child configurations, and ensuring data integrity through proper comparisons and updates. The project also includes developing clear pseudo-code, managing user interactions, and ensuring the program's robustness through testing and debugging. These tasks collectively aim to strengthen practical skills in data structures, algorithm development, and software engineering principles.
Part 1: Recursive Function Calculator
The first application is a recursive calculator that prompts users to select from six tasks: calculating factorial, raising a number to a power, summing integers, computing Fibonacci numbers, and determining the GCD of two integers. For each task, the program reads input values, calls the corresponding static recursive method, and displays the results in a formatted manner. Implementing this involves designing separate classes with static methods for each recursive function, and creating a driver class that manages user interaction with control structures like switch-case and do..while loops for menu navigation.
Students should design the pseudo-code logically outlining input collection, validation, method calls, and output formatting before coding. After coding the methods based on the mathematical definitions, students must compile, run, and debug their programs to ensure correctness. The application should repeatedly offer the menu until the user chooses to exit, demonstrating mastery of control flow, recursion, and user interface handling in Java.
Part 2: Binary Search Tree for BankCustomer Management
The second application involves creating a system to manage bank customer information utilizing a binary search tree (BST). Users can insert new customer records, fetch existing ones, encapsulate data, update details, delete records, and display all stored data. This requires designing a BankCustomer class that encapsulates relevant fields and using inheritance principles to extend functionality if necessary.
The BST implementation must correctly handle insertion and deletion, including the intricate cases of deleting the root node with zero, one, or two children. Special attention is needed to modify the tree structure without compromising data relationships. The application must facilitate searching by customer ID, updating contact information, and comparing data to demonstrate encapsulation principles.
Throughout this process, students should produce pseudo-code outlining each operation, implement the classes and driver program in Java, and test extensively to resolve errors. Proper management of object references, data integrity, and user interaction mechanics are crucial. The project’s goal is to solidify understanding of data structures, object-oriented concepts like inheritance and polymorphism, and practical programming skills for real-world applications.
References
- Deitel, P. J., & Deitel, H. M. (2014). Java How to Program (10th ed.). Pearson.
- Livermore, D. (2012). Data Structures and Algorithms in Java. McGraw-Hill Education.
- Gaddis, T. (2018). Starting Out with Java Programming. Pearson.
- Goodrich, M. T., Tamassia, R., & Goldwasser, M. H. (2014). Data Structures and Algorithms in Java. Wiley.
- Zusman, L., & Willen, S. (2017). Object-Oriented Programming with Java. Springer.
- Koffman, E. B., & Wolczko, M. J. (2014). Data Structures: Abstraction and Design Using Java. Johns Hopkins University Press.
- ISO/IEC 14882:2017 (Programming language C++ — ISO/IEC Standard).
- Morin, P. (2014). Data Structures, Algorithms, and Software Principles in Java. Morgan Kaufmann.
- McConnell, S. (2004). Code Complete: A Practical Handbook of Software Construction. Microsoft Press.
- Effective Java (3rd Edition) by Joshua Bloch (2018). Addison-Wesley Professional.