help with strings

Hello I need help with the following algorithm:

We have a sorted list of strings( as in dictionary) and a string (a


  • [color=Blue]If you have a linked list - binary search will not be effective, because it requires that collection be accessed with an index and linked list does not have that ability. You need an array here.

    Once you have an array filled and sorted - you should be able to use binary search. In callback function for a search you need to check not the whole string, but only its prefix - it should be easy enough.

    And binary search will only give you the answer - if the prefix found or not. The full list of words starting with the prefix you will find using the found index. Go up the array (from index returned by BS) and find where the group of words begins (at which index), then go down the array (from index returned by BS) and find the end of the group.[/color]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion