메뉴 건너뛰기

app

interpolationSearch

박영식2003.11.05 19:52조회 수 2199댓글 0

    • 글자 크기
int CRandom::interpolationSearch(int search_key, int key[], int n)
{
        int index=0, low =0, high=NUM-1, output=0;
        cnt=0;
        while(low <= high && output ==0)
        {
                cnt++;
                if(search_key == key[index]){
                        output=index;
                        return(index+1);
                }
                else{
//                printf("index = %dt",index);
                        index=low + (int)((float)((search_key-key[low])*(high-low))/(key[high]-key[low]));
        }
                if (search_key < key[index]){
                        high=index-1;
                }
                else{
                        low=index+1;
                }

        }
        return index+1;
}
박영식 (비회원)
    • 글자 크기

댓글 달기

suritam9
2013.12.02 조회 3162
lispro06
2017.06.22 조회 1617
suritam9
2019.04.05 조회 1851
lispro06
2013.12.10 조회 2739
lispro06
2014.02.08 조회 3806
이전 1 2 3 4 5 6 7 8 9 10... 14다음
첨부 (0)
위로