Word tree data structure problem

Assignment Help JAVA Programming
Reference no: EM131715706

Introduction to Computer Science Assignment

Word Tree 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.

2386_figure.png

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.

Submit only the file WordTree.java as a zip file. Use the A3TesterPosted.java file to test your code.  You do not need to submit this tester file.

Attachment:- Assignment Files.rar

Reference no: EM131715706

Questions Cloud

Create a historical timeline describing the major events : Create a historical timeline describing the major events within the field of forensic science.Your timeline should bullet point the significant events .
Coefficient of kinetic friction : A mass of 10 kg is moving at 5.3 m/s on a horizontal surface and the enitre surface has friction with a coefficient of kinetic friction of 0.58.
Discuss visual perception and interpretation of events : What social pressures does the group exert upon you to alter your visual perception and interpretation of events. Explain
Horizontal surface with friction : A mass of 7 kg is moving at 7.9 m/s on a horizontal surface with friction. If y = 0 m for gravitational potential energy is the horizontal surface
Word tree data structure problem : COMP 250: Introduction to Computer Science Assignment. Read the provided code including the comments which explain what the various methods do
How are mental health programs delivered in prison : Describe the different types of cultures and subcultures you might face in prison.How are mental health programs delivered in prison?
Coefficient of static friction between the wheels : The coefficient of static friction between the wheels and track is 0.207. the acceleration of gravity is 9.9 m/s squared.
Define what can be done to prevent the food fights : What can be done to prevent the "food fights" which seem to break out every Thursday in the school cafeteria
Earth satellite remains in orbit at a distance : An earth satellite remains in orbit at a distance of 11494 km from the center of the earth. What speed would it have to maintain?

Reviews

len1715706

11/10/2017 3:49:04 AM

Topic: Java Programming. Submit only the file WordTree.java as a zip file. Use the A3TesterPosted.java file to test your code. You do not need to submit this tester file. 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. 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.

len1715706

11/10/2017 3:48:58 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.

Write a Review

JAVA Programming Questions & Answers

  Calculate the interval by dividing the largest array

Create a for loop that iterates through the smallest array to the largest array and keep adding the interval -

  Programming and logic tennis player array assignment

Programming and Logic Tennis Player Array Assignment - store the number of wins for the player's first year

  Import the file into eclipse and work on all the tasks

Import the file into eclipse and work on all the tasks in that file and on eclipse - Download the latest version of CuttlefishDinner program

  Write a java program to perform matrix multiplication

Write a java program to perform matrix multiplication - Your code will need to be able to read in these files, place the contents of each file into separate two-dimensional arrays and then perform the needed multiplication and place the output of t..

  Write a program that asks for number of ticket to purchase

Write a program that asks for the number of ticket to purchase. Then calculate and display the amount of the discount (if any) and the total purchase price.

  Write a program that converts date formats

Write a program that prompts the user to input an integer between 0 and 35. If the number is less than or equal to 9, the program should output the number; otherwise, it should output A for 10, B for 11, C for 12,..., Z for 35. (Hint: use the case..

  How does java support the concept of encapsulation

How does Java support the concept of encapsulation? Describe the difference between an object and a class. What is the difference between the contents of a Java variable of a primitive type and a Java variable of a class type?

  Briefly describe cloud service information security features

Briefly describe cloud service information security features from the services cloud vendors that you proposed.; (should keep the question back in your actual report)

  Write a generic linked list tree

Write a generic linked list tree and a generic linked list binary search tree class that inherits from your generic linked tree class

  Write java application that lets you create strong password

Write a java application that lets you create a strong password. The password should follow the following some criteria: (use your own creativity to come up with specific requirements).

  Chat monitoring system

The name of the project is chat monitoring system. in the file you will see the screenshot diagram 2A are my design, i want it to be upgrade, to look professional like the diagram 2B. please java, netbeans and GUI. please can I have only the client s..

  Develop and test html document that has checkboxes for apple

Develop and test an HTML Document that has checkboxes for apple (59 cents each), oranges (49 cents each), and Banana (39 cents each), along with a submit button.

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