Re: NSDictionary fast search
Re: NSDictionary fast search
- Subject: Re: NSDictionary fast search
- From: Allan Odgaard <email@hidden>
- Date: Mon, 9 Feb 2004 23:09:17 +0100
On 7. Feb 2004, at 12:13, Roberto Sobachi wrote:
Which is the fastest method to search a string value of an NSDictionary
in an NSArray?
It really depends... some strategies with different trade-offs (i.e.
pre-processing time vs lookup-time):
1) search the array element by element: O(n)
2) sort the array O(n lg n) and use binary search: O(lg n)
3) create a hash-set O(n) and use hashing: O(1) (expected!)
There are other approaches like state-machines and ternary-search trees
often used in parsers (to recognize keywords/maintaining
symbel-tables).
Give some details about exactly what it is you're doing and we can
better answer your questions.
--
Allan * Top-House * DK
http://www.top-house.dk/~aae0030/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.