LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-16-2004, 01:00 AM   #1
blackzone
Member
 
Registered: Jun 2004
Posts: 256

Rep: Reputation: 30
searching and hashtable question.


I have a list of string: "apple, orange, banana...."

and a string "watermelon"

what is the most effective way to check if watermelon is in the list of string?

would hash table be an effective way to do it?
 
Old 11-16-2004, 02:13 AM   #2
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
If there are lots of strings there (eg. >100), hash would be quite good (O(1) when there is no collisions) ; there is some strorage and hash generating overhead, though.

But for huge amount of strings, I would use tries to store the data (try googling for trie).

Last edited by ToniT; 11-16-2004 at 02:17 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
basic question about searching files balteo Linux - Newbie 1 09-03-2005 07:38 PM
hashtable/hashmap+linux+C saajii Programming 2 09-20-2004 07:32 PM
I have been searching but.... Jacksenflamed Linux - Newbie 6 03-17-2004 08:26 PM
SQL and searching question Robert0380 Programming 3 08-18-2002 11:34 PM
Searching mjgeiger Linux - Newbie 4 06-05-2002 07:26 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration