Write a narrative that describes how about designing

Assignment Help Computer Graphics
Reference no: EM13772025

1. First we need to compute the canonical form of each word. The canonical form of a word contains the same letters as the original, but in sorted order. So compose a static method

public static String canonicalForm(String word)

so that canonicalForm("computer") returns "cemoprtu", and canonicalForm("poor") returns "oopr". For this first step, put this method in a little program CanonWord.java that inputs one word and outputs its canonical form:

java CanonWord
Enter word: computer
cemoprtu

To implement canonicalForm, program a loop that unloads the individual characters in the argued string and puts them in an array of char or ArrayList<Character>. Thus canonicalForm("poor") gets an array of 4 chars ‘p', ‘o', ‘o', ‘r' or an ArrayList<Character> with the corresponding Characters. Then sort that array or ArrayList<Character>. Finally, use the sorted characters to build a new String by a loop of s = s + c, where s is a String, and c is a char or Character.

The program CanonWord needs a main method as well as the canonicalForm method. All it does is use a Scanner to get the word from the user and call canonicalWord to convert it, and print out the resulting canonical form.

2. Now write a program FindAnagrams that (in its main method) reads words.txt, and for each word there, adds it into an ArrayList<String> words and its canonical form into an ArrayList<String> codes. It obtains the canonical form by calling the same canonicalForm method you developed for CanonWord. Sort the codes ArrayList. Then hunt for duplicates in the sorted ArrayList codes. Any duplicates there will indicate anagrams in the original words. Keep track of the code with the most duplicates, and how many duplicates there are for it that you have found so far as you scan codes. Finally using this most duplicated code, scan the words list for words that have this canonical form and output them. Don't worry about ties at the longest length, just report on first anagram group with the most duplicated codes.

Test case (this is just an example, the actual words.txt you will be working with is MUCH longer):
words.txt codes sorted codes
rat art abt
hears aehrs abtt
share aehrs aehrs
tar art aehrs
bat abt aehrs
batt abtt art
shear aehrs art

The triplet of codes "aehrs" means that the corresponding words (hears, share, and shear) are anagrams. Similarly the duplicate of codes "art" indicates that rat and tar are anagrams. We are interested in the most duplicated codes, so the program should output as follows:

java FindAnagrams
hears
share
shear

We see there are two anagram groups here, one with code aehrs and the other with code art, so the most duplicated code is aehrs, corresponding to words hears, share, and shear.

For an example of comparing words next to each other in a sorted list, see line 34 of Vocabulary1.java, pg. 684, or line 30 of the program on the textbook's site.

Note that we are assuming that all the words in words.txt are in the same case, uppercase or lowercase. The textbook's words.txt is all in lowercase.

3. Write a narrative that describes how you went about designing and implementing these modifications, how you tested your program. Did you use the test case during development or did you use the final words.txt from the start, or what? Did you find it helpful that the canonicalForm computation was separately developed? Report on what you found to be the longest anagrams in the author's words.txt

Reference no: EM13772025

Questions Cloud

Create a new web application that displays a form : Create a new Web application titled Week8. Next, create a JSP that displays a form when the doGet method is invoked. The form will contain a post action that directs the form post back to the same JSP, which in the doPost method will save the form..
What is the pressure : Three Liters of gas at STP is mixed with another 3 liters of gas at STP. The volume is then reduced to 1 liter at standard temperature. What is the pressure?
Current methodology of sex offender treatment : Respond all given topics: Current Methodology of Sex Offender Treatment and Sex Offender Rehabilitation
The relationship of geography to other scientific discipline : Essay you are required to answer all five (5) of the questions. Although there is no set word limit for these essay questions, you will be graded on your knowledge of the material and the detail with which you write your answers.
Write a narrative that describes how about designing : Write a narrative that describes how you went about designing and implementing these modifications, how you tested your program. Did you use the test case during development or did you use the final words.txt from the start, or what?
How many degrees of freedom is the estimate based : What proportion of observed variation in hardness can be explained by the simple linear regression model relationship between hardness and elapsed time?
Explain value claim signifcance with thesis : Explain value claim signifcance with thesis. Pro body: Define values, 3 definition methods, 2 research pieces. Quote the dictionary. if you quote you need to site.
Impact of human resource management activities : "Exercise: Evaluating the Financial Impact of Human Resource Management Activities: Reduced Turnover Costs" in the course text, Human Resource Management Applications.
Mathemethical problems issues : How fast can your 4-bit adder/subtractor determine the sum or difference of two numbers?

Reviews

Write a Review

Computer Graphics Questions & Answers

  Distinguish between uniform scaling differential scaling

distinguish between uniform scaling differential scaling? or diffrence between uniform scaling differential

  Task in this lab you will develop the following image

task in this lab you will develop the following image manipulations that can be performed on a user-specified image.

  I need open gl gaming mini project in c using open gl

in c using open gl command i need any gaming project without any plagiarism. ltbrgt ltbrgtin c using open gl command i

  This is an opengl assignment using c my compiler is ms

this is an opengl assignment using c. my compiler is ms visual c express. details work on a particle and mesh

  Redraw the circle

In the first round, the circle should stay visible for 1 second and each subsequent round the visible time should be 25% shorter than the previous round

  1 on a day to day basis what are the general issues you

1. on a day to day basis what are the general issues you might deal with as a manger in the humane society animal

  Rank document relevance by number of times input keyword

You should also rank document's relevance by number of times input keyword occurs in document. How to rank document's relevance by number of times input keyword occurs in document.

  Why menu-driven interfaces continue to be popular

Suggest at least three (3) strategies for making menu-driven interfaces visually appealing in the modern computing environment.

  Tasknbsp write a one page paper summarizing your

tasknbsp write a one page paper summarizing your thoughts.bob pierce a gentle man of about 50 is the president of abc

  1 how could utv become an rs5 billion company by 2008 and

1. how could utv become an rs5 billion company by 2008 and an rs10 billion company by 2010? whatcould the role of the

  The security policy document outline

Using the GDI Case Study below, complete the Security Policy Document Outline

  Gui that takes text input from the user for name

You have a GUI that takes text input from the user for name, favorite color, and favorite food. On the GUI, the user will click "Enter the Information.

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