2

What is the data structure used for search suggestions like Google Suggest. Does it all depend on the application? Would be helpful someone give me a link to good reference!

GusP
  • 2,454
  • 2
  • 23
  • 32
Reddy
  • 1,620
  • 6
  • 26
  • 33

2 Answers2

4

Consider a Trie. Here's a discussion about good implementations. This book will give more in-depth coverage.

But this approach assumes that what has already been typed is spelled correctly. If that is not a reasonable assumption, you will need to do something more sophisticated.

Community
  • 1
  • 1
Dilum Ranatunga
  • 13,254
  • 3
  • 41
  • 52
1

You can search for "autocomplete".

Here's a tutorial for a jQuery plugin that does autocomplete.

Here's a video for how it's done.

And here's really a lot of information about a detailed version.

DOK
  • 32,337
  • 7
  • 60
  • 92