Define a special kind of rooted tree

Assignment Help JAVA Programming
Reference no: EM131717061

WordTree Data Structure

Here we define a special kind of rooted tree that we use to efficiently index words by storing their prefixes. The main property of this tree is that each edge corresponds to a character. Thus the path from the root of the tree to any node in the tree defines a string. The string defined by each node is a prefix of all strings defined by the descendents of that node.

Below is an example tree. It contains the following words: a, and, ax, dog, door, dot. You will note that the dashed nodes correspond to prefixes in the tree (an, d, do, doo) that are not in our list of words. The tree must also keep track of this distinction by storing for each node whether it corresponds to a word or not.

Note that if C is the set of all possible characters defined at the edges, then each node can have at most k = | C | children, where the | C | notation just means the number of elements in set C.

2437_figure.jpg

What You Need To Do

Read the provided code (WordTree.java, A3TesterPosted.java), including the comments which explain what the various methods do. This will take you some time, so go slow and read the code carefully. Note that the WordTree class has a private inner class TreeNode.

For the WordTree class, fill in the missing code for the following methods:

- createChild(), toString() for the inner class TreeNode
- getPrefixNode(), insert(), contains(), getListPrefixMatches()

We suggest you implement them in the order listed above. To get started, you may wish to add a main() method to the WordTree class. Eventually you should move on to using the Tester file. Don't forget to delete the main method when you submit !

You may only use Java String methods length() and charAt(). In particular, do not use String searching methods such as String.startsWith(), String.substring(), etc. The point of the assignment is for you to organize and compare strings using this tree data structure.

Only add code in the area where it says to add code. The grader may be sensitive to any changes that you make outside that area. Any helper methods that you wish to write should be added at the end of the WordTree.java file.

Note that all methods and also the inner class have been given the public access modifier. This was done to simplify grading. As you will learn later in the course, typically one does not make all methods public.

Attachment:- Java file.rar

Reference no: EM131717061

Questions Cloud

Explain wage and employment figures : What are some primary ways in which analysts may use a model of the labor market to explain wage and employment figures for healthcare workers?
Mention the application of the theories : After considering these theories, what allocation of responsibility between the company and the victim do you think would have been fair?
What is a financial intermediary : What are its key characteristics? Is a bank a type of financial intermediary? What other financial-services companies are financial intermediaries?
What roles do religions play in appiahs analysis : Discussion Board: "What roles do religions play in Appiah's analysis? How is your approach similar to or different from his?"
Define a special kind of rooted tree : Define a special kind of rooted tree that we use to efficiently index words by storing their prefixes. The main property of this tree is that each edge
Intermodal regarded as an economical option : Why is intermodal regarded as an economical option? What are some advantages/disadvantages of intermodal?
What sensor resistance r will null the bridge : What sensor resistance, R, will null the bridge? ii. What is the off-null voltage if R changes by 0.5 O? What is the temperature if the TC voltage is 22.87 mV?
Describe the principal similarities among companies : Using Standard & Poor's Market Insight, Educational Version, available to users of this McGraw-Hill book, describe the principal similarities and differences.
From a strategic management prospective : From a strategic management prospective answer the following: Using the Five Forces model, explain the prospects for profitability of the steel Industry

Reviews

len1717061

11/11/2017 1:54:34 AM

Submit a single zipped file A3.zip which contains the modified WordTree.java file, to the myCourses assignment A3 folder. Include your name and student ID number in the comment at the top of the WordTree.java file. In this assignment, you will work on the problem of storing a set of n words in a tree data structure, and a method for efficiently finding all the words that have a given prefix. You should be familiar with the latter problem through the autocomplete feature found on cell phones, web forms, Eclipse. For instance, if you type in “aar", then the autocomplete feature may suggest aardvark, aardvarks, aardwolf, aardwolves, aargh.

len1717061

11/11/2017 1:54:27 AM

• The T.A.s handing this assignment are Ram and Navin. Their office hours and location and email contacts will be posted on mycourses Announcements. • Same general instructions as Assignments 1 and 2, in particular, the late penalty. • We will deduct at least 20 points for any student who has to resubmit after the due date (i.e. late) because the wrong file or file format was submitted. This policy will hold regardless of whether the student can provide proof that the assignment was indeed “done” on time. This includes submitting a .class file, starter code, a rar or 7z format.

Write a Review

JAVA Programming Questions & Answers

  Create and test some of the classes for the problem scenario

CS310- The assignment this week is to create and test some of the classes for the problem scenario above. These classes will be used to implement data structures in later assignments.

  Provide java code to create and initialize an array

Provide Java code to create and initialize an array of integers (Java primitive int), floats or any other Java primitive type of your choice. You pick the array name and length.

  Elements from a html document

Function test Count List Elements should simply retrieve an array of all list elements on the page and assert that their total count is 3.

  Explain java stack and heap

I am posting the questions as reference, but I am requesting information about how to do these types of questions generally, not to have them done for me.

  Chat server java program

Edit a chat server java program: the files is a perfect running a chat server java program. I need to make the layout a little bit different then it is now. i also want to add imoji icons (emotion icons) into the program.

  Redesign the grading program as an object-oriented design

redesign the grading program as an object-oriented design. We will start with a simple Student class. The student will have a name, an id (as a String) and a set of grades (as doubles)

  Create dict letter frequencies that reads the file

createDictLetterFrequencies that reads the file and also takes a parameter n. This method should return a dictionary of dictionaries. The outer dictionary associates the previous n letters of a word with an inner dictionary, which indicates the frequ..

  Method that reads a text file and returns a list of tokens

Write a method that reads in a text file and returns a list of the tokens (preferably alphanumeric) in that file. Write a method to print out frequency results.

  Write a portion of a program for a church website

Write a portion of a program for a church's website. The program will be used for a chatting feature, which should include an Input Box that requests the user's name.  The message box should include the user's name and the Scripture of the Day (ch..

  Details of all advertisers registered with the service

Create a list of 6-7 different customers of both types with made-up details built in to the client program - display the details of all advertisers registered with the service,

  Modify the numbers guessing game program

Modify the numbers guessing game program. Suppose that the variable num and guess are as declared and the diff is an int variable.

  Program to convert temperature from fahrenheit to celsius

Write a Java program to convert temperature from Fahrenheit to Celsius - Change them to use a keyboard scanner instead of hard-coding values.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd