Project to create a dictionary as a binary tree using java code.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Project to create a dictionary as a binary tree using java code.

  1. Data structure : A word in a dictionary will keep the key (the defined word) and a definition (another string). For each node we need to keep a link to the left subtree containing the words before the current word and a link to the right subtree containing the words after the current word.
  2. Test and initialize : a method that will initialize a binary tree with 15 terms from the textbook. Provide correct names and definitions for the test data.
  3. Print a binary tree : a method that will print a binary tree in the following format.

      LEFT NODE

ROOT NODE

      RIGHT NODE

For instance, a valid tree is shown below, please disregard the bullets:

Need to use a recursive function that will receive the number of spaces before a node (4 spaces for each level), and a node. The function will do nothing if the node is null. If the node has a left subtree, call it recursively to print the subtree, but with more spaces. Then print the spaces and the node key. Then print recursively the right subtree with more spaces. Test the method by showing the tree after each operation performed in step 2.

  1. Find a word in the dictionary : Need a method that will receive a word and return the definition if the word is in dictionary or null otherwise. Test the method with two words from dictionary and two not in the dictionary.

 

  1. Insert a word : Need a method that will receive a word and its definition. If the word is in dictionary, update the definition. If not, add the word to the dictionary. Test the method with two refined definitions and two new definitions. Print the dictionary after each operation.
  2. Check if leaf, single leaf and two leaves : Creating three methods that will check if a word is a leaf, has a single child or has 2 children. Returns true if the property holds, otherwise false. Check the method with various words: 2 leafs, 2 single child, 2 two children and 2 not in the dictionary. Print the dictionary after each operation.
  3. Delete a leaf node : Need a method that will receive a word and if the word is a leaf delete the node from the dictionary. Check the method with various words: 2 leafs, 2 single child, 2 two children and 2 not in the dictionary. Print the dictionary after each operation.

One way to implement is: create a method that will receive a subtree root node and a key to delete. If the node is a leaf and has the same key remove the node from the tree and return the resulted subtree. The caller must link the subtree.

  1. Delete a node with a child : Need a method that will receive a word and if the word has a single child delete the node from the dictionary. Check the method with various words: 2 leafs, 2 single child, 2 two children and 2 not in the dictionary. Print the dictionary after each operation.
  2. Delete a node with two children : Need a method that will receive a word and if the word has two children delete the node from the dictionary. Check the method with various words: 2 leafs, 2 single child, 2 two children and 2 not in the dictionary. Print the dictionary after each operation.
  3. Delete any node : Combine the previous 3 delete methods to create one method to delete any node. Check the method with various words: 2 leafs, 2 single child, 2 two children and 2 not in the dictionary. Print the dictionary after each operation.
  4. First and last word : Need a method that will return the first and the last word from the dictionary. Check the methods.
  5. Preorder : Need a method that will traverse the tree in preorder and show the words in the console. Check the method.
  6. Inorder : Need a method that will traverse the tree in inorder and show the words in the console. Check the method.
  7. Postorder : Need a method that will traverse the tree in postorder and show the words in the console. Check the method.
  8. Height of the tree : Need a method that will compute the height tree. Check the method.
  9. Find the word with longest definition: Need a method that will compute the word with the longest definition. Check the method.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY