From ce78232cf4f01144fc29c865c686d1094604376e Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 13 May 2019 22:06:56 +0200 Subject: [PATCH] Partial exercise 2 and 3 --- bin/app/App.class | Bin 2791 -> 3913 bytes bin/app/BinaryNode.class | Bin 0 -> 347 bytes bin/app/LinkedList.class | Bin 0 -> 399 bytes bin/app/Node.class | Bin 0 -> 474 bytes src/app/App.java | 136 +++++++++++++++++++++++++++++++++++---- src/app/BinaryNode.java | 8 +++ src/app/LinkedList.java | 5 ++ src/app/Node.java | 7 ++ 8 files changed, 143 insertions(+), 13 deletions(-) create mode 100644 bin/app/BinaryNode.class create mode 100644 bin/app/LinkedList.class create mode 100644 bin/app/Node.class create mode 100644 src/app/BinaryNode.java create mode 100644 src/app/LinkedList.java create mode 100644 src/app/Node.java diff --git a/bin/app/App.class b/bin/app/App.class index 02d834149e8899d8bafeede27a3c0377408649ab..1e30390ddbb13399d35cb463788836dd0160cd89 100644 GIT binary patch literal 3913 zcma)9dvKK176092H~a18OE%erz$a7}ESLu&Y$6X69)?INH3^Skgb*lS_K|GZ>@NFA z4GmRWR4PR(wIZN4P-^61ttbnXw$OH*I{l+F`j7n&|7oXorvEUV>5PcO8aAVGfvV~)9k~C5S z@JoURvv98q->}tAJ*ne9_!+yT6c(cs)2i?0g9~#6N~OoEqH!}d+NEMQ8*UAA1w@@2 zv+;nAYSb_qQQ9nncgxFsEHu=SxluzsmnM0pLB~P_csEHi6^_%rG8NWaN?IgWlg>*f zmm?OAWF%p+jwO=dOhpF&+e{7cqAKokDGX-6$@82W)!ZcK zensh5lzxjsF{Ce&b5QLD)oxJj2GwrR+Fh)8mdH7zI75mvq&P#0Go&~}iZet`MjsQF`L5BXRNv0B2M+lT&6br`(GJ|xZx@L_F0|L`;zs6PBXe<;?c@TkH3LMh0 z12G;A4w|Xf3=OSbQ`085<2n*Za);K0rK_{5+iLD`E-$Y|o=E9PgCev{!pa$e%IZ6h zkk`bBj_=}0=I)3Y%ZArR1m;c7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YD#1Yj}qF(NR|>`!4C&M^B6sKXUzf0es$q8`8Tb-INH+(x6= zh$gX#5yuFRf_=Ypp zu9wc8&Iyv;j<<~uynRb=7Z}3<%(#o`3aZ5&EKm^fd;WoP7xSs%pQH2L$9{Nel*=50 eEkufnIPxCxS6W(npBKtKWflDkTx4H_OaB7h^=1+P diff --git a/bin/app/BinaryNode.class b/bin/app/BinaryNode.class new file mode 100644 index 0000000000000000000000000000000000000000..ddd4fa0e1b7c921108d8731dea2ebc1abeb2115c GIT binary patch literal 347 zcmY*Uu};G<6uj3s353#w0w2Hz3}j&gbpVMeDnn6sCz#Y#>O{sx;(AyHqyS&+h-L+5VEy=lX)Xeoj;aqRXKvtPHhO& zVka$})uz57M4hzCuqiA44`WR<>V=ii>UzZ--D;!Vj1Zh(ELpwh$OHk>F%B>$q=hzW zzTK3{KFP9CKC!K2vy@i*`_L3_rC$ljqTSj`J!o%CcS~IPPvQ(5!YC<E| z!Wq~n{}DKn@yF;gyK6Y$Tz+8hodpXXqbZwwpRwQM4#xv#gO)O6*1@R3LyVhv^b5-7 BS&9Gv literal 0 HcmV?d00001 diff --git a/bin/app/Node.class b/bin/app/Node.class new file mode 100644 index 0000000000000000000000000000000000000000..ff482308acadbb28f223ceeee0d31e975c908f57 GIT binary patch literal 474 zcmZWl%SyvQ6g@XdneK?rrx()}b3bxN9sG!gwQSAq*az>gB| z*ayTe=FB~h+}u0gKc8O!u5fI_AhblD2mRTTv|$lC6Y(N~RAl4eF`mezBv`7HQ-UA; zw{8f|K#em|R)r)qhYuWN(aPj2f9FQ4&aC-s5-wsr9ZbcXgUwK7s_YTW)3Xt)cRY*> z6T2R^u|sG_DwF+c8p~oR;*@{oN3%qvBT*>Lm!efZt2v=t_ulfA?+#{Fk;r?cJ2-md zOT7`{BGiLlZ|>LIlyCx`lb=tY2Aa%lt_-vo9k^@0#oViLVvqM>Y_oUEH}Ty#|3K%R g3ll!0Zm8=$MsE?oKDPl5YKm@ep! stack = new MyStack(); - stack.push("hello"); - stack.push("world"); - stack.push("123"); - System.out.println(stack.pop()); - System.out.println(stack.pop()); - System.out.println(stack.pop()); + // System.out.println("++++ Aufgabe 1.1 - 1.3 ++++"); + // MyStack stack = new MyStack(); + // stack.push("hello"); + // stack.push("world"); + // stack.push("123"); + // System.out.println(stack.pop()); + // System.out.println(stack.pop()); + // System.out.println(stack.pop()); - /** Aufgabe 1.4 */ - System.out.println("++++ Aufgabe 1.4 ++++"); - tokenizeAndCalc("( 2 + 3 )"); - tokenizeAndCalc("( 3 - ( 2 * 3 ) )"); - tokenizeAndCalc("( ( 5 * 4 ) - ( 2 * ( 3 / 4 ) ) )"); + // /** Aufgabe 1.4 */ + // System.out.println("++++ Aufgabe 1.4 ++++"); + // tokenizeAndCalc("( 2 + 3 )"); + // tokenizeAndCalc("( 3 - ( 2 * 3 ) )"); + // tokenizeAndCalc("( ( 5 * 4 ) - ( 2 * ( 3 / 4 ) ) )"); + + // /** Aufgabe 2.1 - 2.2 */ + // System.out.println("++++ Aufgabe 2.1 - 2.2 ++++"); + // Node n1 = new Node(); + // Node n2 = new Node(); + // Node n3 = new Node(); + // Node n4 = new Node(); + // n1.item = 1; + // n2.item = 2; + // n3.item = 3; + // n4.item = 4; + // n1.last = null; + // n1.next = n2; + // n2.last = n1; + // n2.next = n3; + // n3.last = n2; + // n3.next = n4; + // n4.last = n3; + // n4.next = null; + // n3.item = null; + // n2.next = n4; + // System.out.println(n1.item); + // System.out.println(n1.next.item); + // System.out.println(n1.next.next.item); + + /** Aufgabe 3.1 */ + System.out.println("++++ Aufgabe 3.1 ++++"); + BinaryNode ba1 = new BinaryNode(); + BinaryNode ba2 = new BinaryNode(); + BinaryNode ba3 = new BinaryNode(); + ba1.item = "+"; + ba2.item = "2"; + ba3.item = "3"; + ba2.parent = ba1; + ba3.parent = ba1; + ba1.left = ba2; + ba1.right = ba2; + + BinaryNode bb1 = new BinaryNode(); + BinaryNode bb2 = new BinaryNode(); + BinaryNode bb3 = new BinaryNode(); + BinaryNode bb4 = new BinaryNode(); + BinaryNode bb5 = new BinaryNode(); + bb1.item = "*"; + bb2.item = "5"; + bb3.item = "+"; + bb4.item = "2"; + bb5.item = "3"; + bb2.parent = bb1; + bb3.parent = bb1; + bb4.parent = bb3; + bb5.parent = bb3; + bb1.left = bb2; + bb1.right = bb3; + bb3.left = bb4; + bb3.left = bb5; + + BinaryNode bc1 = new BinaryNode(); + BinaryNode bc2 = new BinaryNode(); + BinaryNode bc3 = new BinaryNode(); + BinaryNode bc4 = new BinaryNode(); + BinaryNode bc5 = new BinaryNode(); + BinaryNode bc6 = new BinaryNode(); + BinaryNode bc7 = new BinaryNode(); + bc1.item = "+"; + bc2.item = "*"; + bc3.item = "2"; + bc4.item = "3"; + bc5.item = "*"; + bc6.item = "4"; + bc7.item = "5"; + bc2.parent = bc1; + bc3.parent = bc2; + bc4.parent = bc2; + bc5.parent = bc1; + bc6.parent = bc5; + bc7.parent = bc5; + bc1.left = bc2; + bc1.right = bc5; + bc2.left = bc3; + bc2.right = bc4; + bc5.left = bc6; + bc5.right = bc7; + + BinaryNode bd1 = new BinaryNode(); + BinaryNode bd2 = new BinaryNode(); + BinaryNode bd3 = new BinaryNode(); + BinaryNode bd4 = new BinaryNode(); + BinaryNode bd5 = new BinaryNode(); + BinaryNode bd6 = new BinaryNode(); + BinaryNode bd7 = new BinaryNode(); + bd1.item = "*"; + bd2.item = "2"; + bd3.item = "+"; + bd4.item = "3"; + bd5.item = "4"; + bd6.item = "*"; + bd7.item = "5"; + bd2.parent = bd1; + // bd3.parent = // Nicht möglich. Da Braum 3 Zweige benötigt. + + } + + private static boolean find(BinaryNode tree, String find) { + if (tree.item == find) + return true; + else { + // TODO: implement walk algorithm + return false || true; + } } private static void tokenizeAndCalc(String in) { diff --git a/src/app/BinaryNode.java b/src/app/BinaryNode.java new file mode 100644 index 0000000..2178b67 --- /dev/null +++ b/src/app/BinaryNode.java @@ -0,0 +1,8 @@ +package app; + +public class BinaryNode { + String item; + BinaryNode parent; + BinaryNode left; + BinaryNode right; +} \ No newline at end of file diff --git a/src/app/LinkedList.java b/src/app/LinkedList.java new file mode 100644 index 0000000..5ba7b3b --- /dev/null +++ b/src/app/LinkedList.java @@ -0,0 +1,5 @@ +package app; + +public class LinkedList { + // TODO: +} \ No newline at end of file diff --git a/src/app/Node.java b/src/app/Node.java new file mode 100644 index 0000000..39202e1 --- /dev/null +++ b/src/app/Node.java @@ -0,0 +1,7 @@ +package app; + +public class Node { + Item item; + Node next; + Node last; +} \ No newline at end of file