Showing posts with label Sederhana. Show all posts
Showing posts with label Sederhana. Show all posts

Sunday, 3 May 2015

Contoh Program Doubly Linked List Sederhana dalam Bahasa Java

class simpul{
    int data;
    simpul next, prev;
    public simpul(int d){ data=d; next=prev=null; }
    int getdata(){ return data; }
}
class doubleLL{
    simpul head, tail;
    int jumlah;
    public doubleLL(){ jumlah=0; head=tail=null; }
    void tambahdepan(int d){
        simpul baru = new simpul(d);
        if(head==null){
            head=tail=baru;
        }
        else{
           head.prev = baru;
           baru.next = head;
           head = baru;
        }
    }

Sunday, 26 April 2015

Contoh Program Linked List Sederhana dalam Bahasa Java

package bp2;
class node {
    int data;
    node next;
    public node(int d){
        data = d; next = null;
    }
    int getnode(){ return (data); }
}
class LinkedList2{
    node head;
    node tail;
    int jumlah;
    public LinkedList2(){
        head = null; tail = null; jumlah = 0;
    }
    void tambahbelakang(node baru){