1 / 6

Pertemuan 6

Pertemuan 6. Searching s. Indexed Sequential Search. for (i = 0; i < indxsize && kindex [ i ] <= key; i ++) { if (i == 0) lowlim = 0; //set low limit else lowlim = pindex [i-1]; if (i == indxsize ) hilim = n – 1; //set high limit else hilim = pindex [i]-1; }

mnunez
Download Presentation

Pertemuan 6

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pertemuan 6 Searchings

  2. Indexed Sequential Search for (i = 0; i < indxsize && kindex[ i ] <= key; i++) { if (i == 0) lowlim = 0; //set low limit else lowlim = pindex[i-1]; if (i == indxsize) hilim = n – 1; //set high limit else hilim = pindex[i]-1; } for (j = lowlim; j <= hilim && k[ j ] != key; j++); //search if (j > hilim) return (-1); else return ( j );

  3. Tracing ISS key = 17. Index size = 3.

  4. Latihan tracing

  5. Binary Search low = 0; high = n – 1; while (low <= high) { middle = (low + high)/2; if (key == data[middle]) return(middle); //selesai. if (key < data[middle]) high = middle – 1; else low = middle + 1; } return(-1); //data tidak ditemukan.

  6. Latihan tracing key = 18

More Related