mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 14:30:36 +00:00
choose the middle value as pivot
This commit is contained in:
parent
6013451ee2
commit
eb968e50b6
1 changed files with 2 additions and 0 deletions
|
|
@ -21,6 +21,8 @@ static inline void swap(TYPE *a, int i, int j)
|
|||
template <typename TYPE>
|
||||
static int partition(TYPE *a, int l, int h)
|
||||
{
|
||||
int p = (l + h) / 2;
|
||||
swap(a, p, h);
|
||||
for (int i = l; i < h; ++i)
|
||||
if (a[i] < a[h])
|
||||
swap(a, i, l++);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue