Sequential Search


ada beberapa banyak metode yang digunakan dalam proses searching antara lain Binary Search dan juga sequential Search....
Kali ini saya akan mnshare kepada kita semua bagaimana membuat program searching menggunakan metode Sequential Search menggunakan bahasa pemrograman Java. Berikut adalah ssource code dari program tersebut : 

package prak_mod3;
import java.util.Scanner;

public class sequential_no2 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        System.out.print("Masukkan banyak data : ");
        int n = in.nextInt();
        int isi[] = new int[n];
        //input data
        for(int i=1;i<=n;i++){
            System.out.print("data ke-"+i+" : ");
            isi[i-1] = in.nextInt();
        }
        System.out.print("Data yang dicari = ");
        int search = in.nextInt();
        //proses pencarian
        int x=0;
        for(int j=1;j<=n;j++){
            if(isi[j-1]==search){

                x=j;

                System.out.println("Data ditemukan di data ke-"+x);
                break;
            }
        }
        if(x==0){
            System.out.println("data tidak ditemukan");
        }
    }
}
berikut ini adalah hasil running dari program yang sudah saya buat tadi  : 

Semoga tulisan yang saya buat ini dapat bermanfaat bagi kita semua...
selamat mencoba dan mengeksplor program itu sendiri
^_^

1 komentar:

Blog27999 mengatakan...

You should see how my pal Wesley Virgin's story starts with this shocking and controversial VIDEO.

You see, Wesley was in the army-and shortly after leaving-he unveiled hidden, "mind control" secrets that the CIA and others used to get anything they want.

THESE are the EXACT same secrets tons of famous people (notably those who "come out of nowhere") and elite business people used to become wealthy and famous.

You probably know that you use less than 10% of your brain.

That's really because most of your brain's power is UNCONSCIOUS.

Maybe this expression has even occurred INSIDE your own mind... as it did in my good friend Wesley Virgin's mind seven years back, while driving an unlicensed, beat-up garbage bucket of a vehicle without a driver's license and with $3.20 in his pocket.

"I'm absolutely fed up with going through life paycheck to paycheck! Why can't I turn myself successful?"

You took part in those conversations, am I right?

Your success story is waiting to happen. Go and take a leap of faith in YOURSELF.

Learn How To Become A MILLIONAIRE Fast

Posting Komentar