Course Hero Logo

CSC 130 - Fall 2021 - Assignment 3 - BST.pdf - California...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 2 out of 6 pages.

California State University, SacramentoCollege of Engineering and Computer ScienceComputer Science 130:Data Structures and Algorithm AnalysisAssignment #3 – Binary Search TreeOverviewFor this assignment, you are going to create a Binary Search Tree (BST)with a minimal interface. You don't have to balance the tree. In fact, don'teven try it yet. We are creating a very basic tree class.For the sake of testing, we are going to restrict this tree to use Integersrather than the generic Object class. Like all programming assignments,work on it in parts.Part 1: Node ClassOverviewIn recursively defined structures, like trees, all the coding (and complexity)is found in the recursive structure itself. In the case of trees, the node willcontain the vast amount of the logic and behavior.The node will use a Key-Value system. The key is used to store and findnodes. The value field is completely passive.Interfacepublic class NodeNodeleftNoderightintkeyThe key. This key will be used to store the node into the tree.stringvalueThe value that the node contains.voidprint(int indent)This method will the structure of the tree. One node will be printedper line. You should use preorder tree traversal. Feel free toredirect the stream if you like. Please see the pseudocode below.voidadd(int key, String value)Adds the key to the correct position in the BST. If the key alreadyexists, do nothing.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 6 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
N/A
Tags
Recursion, College of Engineering and Computer Science, use code

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture