D
D
Dmitry2019-01-13 14:54:54
Algorithms
Dmitry, 2019-01-13 14:54:54

Which is faster, simple search or sort + search?

Good afternoon. Which is faster, simple search or quick sort + binary search? What is the rationale for this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2019-01-13
@tchdmevg

Simple search
complexity -n Binary search complexity - Log(n)
But the speed of quicksort is non-constant, and in the worst case is n^2.
So there is no definite answer. Everything depends on the input data.
However, if the search is done frequently, and the data does not change (i.e., it can be sorted once), then binary search is definitely faster.
It's all based on mathematics and nothing else.

A
Armenian Radio, 2019-01-13
@gbg

Linear search - N
qsort - NlogN
Binary search logN
For one-time search - linear search wins

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question