TUGAS 03 SISTEM BERKAS -Organisasi Berkas Physical Sequential-

PROGRAM MENENTUKAN KUNCI
PADA ORGANISASI BERKAS PHYSICAL SEQUENTIAL
DENGAN MENGGUNAKAN BAHASA PASCAL


Nama : Ririn Septrisulviani
NIM   : 131.05.1060
Kelas A


Download File .EXE

Buat yang mau belajar, berikut cuplikan source code nya :
  • Function-Function
  • 
    function sequen(cari: integer): integer;
    begin
            i:=1;
            while ((icari)) do
            i:= i+1;
                    if data[i]= cari then
                    begin
                            sequen:=i;
                            waktu:=ln(n)/ln(10);
                    end
                    else
                            sequen:=0;
    end;
    
    function binary(cari: integer):integer;
    var
            awal,akhir,tengah: integer;
            ketemu:boolean;
            indeksxx: integer;
    begin
            awal:= 1;
            akhir:= n;
            ketemu :=false;
            indeksxx := 0;
            while ((awal <= akhir) and (not ketemu)) do
            begin
                    tengah:= (awal+akhir) div 2;
                    if cari = data[tengah] then
                    begin
                            ketemu := true;
                            indeksxx := tengah;
                            waktu:=ln(n)/ln(10);
                    end
                    else
                    begin
                            if cari < data[tengah] then
                            akhir :=  tengah-1
                            else
                            awal := tengah+1;
                    end;
            end;
            binary:=indeksxx;
    end;
    
    function interp(cari: integer): integer;
    var
            low,high,t,pos: integer;
            p:real;
            label selesai;
            
    begin
      low:= 1;
            high:= n;
            t:=0;
            p:=0;
      while (data[low]<=cari) and (data[high]>=cari) do
      begin
      p:=low+((cari-data[low])/(data[high]-data[low]))*(high-low);
      pos:=round(p);
      if (data[pos]=cari) then
                    begin
          t:=1;
          goto selesai;
        end;
                    
                    begin
                            if (data[pos] > cari) then
                            high:=pos-1
          else
          low:=pos+1;
                    end;
                    if low>high then goto selesai;
            end;
            selesai:
            if t=1 then 
            interp:=pos;
            waktu:=ln(n)/ln(10);
    end;
    
  • Procedure Urut Kunci (secara Ascending) untuk Metode Binary dan Metode Interpolation
  • 
    procedure urut;
    var     min,urut,k : integer;
           
    begin
    urut:= 1;
            for i:= 1 to n-1 do
            begin
            min:=i;
                    for j:= urut to n do
                    begin
                            if data[j] < data[min] then
                            min:=j;
    
                            if data[i] <> data[min] then
                            begin
                            k:= data[i];
                           end;
    
                            if data[i] > data[min]  then
                            begin
                                    data[i] := data[min];
                                    data[min]:= k;
                            end;
                    end;
            urut:=urut+1;
            end;
    end;
    
  • Program Utama
  • 
    begin
            repeat
            clrscr;
            writeln('+----------------------------------------------+');
            writeln('|               Program Pencarian              |');
            writeln('+----------------------------------------------+');
            writeln('|       [1] Pencarian Sequential               |');
            writeln('|       [2] Pencarian Binary                   |');
            writeln('|       [3] Pencarian Interpolation            |');
            writeln('|       [0] Keluar                             |');
            writeln('|++++++++++++++++++++++++++++++++++++++++++++++|');
            writeln('|++++++++++++++++++++++++++++++++++++++++++++++|');
            writeln('|       Pilih :                                |');
            writeln('|++++++++++++++++++++++++++++++++++++++++++++++|');
            writeln('|++++++++++++++++++++++++++++++++++++++++++++++|');
            writeln('| Program ini dibuat oleh :                    |');
            writeln('| Nama               : Ririn Septrisulviani    |');
            writeln('| NIM                : 131051060               |');
            writeln('| Bahasa Pemrograman : Pascal                  |');
            writeln('+----------------------------------------------+');
            gotoxy(17,10);readln(pilih);
            case pilih of
            '1' : begin
                    clrscr;
                    menu1;
                    readkey;
                    end;
            '2' : begin
                    clrscr;
                    menu2;
                    readkey;
                    end;
            '3' : begin
        clrscr;
        menu3;
        readkey;
        end;
            '0': exit;
                   end;
    until pilih='0';
    end.
    
Untuk source code lebih lengkapnya bisa dilihat laporan diatas yaa :)
Oke sekian dulu teman-teman, lain kali kita lanjut nugas lagi yaakk hehe :d

Posted in: ,

1 komentar:

  1. thanks for information gan izin copy paste yaa

    kunjungi juga -->> kata-quotes.blogspot.com

    BalasHapus