Skip to content

Instantly share code, notes, and snippets.

@khaeransori
Created August 21, 2014 14:36
Show Gist options
  • Select an option

  • Save khaeransori/30c806d6d0ab5e947fc6 to your computer and use it in GitHub Desktop.

Select an option

Save khaeransori/30c806d6d0ab5e947fc6 to your computer and use it in GitHub Desktop.
Tugas Struktur Data SP 2014 (pengganti kuliah hari Rabu 20 Agustus 2014)
public class Node {
Node kanan, kiri;
Integer data;
public Node(){
}
public Node(Integer x) {
data = x;
}
public void setKanan(Node ptr) {
this.kanan = ptr;
}
public void setKiri(Node ptr) {
this.kiri = ptr;
}
public void setData(Integer x) {
this.data = data;
}
public Node getKanan() {
return this.kanan;
}
public Node getKiri() {
return this.kiri;
}
public Integer getData() {
return this.data;
}
}
Node x = new Node();
Node y = new Node();
Node z = new Node();
Node h = new Node();
Node j = new Node();
Node k = new Node();
x -- y -- j
h -- z -- k
x.setKanan(y);
y.setKanan(j);
j.setKiri(y);
y.setKiri(x);
h.setKanan(z);
z.setKanan(k);
k.setKiri(z);
z.setKiri(h);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment