Help with Array Sort
-
Consider the following array, whose contents are NOT sorted: int Ids[10]={12,4,22,67,2,5,11,33,6,10}; If a binary search routine is written to search through this array, what will happen? For example, Will the program abort, since the array is not sorted? or will the binary search routine be successful, but inefficient? or Will the binary search fail? or ??? Loli10
-
Consider the following array, whose contents are NOT sorted: int Ids[10]={12,4,22,67,2,5,11,33,6,10}; If a binary search routine is written to search through this array, what will happen? For example, Will the program abort, since the array is not sorted? or will the binary search routine be successful, but inefficient? or Will the binary search fail? or ??? Loli10
The binary sort will fail. - Anders Money talks, but all mine ever says is "Goodbye!"
-
Consider the following array, whose contents are NOT sorted: int Ids[10]={12,4,22,67,2,5,11,33,6,10}; If a binary search routine is written to search through this array, what will happen? For example, Will the program abort, since the array is not sorted? or will the binary search routine be successful, but inefficient? or Will the binary search fail? or ??? Loli10
Binary search on a non-sort list will yield a LOT of erronious "not found"s. Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
-
Consider the following array, whose contents are NOT sorted: int Ids[10]={12,4,22,67,2,5,11,33,6,10}; If a binary search routine is written to search through this array, what will happen? For example, Will the program abort, since the array is not sorted? or will the binary search routine be successful, but inefficient? or Will the binary search fail? or ??? Loli10
Sort it first. Binary search expects a sorted array. It won't crash your program, but you will get wrong results for your search if the array is unsorted. Nish It's seven o'clock On the dot I'm in my drop top Cruisin' the streets - Oh yeah I got a real pretty, pretty little thing that's waiting for me