Академический Документы
Профессиональный Документы
Культура Документы
Class SLLNC
public class SLLNC {
public SLLNC() {
}
public SLLNC(int d) {
data = d;
next = null;
}
if (jikaEmpty() == true) {
head = baru;
head.next = null;
} else {
baru.next = head;
head = baru;
}
}
if (head.next == null) {
head = null;
} else {
hapus = head;
head = head.next;
hapus = null;
}
}
public void hapusBelakang() {
//isikan method untuk hapus belakang
}
if (head.next == null) {
head = null;
} else {
bantu = head;
while (bantu.next.next != null) {
bantu = bantu.next;
}
bantu.next = null;
}
}
Class SLLNCApp
public class SLLNCApp {
List.tambahDepan(5);
List.tambahDepan(2);
List.tambahDepan(7);
List.tambahBelakang(9);
List.printDepan();
System.out.println();
List.tambahDepan(6);
System.out.println();
List.printDepan();
List.hapusDepan();
System.out.println();
List.printDepan();
List.hapusBelakang();
System.out.println();
List.printDepan();
List.tambahBelakang(4);
System.out.println();
List.printDepan();
}
}
Class SLLC
public class SLLC {
public SLLC() {
}
public SLLC(int d) {
data = d;
next = null;
}
SLLC head;
SLLC bantu;
if (jikaEmpty() == true) {
head = baru;
head.next = head;
} else {
if (head.next == head) {
baru.next = head;
head.next = baru;
head = baru;
} else {
bantu = head;
while (bantu.next != head) {
bantu = bantu.next;
}
bantu.next = baru;
baru.next = head;
head = baru;
}
}
}
public void insertBelakang(int databaru) {
//isi kan method untuk tambah belakang
}
Class SLLCApp
public class SLLCApp {
Class DLLNC
public class DLLNC {
public DLLNC() {
}
public DLLNC(int d) {
data = d;
next = null;
prev = null;
}
if (jikaEmpty() == true) {
head = baru;
head.next = null;
head.prev = null;
} else {
head.prev = baru;
baru.next = head;
head = baru;
}
}
Class DLLNCApp
public class DLLNCApp {
Class linkDLLC
public class linkDLLC {
Class DLLC
public class DLLC {
linkDLLC head;
linkDLLC bantu;
if (jikaEmpty() == true) {
head = baru;
head.next = head;
head.prev = head;
} else {
bantu = head.prev;
head.prev = baru;
baru.next = head;
head = baru;
bantu.next = head;
head.prev = bantu;
}
}
if (head.next != head) {
bantu = head.prev;
head = head.next;
bantu.next = head;
head.prev = bantu;
hapus = null;
} else {
head = null;
}
}
Silahkan dicoba/dipraktekkan class-class diatas. Lalu silahkan dianalisa perbaris sesuai, tampilkan
output masing-masing class. Lakukan eksplorasi terhadap koding diatas !!!
Laporan Praktikum dikumpul ke google classroom. Batas pengumpulan hingga hari minggu (29
September 2019) pada jam 12.00 malam.