Hey hey! That's reducible >-< Well... now if you are having your list sorted by length, starting with the longest word, then yes you can pass that list only once. If it's not ordered, you may decide between passing it once to sort it, and then pass it again to proccess it, or passing it once and convert it to an AVL tree (wiki that). You can code the comparison (check if a word starts or ends with the other word) in the code that adds nodes to the tree, so it will halt if it's wrong, please note that the sorting of the AVL tree will be by length not alphabetic order (one uses to forgive that :P).
Now, if you are always taking away letters, then you are sure that the result will always be shorter than the past word, so that's why we start with the longest one of the set and go decending length. Then you will read the next word, and check if the one you had starts or ends with the recently read, if so, then replace the word you had with the recently read and repeat, otherwise it's a failure, return false, throw an exception, show a message whatever it is. Does that helps? Theraot On 18 mayo, 08:23, Subrato Mukherjee <[email protected]> wrote: > Sure I will try my best to share what I have in mind. As mentioned before I > have a list of words (currently in txt file) which are reducible. I want to > first like to make a list of those words in such a manner that when I start > reducing the words to check if they are valid, I dont go through the whole > list. Instead I just use specific checks like if I removed o from orange I > will be checking if range is valid words or not from the list. If it is, > then I remove the next alphabet say r and I get ange which is invalid but > removing e will still result in valid word. I do this for all the words in > the list and find which is the longest word which can be reduced to single > valid alphabet. If while doing so I find there is more than 1 word that is > of similar length and reduced to single valid alphabet, then I need to > choose the most non-alphabetical word from that tie. > > I hope I was able to clear up if there any confusions about my objective > here. I will be sticking to c# at this moment to code this. > > Thanks > -S > > > > On Tue, May 18, 2010 at 8:31 AM, Raghu <[email protected]> wrote: > > Can you be kind enough to share more.... Like what are you trying to > > achieve here. Hash function/table would be a good solution too.... > > > --Raghu > > > On May 18, 2010, at 5:40 AM, Subrato Mukherjee <[email protected]> > > wrote: > > > Yes you are indeed right about the explanation I provided wasnt enough now > > that I go through it. Lets say the word I am currently checking is orange > > > so in this case, removing o will still result in range which is a valid > > word then removing e from the resulting word would still result in valid > > word rang. So basically I need to take out one letter at a time in such a > > manner that it results in valid word. I have the word list so I know the > > exact number of words and the words I am going go through. > > > orange > > range > > rang > > ran > > an > > a > > > I hope I was able to clarify this time around better > > > Thanks in advance > > > -S > > > On Tue, May 18, 2010 at 4:59 AM, Jamie Fraser < <[email protected]> > > [email protected]> wrote: > > >> I think you need to explain your problem a bit better! :) > > >> On Thu, May 13, 2010 at 5:42 PM, S < <[email protected]> > >> [email protected]> wrote: > >> > Hello all, > >> > I have a list of words (about 1600) and all of them are > >> > reducible to some extent. So if I have this list, what would be the > >> > best way to put them in the list to compare as I reduce them. I > >> > thought of hash function but that just seem to be a optimal solution. > >> > Is there anyone who can give some inputs for the same ? > > >> > I havent done any such programming and I am out of ideas > >> > so anything would be appreciated. > > >> > Thanks in advance > > >> > -S
