From f1bc2a7828cefb586322a5334a942f8d5caf2268 Mon Sep 17 00:00:00 2001 From: islah-fari Date: Fri, 21 Feb 2020 01:33:24 +0800 Subject: [PATCH] Tugas 1 --- assignment-01/H071181501/Main.class | Bin 0 -> 671 bytes assignment-01/H071181501/Main.java | 33 + assignment-01/H071181501/Node.class | Bin 0 -> 796 bytes assignment-01/H071181501/Node.java | 24 + .../H071181501/SingleLinkedList.class | Bin 0 -> 9133 bytes .../H071181501/SingleLinkedList.java | 612 ++++++++++++++++++ 6 files changed, 669 insertions(+) create mode 100644 assignment-01/H071181501/Main.class create mode 100644 assignment-01/H071181501/Main.java create mode 100644 assignment-01/H071181501/Node.class create mode 100644 assignment-01/H071181501/Node.java create mode 100644 assignment-01/H071181501/SingleLinkedList.class create mode 100644 assignment-01/H071181501/SingleLinkedList.java diff --git a/assignment-01/H071181501/Main.class b/assignment-01/H071181501/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..197f2b59cdad258b1f60016ca7bc44756f0849ca GIT binary patch literal 671 zcmZ8eVNVl55PjQT@0RwU^%O-BD2j0ODy7i)L5=^Kw{klHVpU%HXSq^1OoQcIEk}o0!4rGoq+Z7IMM>uFi!OT*{HA6H>y8m#2TqM z5xD7p43E^gY7JE~X!Wu*P6kg*VYzpFmLBSEY{)ZvBySm>i|e={Q0tL5)a?32M`3)L z35d3fCLYq+;o0TsxY#meJ5rgdxBog!Pa@<@91>gDcG1R;i(S*hG6OkgD(#?uqz^g9 zRwpMqi3H~Te}qr6xp0}K>RhL%lwBF=bf8~M3;tJ~7ZeAYeJ%f$S=)(|NPj)}j8$CY z|1e(x!Yoak=WU5r(3Tn(5Z~zV4T*LhL&{CFHj7x?B12#4?Js( zQsCJ+Iyp*%W6U(YGQFl($vFS@yS=91w_M}{<$pq*3*2U(0`B|)YEX66 literal 0 HcmV?d00001 diff --git a/assignment-01/H071181501/Main.java b/assignment-01/H071181501/Main.java new file mode 100644 index 0000000..e3a3ac0 --- /dev/null +++ b/assignment-01/H071181501/Main.java @@ -0,0 +1,33 @@ +public class Main { + public static void main(String[] args) { + SingleLinkedList str = new SingleLinkedList(); + SingleLinkedList str2 = new SingleLinkedList(); + SingleLinkedList integer = new SingleLinkedList(); + // int[] numbers = {1, 200, 390, 9, 23, 56, 78}; + // SingleLinkedList list = new SingleLinkedList(); + // for (int number : numbers) { + // list.append(number); + // } + str.append("1"); + str.append("2"); + str.append("3"); + str.append("4"); + str.traverse(); + str2.append("data 1"); + str2.append("data 2"); + str2.append("data 3"); + str2.append("data 4"); + str.mergeAppend(str2); + str.traverse(); + str.get(5); + str.indexOf("data 3"); + + // str.indexOf("6"); + // str.get(2); + // str.size(); + // str.size(); + // str.clear(); + // System.out.println(str.isEmpty()); + // System.out.println(str.contain("6")); + } +} diff --git a/assignment-01/H071181501/Node.class b/assignment-01/H071181501/Node.class new file mode 100644 index 0000000000000000000000000000000000000000..9bdfd8e2c35cfdef6ffa8a1079d2630273862a35 GIT binary patch literal 796 zcmZuuO;6iE6r8nV8#`YRKKhv!Qd;aF0jD0?D5}(|r!=jUD2LuQ!Ac##i4v!OsTU3) zfsi3;ip=^Apv0P_n)`BpI z>H_QTqN3NK-)GVUij5%jo70o7KW@wJF%i?Hgz9kme)MBzv*da+qkMXtSviyc`fN98 zQv!wLob)NcqT-i$%{6K~vZ&#D@p{fLIhkAQuJ=GBNGX-n(o}Z(KRbuGGBr3@V)cZ)r+D^=mG;o8lv19P@&Ydz)piH`tLgG; jx?5P8Kgj5(1hja;WXcVci5Sqbp9Bku^((xN+cy6KL6?L| literal 0 HcmV?d00001 diff --git a/assignment-01/H071181501/Node.java b/assignment-01/H071181501/Node.java new file mode 100644 index 0000000..d2b443f --- /dev/null +++ b/assignment-01/H071181501/Node.java @@ -0,0 +1,24 @@ +public class Node { + private T data; + private Node pointer; + + public Node(T data) { + this.data = data; + } + + public Node getPointer() { + return pointer; + } + + public void setPointer(Node pointer) { + this.pointer = pointer; + } + + public T getData() { + return data; + } + + public boolean hasPointer() { + return pointer != null; + } +} diff --git a/assignment-01/H071181501/SingleLinkedList.class b/assignment-01/H071181501/SingleLinkedList.class new file mode 100644 index 0000000000000000000000000000000000000000..379989736dc7e78addc9925e176282eb44639394 GIT binary patch literal 9133 zcmb_h3wTuJnSTE>GnvU`awP)<2n-3ATnQ2c2@nJ%g5&}w0ucm;==O53Xd>z0Xyy!&{x-u~ZTiw{^g##h^uwDLi%f}us?|S83 zSpG!Z==0!4FR~EzAm&EggMKe^5taRRcyN;kJLT;zH*U_vEx6T#+uZn)7q?@#7kA*x za+W(i*drhA^5AbgxZ8t!Jh-=jfF5w;K>_DBGuSDR(byd6H0KLswuZKbgYo{TDUhWa z7qqp_ujd2vy@W^c62ud`w|1nxTbvJ)+1vAqs!J0 zH`a~6W3RIHR{vbxe{ombj9wLt2L+}Nv*d6S(Q>({HBX*xo)zIvbEgDw;jk47qa3I1 zGWz>EgK-+{(>HQtH?h0>qNXMw-@033c15D5Mp%&6X07J28adk4(PIXq0^X?E8`)tl zSN^gd+LTK&^c$|LZxZV|%M`3!-D)Ex-`0}ooTuB;klC9O{jzmqLnL}rFiM|}N_$T9 z%CUyht-4!bdPAb0uhWcmL_=FlDL;V%`(vU{R<9Y|YA#M`s5KPc+GA2?-DYQFD5frryH>9BkxxyrD&YoCJR00#Mq^wtFLB!tjr3}Vrq<0Tqn>@la1qbELJu zW81PGv)2sAm+kB@`{JPp?eHr50+MAp<>L(R=14&H4OpE8N>eed*lOvIw{$Iu^oKiR zwwXq$cLBZ(v~&gZYagz}Wkjqs?UR>4C>D^a_F);Ssjk%A$+_J4st-@#NrB>9ynz5i zE|^&tm>T1~@{fMF%}eK|M(b?j#$F$u!qaX%EsxD4nNO-k~J5U<=F2ht&-`Bu9GK$4c>OS-3SG zWi+W|Yh$Z*S1fM!Qr3}v%HFSM4@GKLv2&b5%wR8fg!~k}D~NBaMCjfT?CCdUh>T|T zvB9!>aG3UK`fQAhJ~=nXEwCqA3*IoySaYXO!`Z#tg0ZC4%)Femhui594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878$1y<@=#^u<4U6d%Z);8Fveh$;m2lUG`1W1 zGL8D<{Hzm$S6arQH3=|1=bps2pZMOrG;=? z!IJAN`7=i8`bhAIFH!WrWLdYtvQ8UPCXE^^r8QYgE9oco@uCZj4|LAGXwPBN!YrQM z!>FM>GilFd$T4PNlu?W6#%z=sb5L!}MXfOp3ynIgHs<46W1+IcClA_G#S!pMq&PPu z#d(*7Kd~8F_*q@ZJFU(mgTIrelxR~@DL { + private Node head; + private Node tail; + private int size; + + public void append(T data) { + if (head == null) { + head = new Node(data); + size++; + return; + } + if (tail == null) { + tail = new Node(data); + head.setPointer(tail); + size++; + return; + } + Node newNode = new Node(data); + tail.setPointer(newNode); + tail = newNode; + size++; + } + + public void appends(T ... datas){ + for(T data : datas){ + append(data); + size++; + } + } + + + public void appendAfterData(T data, T after){ + Node newNode = new Node(data); + Node node = head; + if (head == null) { + head = new Node(data); + size++; + return; + } + if (tail == null) { + tail = new Node(data); + head.setPointer(tail); + size++; + return; + } + if (head.getData() == after){ + newNode.setPointer(node.getPointer()); + head.setPointer(newNode); + size++; + } + while(node.getPointer() != null){ + if(node.getPointer().getData() == after){ + newNode.setPointer(node.getPointer().getPointer()); + node.getPointer().setPointer(newNode); + size++; + return; + } + node = node.getPointer(); + } + if(node.getData() != data){ + append(data); + size++; + return; + } + } + + public void appendAfterIndex(T data, int indeks){ + Node newNode = new Node(data); + Node node = head; + int pos = 0; + if (head == null) { + head = new Node(data); + size++; + return; + } + if (tail == null) { + tail = new Node(data); + head.setPointer(tail); + size++; + return; + } + while(node.getPointer() != null){ + if (pos == indeks){ + newNode.setPointer(node.getPointer()); + node.setPointer(newNode); + size++; + return; + } + pos++; + node = node.getPointer(); + } + if(pos == indeks ){ + append(data); + size++; + return; + } + if(pos != indeks){ + append(data); + size++; + return; + } + } + + public void update(T newData, T data) { + Node newNode = new Node(newData); + Node node = head; + + if (head == null) { + throw new NoSuchElementException("Empty List"); + } + if (head.getData() == data){ + head = newNode; + newNode.setPointer(node.getPointer()); + node.setPointer(null); + return; + } + while (node.getPointer() != null){ + if(node.getPointer().getData() == data ){ + newNode.setPointer(node.getPointer().getPointer()); + node.setPointer(newNode); + return; + } + node = node.getPointer(); + } + throw new NoSuchElementException("No Such Element"); + } + + public void updateIndeks(T newData, int indeks){ + Node newNode = new Node(newData); + Node node = head; + int pos = 0; + + if (head == null) { + throw new NoSuchElementException("Empty List"); + } + if(0 == indeks){ + head = newNode; + newNode.setPointer(node.getPointer()); + node.setPointer(null); + return; + } + while(node.getPointer() != null){ + if((pos+1) == indeks){ + newNode.setPointer(node.getPointer().getPointer()); + node.setPointer(newNode); + return; + } + node = node.getPointer(); + pos++; + } + throw new IndexOutOfBoundsException("Index Out Of Bounds"); + } + + public void prepend(T data) { + if (head == null) { + head = new Node(data); + size++; + return; + } + Node newNode = new Node(data); + newNode.setPointer(head); + head = newNode; + size++; + } + + public void prependBeforeData(T data, T before){ + Node newNode = new Node(data); + Node node = head; + if (head == null) { + head = new Node(data); + size++; + return; + } + if (head.getData() == before){ + newNode.setPointer(head); + head = newNode; + size++; + return; + } + while (node.getPointer() != null){ + if(node.getPointer().getData() == before){ + newNode.setPointer(node.getPointer()); + node.setPointer(newNode); + size++; + return; + } + node = node.getPointer(); + } + if (node.getData() != data){ + prepend(data); + size++; + return; + } + } + + public void prependBeforeIndex(T data, int indeks){ + Node newNode = new Node(data); + Node node = head; + int pos = 0; + + if (head == null) { + head = new Node(data); + size++; + return; + } + if(indeks == 0){ + newNode.setPointer(head); + head = newNode; + size++; + return; + } + while(node.getPointer() != null){ + if((pos+1) == indeks){ + newNode.setPointer(node.getPointer()); + node.setPointer(newNode); + size++; + return; + } + node = node.getPointer(); + pos++; + } + if(pos != indeks){ + prepend(data); + size++; + return; + } + } + + public void prepends(T ... datas){ + for(T data : datas){ + prepend(data); + size++; + } + } + + public void clear() { + head = null; + size = 0; + } + + public void removeHead() { + if (head == null) { + throw new NoSuchElementException("Empty List"); + } + head = head.getPointer(); + size--; + } + + public void removeTail() { + if (head == null) { + throw new NoSuchElementException("Empty List"); + } else if (tail == null) { + throw new NoSuchElementException("Head"); + } else if (tail == head) { + throw new NoSuchElementException("Head is Tail"); + } + Node node = head; + while (node.getPointer().getPointer() != null) { + node = node.getPointer(); + } + node.setPointer(null); + tail = node; + size--; + } + + public void remove(T data){ + Node node = head; + + if(head.getData() == data){ + removeHead(); + return; + } + while(node.getPointer() != null){ + if(node.getPointer().getData() == data){ + node.setPointer(node.getPointer().getPointer()); + size--; + return; + } + node = node.getPointer(); + } + throw new NoSuchElementException("No Such Element"); + } + + public void removeIndeks(int indeks){ + Node node = head; + int pos = 0; + + if (indeks == 0){ + removeHead(); + return; + } + while(node.getPointer() != null){ + if((pos+1) == indeks){ + node.setPointer(node.getPointer().getPointer()); + size--; + return; + } + node = node.getPointer(); + pos++; + } + throw new IndexOutOfBoundsException("Index Out Of Bounds"); + } + + public void removeAfterData(T data){ + Node node = head; + while(node.getPointer() != null){ + if(node.getData() == data){ + node.setPointer(node.getPointer().getPointer()); + size--; + return; + } + node = node.getPointer(); + } + throw new NoSuchElementException("No Such Element"); + } + + public void removeAfterIndeks(int indeks){ + Node node = head; + int pos = 0; + while(node.getPointer() != null){ + if(pos == indeks){ + node.setPointer(node.getPointer().getPointer()); + size--; + return; + } + node = node.getPointer(); + pos++; + } + throw new IndexOutOfBoundsException("Index Out Of Bounds"); + } + + public void removeBeforeData(T data) { + Node node = head; + try{ + if(head.getPointer().getData() == data){ + head = head.getPointer(); + size--; + return; + } + while(node.getPointer() != null){ + if(node.getPointer().getPointer().getData() == data){ + node.setPointer(node.getPointer().getPointer()); + size--; + return; + } + node = node.getPointer(); + } + }catch (Exception e){ + throw new NoSuchElementException("No Such Element"); + } + } + public void removeBeforeIndeks(int indeks) { + Node node = head; + int pos = 0; + + if((pos+1) == indeks){ + head = head.getPointer(); + size--; + return; + } + while(node.getPointer() != null){ + if((indeks) - pos == 2){ + node.setPointer(node.getPointer().getPointer()); + size--; + return; + } + node = node.getPointer(); + pos++; + } + throw new IndexOutOfBoundsException("Index Out Of Bounds"); + } + + public void removeForward(T data){ + Node node = head; + int count = 0; + try{ + while(node.getData() != data){ + node = node.getPointer(); + count++; + } + node.setPointer(null); + size = count + 1; + }catch (Exception e){ + throw new NoSuchElementException("No Such Element"); + } + } + + public void removeForwardIndeks(int indeks){ + Node node = head; + int pos = 0; + int count = 0; + try{ + while(pos != indeks){ + node = node.getPointer(); + count++; + pos++; + } + node.setPointer(null); + size = count+1; + }catch (Exception e){ + throw new IndexOutOfBoundsException("Index Out Of Bounds"); + } + } + + public void removeBackward(T data){ + Node node = head; + int count = 0; + try{ + while(node.getData() != data){ + node = node.getPointer(); + count++; + } + head = node; + size -= count; + }catch (Exception e){ + throw new NoSuchElementException("No Such Element"); + } + } + + public void removeBackwardIndeks(int indeks){ + Node node = head; + int count = 0; + int pos = 0; + try{ + while(pos != indeks){ + node = node.getPointer(); + count++; + pos++; + } + head = node; + size -= count; + } + catch (Exception e){ + throw new IndexOutOfBoundsException("Index Out Of Bounds"); + } + } + + public void describeNode(T data) { + if (head == null) { + throw new NoSuchElementException("Empty List"); + } + if (head.getData() == data) { + System.out.printf("{\n data\t: %s\n index\t: %s\n}\n", head.getData(), 0); + return; + } + if (tail.getData() == data) { + System.out.printf("{\n data\t: %s\n index\t: %s\n}\n", tail.getData(), size - 1); + return; + } + Node node = head; + int index = 0; + while (node.hasPointer()) { + if (node.getData() == data) { + System.out.printf("{\n data\t: %s\n index\t: %s\n}\n", node.getData(), index); + return; + } + node = node.getPointer(); + index++; + } + throw new NoSuchElementException("No Such Element"); + } + + public void describeNodeIndeks(int indeks){ + int pos = 0; + if (head == null) { + throw new NoSuchElementException("Empty List"); + } + if (0 == indeks) { + System.out.printf("{\n data\t: %s\n index\t: %s\n}\n", head.getData(), 0); + return; + } + if ((size-1) == indeks) { + System.out.printf("{\n data\t: %s\n index\t: %s\n}\n", tail.getData(), size - 1); + return; + } + Node node = head; + int index = 0; + while (node.hasPointer()) { + if (pos == indeks) { + System.out.printf("{\n data\t: %s\n index\t: %s\n}\n", node.getData(), index); + return; + } + node = node.getPointer(); + index++; + pos++; + } + throw new IndexOutOfBoundsException("Index Out Of Bounds"); + } + + public void mergeAppend(SingleLinkedList list){ + tail.setPointer(list.head); + tail = list.tail; + size += list.size; + return; + } + public void mergePrepend(SingleLinkedList list){ + head = list.tail; + list.tail.setPointer(list.head); + size += list.size; + return; + } + + public void traverse() { + if (head == null) { + System.out.println("Empty Linked List"); + return; + } + Node node = head; + while (node.hasPointer()) { + System.out.printf("[%s] -> ", node.getData()); + node = node.getPointer(); + } + System.out.printf("[%s] -> null\n", node.getData()); + } + + public void traverseFromData(T data){ + try{ + if (head==null){ + System.out.println("Empty Linked List"); + return; + } + Node node = head; + while (node.getData() != data){ + node = node.getPointer(); + } + while (node.getPointer() != null){ + System.out.printf("[%s] -> ", node.getData()); + node = node.getPointer(); + } + System.out.printf("[%s] -> null\n", node.getData()); + }catch (Exception E){ + throw new NoSuchElementException("No Such Element"); + } + } + + public void traverseFromIndex(int indeks){ + try{ + Node node = head; + int pos = 0; + + while(pos != indeks){ + node = node.getPointer(); + pos++; + } + if(pos == indeks){ + while(node.getPointer() != null){ + System.out.printf("[%s] -> ", node.getData()); + node = node.getPointer(); + } + System.out.printf("[%s] -> null\n", node.getData()); + } + }catch (Exception E){ + throw new NoSuchElementException("No Such Element"); + } + } + public void get(int indeks) { + Node node = head; + int pos = 0; + while(node.getPointer() != null){ + if(pos == indeks){ + System.out.printf("data => [%s]\n", node.getData()); + return; + } + node = node.getPointer(); + pos++; + } + if (size-1 == indeks){ + System.out.printf("data => [%s]\n", node.getData()); + return; + } + throw new IndexOutOfBoundsException("Index Out Of Bounds"); + } + + public void indexOf(T data){ + Node node = head; + int pos =0; + while(node.getPointer() != null){ + pos++; + node = node.getPointer(); + if(node.getData() == data){ + System.out.printf("indeks => %s\n", pos); + return; + } + } + throw new NoSuchElementException("No Such Element"); + } + + public int size(){ + System.out.println("Size ==> " + size); + return size; + } + + public boolean isEmpty(){ + if (size == 0){ + return true; + } + return false; + } + + public boolean contain(T data){ + Node node = head; + while(node.getPointer() != null){ + if(node.getData() == data){ + return true; + } + node = node.getPointer(); + } + return false; + } +}