we have sequential search which is in o(n)
then y to go for binary search whose time=o(nlogn)+logn
o(nlogn) is for creating sorted array
if the soln u r saying is tht binary search is applied where already sorted input is available...
then can u giv examples of it?
or is there is any better anaylsis?
why binary search ?
Moderator: Board moderators
Re: why binary search ?
i think once using binary search... structure is geerated with in nlogn time.. but after that every search takes logn time on the corresponding pattern
Re: why binary search ?
can someone post better analysis?
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: why binary search ?
What is your question? Yes O(log n) is faster than O(n). If there are a large number of queries=q and n is large then you might need a binary search.
Sequential search O(q*n)
Binary search O(n*log n)+O(q*log n)
Sequential search O(q*n)
Binary search O(n*log n)+O(q*log n)
Check input and AC output for thousands of problems on uDebug!
Re: why binary search ?
Can anyone describe/elaborate the maximum subarray 2D algorithm with example?
You can join us for best 642-902 pass4sure dumps exam pass4sure 220-802 training solutions. Our usna contains all those materials you want to pass for real Rasmussen College