Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete question in Java Given a word w, you are to find the closest word to win a given dictionary D. Formulation Your word

Please complete question in Java

image text in transcribedimage text in transcribedimage text in transcribed

Given a word w, you are to find the closest word to win a given dictionary D. Formulation Your word w is a string of arbitrary length. Similarly, the dictionary D contains D String s of arbitrarily length. The distance 5 (w,w') between w and a word w' E D is defined as the number of changes needed to make to w to get w', where there are two acceptable changes: insert (c, i) - inserts character c after the i-th character of w; bulkRemove (i,j) - removes all characters in w from the i th character (inclusive) to the j th character (exclusive). Your task is to find: arg minwed 8(w, w'). Technicalities: You may assume all words are comprised of only lower-case English letters. In the event of a tie, the first word in D minimizing the expression should be returned. Example Suppose that your dictionary D contains following strings (one per line): oast oath ogre onyx OSS If you word wis ores, when: S(ores, oast) = 3 ... remove re, insert a, insert t S(ores, oath) = 4 ... remove res, insert a, insert t, insert h S(ores, ogre) = 2 ... insert g and remove s. S(ores, onyx) = 4 ... remove res, insert n, insert y, insert x S(ores, oss) = 2 ... remove re, insert s Since ogre and oss are tied, the first word in the dictionary ogre is returned as the closest match. Input format In our specific case, you will be given input in the following form: [DO] [D1] [Dn-1] -- - [wo] [w]] [w2] ... [Wk-1] --- The interpretation of the input is that the dictionary D has n words, Do... [Dn-1] that are terminated by the delimiter ---. The program is then to find dictionary entries closest to each of k words wo ... [Wx-1). The example problem would thus look as follows: oast oath ogre onyx oss 0 ores Output format Your code should return k lines, whose i -th line is the index of the dictionary entry closest to w;. In the case of our example, this would return

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions