Binary Search

xiaoxiao2021-04-03  219

Continue Quick Sort !!!!

This is binary search.today i find some bugs about my quick sort.

For example:

10 1 320 2 510 2 220 2 1 WHEN TO SORT FOUR RECORDS ABOVE, NO LIMITED CYCLE.

INT Search (Bl Langs [], Char * Key, Int N)

{

Int Mid, Low, High;

Low = 0;

HIGH = N-1;

Int flag;

While (low <= high)

{

MID = (low high) / 2;

Flag = strcmp (key, langs [mid] .f);

IF (Flag == 0)

Return MID;

Else IF (flag> 0)

HIGH = MID-1;

Else

Low = MID 1;

// fprintf (stderr, "key");

}

// Printf ("% D% D / N", Low, HiGH);

IF (low> high)

{

FPRINTF (stderr, "can not find key / n");

Return -1;

}

Else

Return MID;

}

转载请注明原文地址:https://www.9cbs.com/read-131518.html

New Post(0)