Hey guys. I've got a question regarding binary and sequential search.
If the list has 1024 items (lg1024 = 12) at what point (the number of searches) does sorting the list first and using binary search pay off?
Sorry, was not sure if this is the correct forum.
Help required
Started by MasterD009, Feb 23 2009 03:07 PM
3 replies to this topic
#1
Posted 23 February 2009 - 03:07 PM
|
|
|
#2
Posted 23 February 2009 - 04:32 PM
First: log_2(1024) = 10
That said, it depends on several factors:
Cost of sorting, frequency of searches, frequency of inserts, etc.
That said, it depends on several factors:
Cost of sorting, frequency of searches, frequency of inserts, etc.
#3
Posted 23 February 2009 - 06:54 PM
There isn't really anything related to the cost, frequency etc. It's a tricky question that I am having problems with.
#4
Posted 24 February 2009 - 08:39 AM
The answer to the question really depends on the factors I listed. The two search versions each have an overhead cost, as does sorting. The frequency with which you sort, and the cost of the sort algorithm chosen, is going to impact whether one search or another is best.
Short answer: "It depends on what all you are doing"
I've got some tutorials on doing searches, sorts, and inserts with linked lists and arrays and trees that may help answer your question.
http://forum.codecal...nked-lists.html
http://forum.codecal...rees-101-a.html
Short answer: "It depends on what all you are doing"
I've got some tutorials on doing searches, sorts, and inserts with linked lists and arrays and trees that may help answer your question.
http://forum.codecal...nked-lists.html
http://forum.codecal...rees-101-a.html


Sign In
Create Account

Back to top









