From 21bb6b592d6d611bc55aa882dc941b41c5183181 Mon Sep 17 00:00:00 2001 From: kat-coding <83139590+kat-coding@users.noreply.github.com> Date: Wed, 8 Mar 2023 13:59:29 -0800 Subject: [PATCH 01/10] starter files --- .idea/vcs.xml | 6 ++ src/edu/greenriver/sdev333/BSTSet.java | 96 ++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 .idea/vcs.xml create mode 100644 src/edu/greenriver/sdev333/BSTSet.java diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/edu/greenriver/sdev333/BSTSet.java b/src/edu/greenriver/sdev333/BSTSet.java new file mode 100644 index 0000000..8ea31c4 --- /dev/null +++ b/src/edu/greenriver/sdev333/BSTSet.java @@ -0,0 +1,96 @@ +package edu.greenriver.sdev333; + +public class BSTSet implements MathSet{ + /** + * Puts the specified key into the set. + * + * @param key key to be added into the set + */ + @Override + public void add(Object key) { + + } + + /** + * Is the key in the set? + * + * @param key key to check + * @return true if key is in the set, false otherwise + */ + @Override + public boolean contains(Object key) { + return false; + } + + /** + * Is the set empty? + * + * @return true if the set is empty, false otherwise + */ + @Override + public boolean isEmpty() { + return false; + } + + /** + * Number of keys in the set + * + * @return number of keys in the set. + */ + @Override + public int size() { + return 0; + } + + /** + * Determine the union of this set with another specified set. + * Returns A union B, where A is this set, B is other set. + * A union B = {key | A.contains(key) OR B.contains(key)}. + * Does not change the contents of this set or the other set. + * + * @param other specified set to union + * @return the union of this set with other + */ + @Override + public MathSet union(MathSet other) { + return null; + } + + /** + * Determine the intersection of this set with another specified set. + * Returns A intersect B, where A is this set, B is other set. + * A intersect B = {key | A.contains(key) AND B.contains(key)}. + * Does not change the contents of this set or the other set. + * + * @param other specified set to intersect + * @return the intersection of this set with other + */ + @Override + public MathSet intersection(MathSet other) { + return null; + } + + /** + * Determine the difference of this set with another specified set. + * Returns A difference B, where A is this set, B is other set. + * A difference B = {key | A.contains(key) AND !B.contains(key)}. + * Does not change the contents of this set or the other set. + * + * @param other specified set to difference + * @return the difference of this set with other + */ + @Override + public MathSet difference(MathSet other) { + return null; + } + + /** + * Retrieves a collection of all the keys in this set. + * + * @return a collection of all keys in this set + */ + @Override + public Iterable keys() { + return null; + } +} From 58a71245e6b501d52d542a3b4e82efbb76c70f6d Mon Sep 17 00:00:00 2001 From: kat-coding <83139590+kat-coding@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:00:31 -0800 Subject: [PATCH 02/10] starter files --- src/edu/greenriver/sdev333/HashingSet.java | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/edu/greenriver/sdev333/HashingSet.java diff --git a/src/edu/greenriver/sdev333/HashingSet.java b/src/edu/greenriver/sdev333/HashingSet.java new file mode 100644 index 0000000..0de4665 --- /dev/null +++ b/src/edu/greenriver/sdev333/HashingSet.java @@ -0,0 +1,96 @@ +package edu.greenriver.sdev333; + +public class HashingSet implements MathSet{ + /** + * Puts the specified key into the set. + * + * @param key key to be added into the set + */ + @Override + public void add(Object key) { + + } + + /** + * Is the key in the set? + * + * @param key key to check + * @return true if key is in the set, false otherwise + */ + @Override + public boolean contains(Object key) { + return false; + } + + /** + * Is the set empty? + * + * @return true if the set is empty, false otherwise + */ + @Override + public boolean isEmpty() { + return false; + } + + /** + * Number of keys in the set + * + * @return number of keys in the set. + */ + @Override + public int size() { + return 0; + } + + /** + * Determine the union of this set with another specified set. + * Returns A union B, where A is this set, B is other set. + * A union B = {key | A.contains(key) OR B.contains(key)}. + * Does not change the contents of this set or the other set. + * + * @param other specified set to union + * @return the union of this set with other + */ + @Override + public MathSet union(MathSet other) { + return null; + } + + /** + * Determine the intersection of this set with another specified set. + * Returns A intersect B, where A is this set, B is other set. + * A intersect B = {key | A.contains(key) AND B.contains(key)}. + * Does not change the contents of this set or the other set. + * + * @param other specified set to intersect + * @return the intersection of this set with other + */ + @Override + public MathSet intersection(MathSet other) { + return null; + } + + /** + * Determine the difference of this set with another specified set. + * Returns A difference B, where A is this set, B is other set. + * A difference B = {key | A.contains(key) AND !B.contains(key)}. + * Does not change the contents of this set or the other set. + * + * @param other specified set to difference + * @return the difference of this set with other + */ + @Override + public MathSet difference(MathSet other) { + return null; + } + + /** + * Retrieves a collection of all the keys in this set. + * + * @return a collection of all keys in this set + */ + @Override + public Iterable keys() { + return null; + } +} From a750cb6d80acac6d10c72fd1cd789ecd12198d31 Mon Sep 17 00:00:00 2001 From: kat-coding <83139590+kat-coding@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:17:02 -0800 Subject: [PATCH 03/10] comment added --- src/edu/greenriver/sdev333/BSTSet.java | 6 ++++++ src/edu/greenriver/sdev333/HashingSet.java | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/edu/greenriver/sdev333/BSTSet.java b/src/edu/greenriver/sdev333/BSTSet.java index 8ea31c4..187e56d 100644 --- a/src/edu/greenriver/sdev333/BSTSet.java +++ b/src/edu/greenriver/sdev333/BSTSet.java @@ -1,4 +1,10 @@ package edu.greenriver.sdev333; +/** + * @author Katherine Watkins + * SDEV 333 + * Final Project + * @param + */ public class BSTSet implements MathSet{ /** diff --git a/src/edu/greenriver/sdev333/HashingSet.java b/src/edu/greenriver/sdev333/HashingSet.java index 0de4665..b6aa06a 100644 --- a/src/edu/greenriver/sdev333/HashingSet.java +++ b/src/edu/greenriver/sdev333/HashingSet.java @@ -1,5 +1,12 @@ package edu.greenriver.sdev333; +/** + * @author Katherine Watkins + * SDEV 333 + * Final Project + * @param + */ + public class HashingSet implements MathSet{ /** * Puts the specified key into the set. From a4b3c8b917abc8f3a48f76448d911491417b8dcd Mon Sep 17 00:00:00 2001 From: kat-coding <83139590+kat-coding@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:50:52 -0800 Subject: [PATCH 04/10] started BSTSet class --- src/edu/greenriver/sdev333/BSTSet.java | 103 ++++++++++++++++++--- src/edu/greenriver/sdev333/HashingSet.java | 2 +- 2 files changed, 90 insertions(+), 15 deletions(-) diff --git a/src/edu/greenriver/sdev333/BSTSet.java b/src/edu/greenriver/sdev333/BSTSet.java index 187e56d..be921b3 100644 --- a/src/edu/greenriver/sdev333/BSTSet.java +++ b/src/edu/greenriver/sdev333/BSTSet.java @@ -1,4 +1,7 @@ package edu.greenriver.sdev333; + +import java.util.Iterator; + /** * @author Katherine Watkins * SDEV 333 @@ -6,15 +9,48 @@ * @param */ -public class BSTSet implements MathSet{ +public class BSTSet > implements MathSet{ + private Node root; + private class Node{ + private KeyType key; + private Node left; + private Node right; + private int N; + + public Node(KeyType key, int N){ + this.key = key; + this.N = N; + } + } + /** * Puts the specified key into the set. * * @param key key to be added into the set */ @Override - public void add(Object key) { - + public void add(KeyType key) { + root = add(root, key); + } + private Node add(Node current, KeyType key){ + if(current == null){ + return new Node (key, 1); + } + int cmp = key.compareTo(current.key); + //go left + if(cmp < 0){ + add(current.left, key); + } + //go right + else if(cmp > 0){ + add(current.right, key); + } + else{ + current.key = key; + } + //update N + current.N = size(current.left) + size(current.right) + 1; + return current; } /** @@ -24,7 +60,12 @@ public void add(Object key) { * @return true if key is in the set, false otherwise */ @Override - public boolean contains(Object key) { + public boolean contains(KeyType key) { + for(KeyType currentKey: this.keys()){ + if(currentKey.equals(key)){ + return true; + } + } return false; } @@ -35,7 +76,7 @@ public boolean contains(Object key) { */ @Override public boolean isEmpty() { - return false; + return this.size()>0; } /** @@ -45,9 +86,16 @@ public boolean isEmpty() { */ @Override public int size() { - return 0; + return size(root); + } + private int size(Node current){ + if(current == null){ + return 0; + } + else{ + return current.N; + } } - /** * Determine the union of this set with another specified set. * Returns A union B, where A is this set, B is other set. @@ -58,8 +106,10 @@ public int size() { * @return the union of this set with other */ @Override - public MathSet union(MathSet other) { - return null; + public MathSet union(MathSet other) { + MathSet result = new BSTSet<>(); + + return result; } /** @@ -72,7 +122,7 @@ public MathSet union(MathSet other) { * @return the intersection of this set with other */ @Override - public MathSet intersection(MathSet other) { + public MathSet intersection(MathSet other) { return null; } @@ -86,8 +136,17 @@ public MathSet intersection(MathSet other) { * @return the difference of this set with other */ @Override - public MathSet difference(MathSet other) { - return null; + public MathSet difference(MathSet other) { + //create empty set to hold result + MathSet result = new BSTSet(); + Iterator itr = (Iterator) this.keys(); + while(itr.hasNext()){ + KeyType currentKey = itr.next(); + if(!other.contains(currentKey)){ + result.add(currentKey); + } + } + return result; } /** @@ -96,7 +155,23 @@ public MathSet difference(MathSet other) { * @return a collection of all keys in this set */ @Override - public Iterable keys() { - return null; + public Iterable keys() { + //empty queue to hold my result + + Queue queue = new Queue<>(); + //start recursion + inOrder(root, queue); + //when done return the queue + return queue; + } + private void inOrder(Node current, Queue q){ + if(current == null){ + //do nothing - intentionally blank + return; + } + + inOrder(current.left, q); + q.enqueue(current.key); + inOrder(current.right, q); } } diff --git a/src/edu/greenriver/sdev333/HashingSet.java b/src/edu/greenriver/sdev333/HashingSet.java index b6aa06a..cb5e4e7 100644 --- a/src/edu/greenriver/sdev333/HashingSet.java +++ b/src/edu/greenriver/sdev333/HashingSet.java @@ -7,7 +7,7 @@ * @param */ -public class HashingSet implements MathSet{ +public class HashingSet implements MathSet{ /** * Puts the specified key into the set. * From 396b5fbc69e5f4d57d6383dc1992cc8e952b11d5 Mon Sep 17 00:00:00 2001 From: Katherine Watkins Date: Mon, 13 Mar 2023 14:06:58 -0700 Subject: [PATCH 05/10] added intersection and untion functions --- src/FlightRoutesGraph.java | 71 ++++++++++++++++++++++++++ src/edu/greenriver/sdev333/BSTSet.java | 15 +++++- 2 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 src/FlightRoutesGraph.java diff --git a/src/FlightRoutesGraph.java b/src/FlightRoutesGraph.java new file mode 100644 index 0000000..c06eec4 --- /dev/null +++ b/src/FlightRoutesGraph.java @@ -0,0 +1,71 @@ +import edu.greenriver.sdev333.BSTSet; +import edu.greenriver.sdev333.HashingSet; +import edu.greenriver.sdev333.MathSet; + +public class FlightRoutesGraph { + //two sets needed to model graph/network + //1. set of vertices (points, nodes, etc) -airports + //2. set of edges (where the points connect with each other) -routes + + private class Edge{ + private String city1; + private String city2; + + public Edge(String one, String two){ + this.city1 = one; + this.city2 = two; + } + } + + private MathSet nodes; + private MathSet connections; + + public FlightRoutesGraph(){ + nodes = new BSTSet<>(); + connections = new HashingSet<>(); + } + + public void addNode(String city){ + nodes.add(city); + } + public void addEdge(String city1, String city2){ + connections.add(new Edge(city1, city2)); + } + public MathSet getNeighbors(String city){ + //empty set to hold results + MathSet neighbors = new BSTSet<>(); + //loop through edges looking for node value + for (Edge e: connections.keys()) { + if(e.city1.equals(city)){ + neighbors.add(e.city2); + } else if (e.city2.equals(city)) { + neighbors.add(e.city1); + } + } + return neighbors; + } + + + public static void main(String[] args) { + FlightRoutesGraph g = new FlightRoutesGraph(); + //add cities +// g.addNode("SEA"); + g.addNode("JFK"); + g.addNode("ORD"); + g.addNode("ATL"); + g.addNode("MCO"); + g.addNode("DEN"); + + //add connections + g.addEdge("JFK", "MCO"); + g.addEdge("ATL", "MCO"); + g.addEdge("DEN", "ORD"); + g.addEdge("ORD", "ATL"); +// g.addEdge("JFK", "MCO"); +// g.addEdge("JFK", "MCO"); +// g.addEdge("JFK", "MCO"); + + //look for direct flights from JFK + MathSet directJFK = g.getNeighbors("JFK"); + } +} diff --git a/src/edu/greenriver/sdev333/BSTSet.java b/src/edu/greenriver/sdev333/BSTSet.java index be921b3..024161c 100644 --- a/src/edu/greenriver/sdev333/BSTSet.java +++ b/src/edu/greenriver/sdev333/BSTSet.java @@ -108,7 +108,12 @@ private int size(Node current){ @Override public MathSet union(MathSet other) { MathSet result = new BSTSet<>(); - + for (KeyType key : other.keys()) { + result.add(key); + } + for (KeyType key : this.keys()) { + result.add(key); + } return result; } @@ -123,7 +128,13 @@ public MathSet union(MathSet other) { */ @Override public MathSet intersection(MathSet other) { - return null; + MathSet result = new BSTSet<>(); + for (KeyType key : other.keys()) { + if(this.contains(key)){ + result.add(key); + } + } + return result; } /** From ed9b7bfa9d05b1fb64641a319228f98b4738f7f4 Mon Sep 17 00:00:00 2001 From: Katherine Watkins Date: Mon, 13 Mar 2023 16:25:22 -0700 Subject: [PATCH 06/10] completed BSTSet --- .../FinalProject/FlightRoutesGraph$Edge.class | Bin 0 -> 608 bytes .../FinalProject/FlightRoutesGraph.class | Bin 0 -> 2334 bytes out/production/FinalProject/Main.class | Bin 0 -> 2266 bytes .../edu/greenriver/sdev333/BSTSet$Node.class | Bin 0 -> 840 bytes .../edu/greenriver/sdev333/BSTSet.class | Bin 0 -> 4696 bytes .../edu/greenriver/sdev333/HashingSet.class | Bin 0 -> 1501 bytes .../edu/greenriver/sdev333/MathSet.class | Bin 0 -> 687 bytes .../sdev333/Queue$LinkedListIterator.class | Bin 0 -> 1322 bytes .../edu/greenriver/sdev333/Queue$Node.class | Bin 0 -> 673 bytes .../edu/greenriver/sdev333/Queue.class | Bin 0 -> 1943 bytes src/Main.java | 53 +++++++++++++++++- src/edu/greenriver/sdev333/BSTSet.java | 16 +++--- 12 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 out/production/FinalProject/FlightRoutesGraph$Edge.class create mode 100644 out/production/FinalProject/FlightRoutesGraph.class create mode 100644 out/production/FinalProject/Main.class create mode 100644 out/production/FinalProject/edu/greenriver/sdev333/BSTSet$Node.class create mode 100644 out/production/FinalProject/edu/greenriver/sdev333/BSTSet.class create mode 100644 out/production/FinalProject/edu/greenriver/sdev333/HashingSet.class create mode 100644 out/production/FinalProject/edu/greenriver/sdev333/MathSet.class create mode 100644 out/production/FinalProject/edu/greenriver/sdev333/Queue$LinkedListIterator.class create mode 100644 out/production/FinalProject/edu/greenriver/sdev333/Queue$Node.class create mode 100644 out/production/FinalProject/edu/greenriver/sdev333/Queue.class diff --git a/out/production/FinalProject/FlightRoutesGraph$Edge.class b/out/production/FinalProject/FlightRoutesGraph$Edge.class new file mode 100644 index 0000000000000000000000000000000000000000..245bf795c80c6b98aa376c1b6636663a267f3b3d GIT binary patch literal 608 zcmZuu$xZ@65Pdx}$~Ll#xPr<7a6vtadLeEJ!9)y4lL0!=WSlWGjmFRNKukRN0e+OR zdSdi2rjveE)%EJ7UVnbQe*ieeb_^Qy2n-W*m}e+l*kUx6x9(JO|I)J_$CdNph%?N~ zvG6Mg47qlwr5Q&Qu?XTO5-=Ik6YI%p*p@SD-1H}WAc=k=93jsb^lGiAG?OM$NHfe0 zgnT(<$hQATUFivD)KqO*6S?2EBZlMZKk{K}xKise7%g{5tEAe(;hpJ2pL=&!-=<2o z?G7xvXL&;9KSe`r%uoyq29`8w7uO-OE}vb7c-NhJ1AZaYys(S=YCDE#hx_u%^<@NQ zhD^vw2J_l+xYx2R-{+)mDECn&C!+LUIw846k)~_`(rNW=lruUBl8DjFBu&d9gC(k$Nr$*7Vwq4yEA*-b(JDncoi)ld StYag<5;h6rq^_ZaEok4PD1nIp literal 0 HcmV?d00001 diff --git a/out/production/FinalProject/FlightRoutesGraph.class b/out/production/FinalProject/FlightRoutesGraph.class new file mode 100644 index 0000000000000000000000000000000000000000..33a8058e026f17ac51bda10c375ff61a7f28098e GIT binary patch literal 2334 zcmbVNYg1ZR6kP{U5N;Ah<11=4wNV~Q<10pN(uf+3fK@E5rmrj9!d1MO%f+cbCBL9w z+nFSeai-JH`91xV>1&+}Dh91H9i4N}WAAnLUVEL*yT9N52H-Q4yl}wjhD$*M8U>nn z)B`nAP>ozP6QUM*XW=&3Bj@KDQYXDQ0$;dC+38ZDXcNKh$K>^pUc1W7q zhXXaf%a&%U+XXG^!#xbSF{~hfpn(58-cu6+k1nmPqFIAdw)8^8HsL-|!WeO5R6zuv zo}yeZ5pd_#Qd0Ygil7j-q{o8suHebpJ!4)<(CNWE<9)WcB3FwFo??la zu((Nz?*puAD1o#G&*-$eKJP)ClP4Q-50acDVyhl}!O8qWQsS*ENMWObCyOsIR4bVO zsIT-+EBFdu3n)3wN@{!_+eMS`v6CfHzevn;C6UmyFf7mQnet+0c?&$x3LFTp}yW>~3bP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AR!#IplbmBUWVh&;4;@xxy-6(P#m2n(3p62^FfzNOfpW_t1L@##GhacEhKjRF3 zA=7UhD}QjX97ezB;rxgoCQf5OoafNUU{EY@U@US{=(r@-I3+$|v6#i~0gR*WzhSRCIIhg{Q)r2R*+=C=WBEbg;?**=`vul^zLW2Lw2V&xb zKfoVl{BFBoG^S13)9>8xob#P??$2M}e*k!crUe7J0!$luYzdsm*}|DCDFfv#rE;Q~ zT(;Y7=k0JblyQ9!&ZNLreCb8?R{}@S>-cUkcRo(8?9k5tTj@2&)Ywht zy4UvtIapjzq#Efy1uFe;>iT0>c^cn3O+9`+o4?N3?d|zaW1}+3UK)lAHI?r?opC$e zgqx{$rjq7Due8pK7AbNd9!y92rP7rmRDvl%;j29XuiHgkA$rQBUkCp3|17 K)4(YjFn$Bu2(l3X literal 0 HcmV?d00001 diff --git a/out/production/FinalProject/edu/greenriver/sdev333/BSTSet.class b/out/production/FinalProject/edu/greenriver/sdev333/BSTSet.class new file mode 100644 index 0000000000000000000000000000000000000000..ed720d8e953faaee6b2cb6c6715e2d1aceb8af29 GIT binary patch literal 4696 zcmb7HZBrZ96@IR?SVCIx3l1rcv9XP9A<0%_CuwaQ8k^#j8gN`F4J4r~(i+wl66nQ^ zlfETw(j@I4aGJh-;)|!_v@tI6OsC&E(|^$Ehkj^(MaFIVoV_dUs%C)bb>=ZI>#}ExVGd7VKMR&z{X)nw*-nx!0(a%Y5{YZ7J73Q7+hn z399Ziu^W46$|@8T=2JV_H|D!MTwY$WD%L{L9vs-o))@9F9Npfx1omRTF!Y4Nxow;p z+}xj0;chRUH1Q?$5a3PwwnF#jvPnFJgE91)IE2Fr`!@rq(4KeE+EZnPCsF}TI&gyn zqhj!giK7xJqiA2R$wa@2<1*1!aTb?qLi$M)DGX4g>bzkqoZJSWj+WM*F_Fb71vSC{ zQBjsN@nt+sWdv9y!qh;(v(cKZqm#s0JQKsSCZ5Ar6!!TD8zKsEN2F`zNE6Bw#rf?`EyT+~B5=%q`CnV{whUlLb{nt!< z3zMWIUoO=wr$lFZf)NkqJuzOvw`Idf4Bt^W7~;USx?Q&um_}4A%$j%wuaYjObhT2j z$@$2R(jctLTd&8;!#f%nMts4Y2U_3+ka z2BlI~TmNJ%2uM zO8DI@C_faC@Va!Etxai8OqT1FynWe`9+1@DpO$lnZxeR4Hf~FgU=J`yOC`H9T(qiH zo3DoS6C7cWj6kuqDn5Dl;WN)0R0IWda?HyUe{IfOiq~^ znKa+~vaVNsYdF~ZYj5tDo;$XNcqV%v-CA%RCuGAhKIe`3`$%W*(T3qNltzN%<9s_o zKTG?oMMtT z2z{wyQ%b`TDG8>4FcE!(L=5K+enx-uoQa^ywHj~yI!mYc6zCnqarr~Uj5QbmM|HNo z6v);N&mBKoWkyVk!8SyaFNj87gZL|nJ3^acq20|}23%+e*1~K+d;4SBWk$3|>UNJw$xw0Y=9&8~CPzn+Ox9yhP~XKqta^BimzaU_64g&;Q-bnC%3! z_h>;U%u%)-Fo)xGD}_~Ftt-4aS8Q_Q!CAdG;9&J(BN28F<8fpBsMA zAP)cZh#T69xT68$(mlpHUb=&%&)`1-#2jFZfu9o0I|TkNp2p93wSS)<0w1`9NOMT> zYey3T3^i#OYSQprfCgV)gBN)XUgR}+k#B(Cjc5~mzh7hm`iJ45A5Ve)0OXA1%2Wg& z20{P*G0=Ai`j_mH9})Dg2>Le!{o5w!6X?Q^+$`7`Xf6K*K=0ELKhX-B-+YX)6zNS? zj}&RwLrk+oULI?lTQhF2*Bw9?>s=!GJ%e;FP^?{EpyDjnALA|Z=@+Z4Nl^6K+g#JF z?I$$IuNTjO-_ZeSpndET#>b8GX~sRc*72Hq{_t>`kuy|RnNFrZ^6ftB=ubQ|H+WWl zioJ&rw0Y?dU J6vxjI`5!kf*0lft literal 0 HcmV?d00001 diff --git a/out/production/FinalProject/edu/greenriver/sdev333/HashingSet.class b/out/production/FinalProject/edu/greenriver/sdev333/HashingSet.class new file mode 100644 index 0000000000000000000000000000000000000000..38f4d8125dcf0700c935d9b84c2d7ce9b333fe32 GIT binary patch literal 1501 zcmb7?&2kb!5Xb+syMzQ$qA~cH7!oz$A(X{U5KApJDM>t#qDpfb*a=J|v#H&IDtsmn zda}xc58y*t_P{1A5DIdjo1X6eZGZj!_xlfkm&hhy!H&a8B8CNqyW6w5@ix$82lW-H^9DduYA{VIB<-U%neV#8CKOGPzbn*D_#E`xWcXPO8! zTe6)%exvru*kg!wl=KwCo9wib!$B5vvjPa_>6Y*rHfDz=rP9I=X!rfkCtP`aEPSCF zRGCBVQa|ZzF4FNHg_}Lmu$HQ_skrX=6#Kapj`2k#c5qb1^5oNu!bX>psCpg0A>K=K zEvez=cg!A;L7c9ds-Y8KB2AY~@)}vMNi)*1XTQLH(jOa1lEw`raGhjw5P%y+S#Up7}ih literal 0 HcmV?d00001 diff --git a/out/production/FinalProject/edu/greenriver/sdev333/MathSet.class b/out/production/FinalProject/edu/greenriver/sdev333/MathSet.class new file mode 100644 index 0000000000000000000000000000000000000000..b6d6603a0d19b469812aad23f7fe81264f5f1065 GIT binary patch literal 687 zcmah{O;5r=5S>M!fT;KZekCT}+6z5!v&g|j6C%a~#29Z&JK!QNWV>xrf0_q>fIrGO zEu;bb;Iw)BX5Z|*H=kec9{_L(rv_vgoS_%kLxm`n2vOO-hhd}9us@Ykk9P5EWu`7m>>p&rcve~=Es25E!p$hIqYA&Sz$Lpu% z7X%IAU%yUuL`_YLaMl-Zq)VX9AQwn6kqoZP&i{ir*17@)kLyI5=_swWdW*F*laLyf zPu?ZpEqP)vK!wt!NwO~(ksUSDT5z*X<-9*ehr#);#Ik<9IXC%YL1Pw{)B1VEpwyiN z%EcQojx(C4U60euGaz?qMF0vEeh%`44MLd&7on8mP2$V21@V$>!%lKmU^nIW=zf0% VAFSXi)YAGx>M`qd1jk9olW*pStgrw8 literal 0 HcmV?d00001 diff --git a/out/production/FinalProject/edu/greenriver/sdev333/Queue$LinkedListIterator.class b/out/production/FinalProject/edu/greenriver/sdev333/Queue$LinkedListIterator.class new file mode 100644 index 0000000000000000000000000000000000000000..e6bebdee34e47f0910f0c4c739f3373dce8380bc GIT binary patch literal 1322 zcmaJ=TTc^F5dKcPux;6vT5c+cAXR%&7O2-0hzSXiq}G@=eem*dXb)wfY{}WPM1PSl zK4=0l@xezQ{87d^yG@|h?8EMynKSdvd^2-?|M~F~z!sh-5kuUBVPOp847TX_c2^4F zO6N>S+v|w4N~L1I@r5t)HOD;`otopRJtZVpeaSGc4jnJQ#;{n6imj%QK+;6Y!UQaa z>=8fXc8|MV`}O{jXe&b6bX-SmGsFwURuUOZn#fwXh8)8}6gI=yfg?SFSc$A5U+;HB zRWqKpFr#73wlAe{RT6W!ZsLZ8o0w-;CGFc=-KI76=XFA+*Ghg%jFbppc`AC-wE zat!=@<@D^!<|P|W*X7EWf?6M0`(~4(PMV)iMRj{M;6Y^;B15Xh78S5VoEau*bfWH` z>Jn;x)Qo1Z*C1uTEVI z_Tnu=x}kXc_!U1L;7=Edqcb4l4)u#6b=fxtt5CeEZj8o-mZ2$Kt&qw|HTu46i(N-I zF%`UvRXtjUL|u65Wnb^1wdcA*?)13l3F>EVlo%DLr-&um#snB{lZ@%5r1LU8%^2=v zv-(ZaIZn0-tk6GCS}X7ba;5SGSm`^=Qu!R|3ru|reDBgfLovWRB=Mf!&j;Ki&7ydU z!hIA-7Kbb)(iqBkFv!s)slC&sb4>k$X?%te|3U@>8h$*uq2buop*Amc2Bf?5?4Ngxdy^8~Ib rUEb;3;oTbDg)LpD`oq%(Ds&&iBRmdd22V)lf}%2bN^*{x_zbbX*4!!J literal 0 HcmV?d00001 diff --git a/out/production/FinalProject/edu/greenriver/sdev333/Queue$Node.class b/out/production/FinalProject/edu/greenriver/sdev333/Queue$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..8e49b37a6c8af1968a2ded784d5ff28e53d85619 GIT binary patch literal 673 zcmaJ z>QuT?Ak+I_*$_w!%$X%!&t?JIuB!9?J28g=TuIiCm1NZTfh#sQUH^;k=7I2&5QAkmhe6 znO~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enriver.sdev333.BSTSet; +import edu.greenriver.sdev333.MathSet; + + public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); + + System.out.println("ISEMPTY ------------"); + MathSet one = new BSTSet<>(); + System.out.println(one.isEmpty()); + one.add("first"); + one.add("second"); + one.add("third"); + one.add("fourth"); + System.out.println(one.isEmpty()); + + MathSet two = new BSTSet<>(); + two.add("second"); + two.add("fourth"); + two.add("sixth"); + two.add("eighth"); + + //test add + System.out.println("TEST ADD -----------"); + for (String a: two.keys()) { + System.out.println(a); + } + //test size + System.out.println("SIZE ---------------"); + System.out.println(one.size()); + //test contains + System.out.println("CONTAINS -----------"); + System.out.println(one.contains("first")); + System.out.println(one.contains("sixth")); + //test union + System.out.println("UNION --------------"); + MathSet union = one.union(two); + for (String a: union.keys()) { + System.out.println(a); + } + System.out.println("INTERSECTION--------"); + //test intersection + MathSet intersection = one.intersection(two); + for (String a: intersection.keys()) { + System.out.println(a); + } + //test difference + System.out.println("DIFFERENCE----------"); + MathSet difference = one.difference(two); + for (String a: difference.keys()) { + System.out.println(a); + } + + } } \ No newline at end of file diff --git a/src/edu/greenriver/sdev333/BSTSet.java b/src/edu/greenriver/sdev333/BSTSet.java index 024161c..b233297 100644 --- a/src/edu/greenriver/sdev333/BSTSet.java +++ b/src/edu/greenriver/sdev333/BSTSet.java @@ -32,6 +32,7 @@ public Node(KeyType key, int N){ public void add(KeyType key) { root = add(root, key); } + private Node add(Node current, KeyType key){ if(current == null){ return new Node (key, 1); @@ -39,11 +40,11 @@ private Node add(Node current, KeyType key){ int cmp = key.compareTo(current.key); //go left if(cmp < 0){ - add(current.left, key); + current.left = add(current.left, key); } //go right else if(cmp > 0){ - add(current.right, key); + current.right = add(current.right, key); } else{ current.key = key; @@ -76,7 +77,7 @@ public boolean contains(KeyType key) { */ @Override public boolean isEmpty() { - return this.size()>0; + return this.size() == 0; } /** @@ -150,11 +151,10 @@ public MathSet intersection(MathSet other) { public MathSet difference(MathSet other) { //create empty set to hold result MathSet result = new BSTSet(); - Iterator itr = (Iterator) this.keys(); - while(itr.hasNext()){ - KeyType currentKey = itr.next(); - if(!other.contains(currentKey)){ - result.add(currentKey); + + for (KeyType a: this.keys()) { + if(!other.contains(a)){ + result.add(a); } } return result; From efc3aed2e32e758388b1c6347e459d87652e14f8 Mon Sep 17 00:00:00 2001 From: Katherine Watkins Date: Tue, 14 Mar 2023 12:19:25 -0700 Subject: [PATCH 07/10] finishing HashingSet --- out/production/FinalProject/Main.class | Bin 2266 -> 2322 bytes .../edu/greenriver/sdev333/HashingSet.class | Bin 1501 -> 3659 bytes src/Main.java | 6 +- src/edu/greenriver/sdev333/HashingSet.java | 90 +++++++++++++++--- 4 files changed, 78 insertions(+), 18 deletions(-) diff --git a/out/production/FinalProject/Main.class b/out/production/FinalProject/Main.class index 86b3e36e367bdfd6557e0d6df8e90df7bf8465a9..0ab0946cd4e042e431d3476375b2806a7b2eb296 100644 GIT binary patch delta 1165 zcmZvb-*XdH6vsbjH`!g%mDX5V(r9U^N<$k{N()jzsVKB4Ez(*+e#WwG7BSQ$U~JUz z2l&L!IKvBrzUT}OOkoBl%=qKY8Q*>Jfd}=?N8g+QJ)49u&Y0P`=X=k+pYy%hd-m6- zuf}6PKf3=tu$Ssu?3!3MFA4p@dg)G0Ws5mKzdYxaVx%!0wh7UqUoPbwwhNZ$FXuu% z9(*TBYp2W0>H zd&pXS`9mGU<#5dF=r%TRkrkb-<0A^1QP|v$i39R=uogX3O&`BU=J0TQON{}8;rLK9 zjx^)wf9AKb<70PeAFi=Os4*eTq-*RGu8~mjhVUcP6A|5)i0Hm={`n(B-c+ekYabTw z@^+Y;uji`vP`tm!f}!c&a7$c`TeJ9kx@kzwP8xNe$DR|BM5O836RM_dR0|}cb=%)U zi?dDoeS-$k;-iUZgRjyP%4Pv8EMPq;;57>@Yk@k_Dqtn7)&W#Cc{}9o1|MEagz#Ff zv!#9o4q;!l@vL6X^E|~c>#2^>&K^xq5$A|@+%Y;i%La0E>CJUhriUvexuMv%JjYEo zafd#BU^724z%N?rcV6UAHTjD{=^`b)Y?Xe7Bt=?A^+Q`ABc~aWETiJceq4 zqsj4v!c$!n4NyY6$viqFTpg|HHaKiA^Mv#+lOuH7EuNK?#}xCA#G>u7^16S1#aJ9S zIYF;|)6*U~C27%ESL@-<)?HnaJ(KICoiT~it1y$PbYf&Q(U(qMN*VOo0dHtw!ld8X z44g~$_a{aYslJ4t!52;5J*syAO->B4a#ZMIld`H8uf+RSPobXWwui(z+Y;owSkuK9 zxG1Y4Qe2XVkUdp+FhJe6Kl$3S3wowlbTAyOnr691I9TiYI@j0d{B!)lbuXC{o@Rq$ zng&HoGPWruu>|Z?yk$?LSMn^cT<{y;(q-zG3|D^1HJnM&?m111j8WVp2wXe`n diff --git a/out/production/FinalProject/edu/greenriver/sdev333/HashingSet.class b/out/production/FinalProject/edu/greenriver/sdev333/HashingSet.class index 38f4d8125dcf0700c935d9b84c2d7ce9b333fe32..36ae82bf92035784a12dc728b07c6cf81e6438d1 100644 GIT binary patch literal 3659 zcmai0+fo!)6kTVgVYoDMk&DV*B!S^(L=$BIZ_z*m6d|Y>6Nj0GX}|%886#FMFTSL5 zDSgyvQt`!y_>fdZEMg@ekcWJMx69(vY>gdwOQXk)oJBeR`jL)>?b*)BXE@ zzx)QE4~YVJ;PpY%k%L@?MkAc)nu!@kG-h5gVqHsN<4SjTch^90DPl%v#*DZ^Zm$_N zVGr~jWQe0xU>L^Erf+w=1P<4LjWpRN5lptUB-=LbhHWzZOOc5NI;9s<`<#^oj!Ew*o`+7>ar+29E?XSd9^uXnfq3@w5FjP zj2p4w)VvWWL^t;OuusREcuS!yC3iA}=uL@^FT~QaSQ=X)oM)B;=WyO z2}(I2WiG*xj$w>Y@ENgT1>KjXkh8x8pVBcZ`}>UOWl2E9wke8fGGiohY08L=i<)FU zv=9o;PXuG8+&hz6JYuo}O+#5wrJ5l?g)=iOFDA2eZoa&C{DiSQ&Lx3Tg?(O5hf zni~!-I#9ecgP=^6+2N^>?=I$e%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KOGPzbn*D_#E`xWcXPO8! zTe6)%exvru*kg!wl=KwCo9wib!$B5vvjPa_>6Y*rHfDz=rP9I=X!rfkCtP`aEPSCF zRGCBVQa|ZzF4FNHg_}Lmu$HQ_skrX=6#Kapj`2k#c5qb1^5oNu!bX>psCpg0A>K=K zEvez=cg!A;L7c9ds-Y8KB2AY~@)}vMNi)*1XTQLH(jOa1lEw`raGhjw5P%y+S#Up7}ih diff --git a/src/Main.java b/src/Main.java index 177aba5..779f7fc 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,4 +1,5 @@ import edu.greenriver.sdev333.BSTSet; +import edu.greenriver.sdev333.HashingSet; import edu.greenriver.sdev333.MathSet; @@ -14,11 +15,12 @@ public static void main(String[] args) { one.add("fourth"); System.out.println(one.isEmpty()); - MathSet two = new BSTSet<>(); + MathSet two = new HashingSet<>(); two.add("second"); two.add("fourth"); two.add("sixth"); two.add("eighth"); + two.add("sixth"); //test add System.out.println("TEST ADD -----------"); @@ -50,7 +52,5 @@ public static void main(String[] args) { for (String a: difference.keys()) { System.out.println(a); } - - } } \ No newline at end of file diff --git a/src/edu/greenriver/sdev333/HashingSet.java b/src/edu/greenriver/sdev333/HashingSet.java index cb5e4e7..87c13f9 100644 --- a/src/edu/greenriver/sdev333/HashingSet.java +++ b/src/edu/greenriver/sdev333/HashingSet.java @@ -1,21 +1,48 @@ package edu.greenriver.sdev333; +import java.lang.reflect.Array; +import java.security.Key; +import java.util.ArrayList; +import java.util.LinkedList; + /** * @author Katherine Watkins * SDEV 333 * Final Project - * @param + * @param */ -public class HashingSet implements MathSet{ +public class HashingSet implements MathSet{ + private LinkedList [] hs; + private int M; + + public HashingSet(){ + this(997); + } + public HashingSet(int M){ + this.M = M; + hs = new LinkedList[M]; + for(int i= 0; i(); + } + } + private int hash(KeyType key){ + return (key.hashCode() & 0x7fffffff) % M; +// return 1; + } + + /** * Puts the specified key into the set. * * @param key key to be added into the set */ @Override - public void add(Object key) { - + public void add(KeyType key) { + int index = hash(key); + if(!hs[index].contains(key)) { + hs[index].add(key); + } } /** @@ -25,7 +52,11 @@ public void add(Object key) { * @return true if key is in the set, false otherwise */ @Override - public boolean contains(Object key) { + public boolean contains(KeyType key) { + int index = hash(key); + if(hs[index].contains(key)){ + return true; + } return false; } @@ -36,7 +67,7 @@ public boolean contains(Object key) { */ @Override public boolean isEmpty() { - return false; + return size() == 0; } /** @@ -46,7 +77,11 @@ public boolean isEmpty() { */ @Override public int size() { - return 0; + int size = 0; + for(int i=0; i < M; i++){ + size += hs[i].size(); + } + return size; } /** @@ -59,8 +94,15 @@ public int size() { * @return the union of this set with other */ @Override - public MathSet union(MathSet other) { - return null; + public MathSet union(MathSet other) { + MathSet union = new HashingSet<>(); + for (KeyType key: other.keys()) { + union.add(key); + } + for(KeyType key : this.keys()){ + union.add(key); + } + return union; } /** @@ -73,8 +115,14 @@ public MathSet union(MathSet other) { * @return the intersection of this set with other */ @Override - public MathSet intersection(MathSet other) { - return null; + public MathSet intersection(MathSet other) { + MathSet intersection = new HashingSet<>(); + for(KeyType key : other.keys()){ + if(this.contains(key)){ + intersection.add(key); + } + } + return intersection; } /** @@ -87,8 +135,14 @@ public MathSet intersection(MathSet other) { * @return the difference of this set with other */ @Override - public MathSet difference(MathSet other) { - return null; + public MathSet difference(MathSet other) { + MathSet difference = new HashingSet<>(); + for (KeyType key: this.keys()) { + if(!other.contains(key)){ + difference.add(key); + } + } + return difference; } /** @@ -97,7 +151,13 @@ public MathSet difference(MathSet other) { * @return a collection of all keys in this set */ @Override - public Iterable keys() { - return null; + public Iterable keys() { + Queue queue = new Queue<>(); + for(int i =0; i Date: Tue, 14 Mar 2023 12:21:57 -0700 Subject: [PATCH 08/10] test with FlightRoutes --- .../FinalProject/FlightRoutesGraph.class | Bin 2334 -> 2588 bytes src/FlightRoutesGraph.java | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/out/production/FinalProject/FlightRoutesGraph.class b/out/production/FinalProject/FlightRoutesGraph.class index 33a8058e026f17ac51bda10c375ff61a7f28098e..898ad55391c8e78eb8614034dc25f61153c9554e 100644 GIT binary patch delta 873 zcmZuvOHUJF6g}Te+ZoyhbpR0s0~*xWng$f9C?b|tN*@%8Z+whWv863o3WzUs3kw$$ zBqqkKYcwIj1##`lAEAH1r3>)PM@1KAGT(iC=iIsX+<9-jt95_f{Ja668?RQ~KNK|` z?zMg@?QH{*n2xxBIyl^?BT1)sB(5VxClMOdF-)f~oOHv35ic&|iWOIbu4`Ug#|>*y zjZ9Qw6t^_o_Tmoi3hd6Avt}S~7RLkW`RQ_|K>p-RS)eX1Z?cntR4H35r^}^`Svc#) zJ>1tY=0yhm0yY1^2xwC_BVYXVO|^s~Ov`jG9)7@K6pZt&!!8JH#}DD8?}UqI)~a^- zPv(d-;NV%$b04t{*w1Hz881=50pwAj6}W_c$t$=TJ8Yht)qy73gA%`2#-0iu)TD?Y z8NwDuGB;eUJ%5?as6mTlHbZ5l+8t&sIwjN2_0m(wrlPc2>yTCwIcr%v8nSyl&aQoE z!z8BU6y{D1v+{MF%txF{L5X;KrtOTa&9t?pH8yQ)Q$`hLFl+b8VN>kLN&Jcx)Q>F; zts(3)qQ>AF(mo?mu|q~o#xWxyZK#qD8BrNWD|tp&6aICy2&|)3AbDaPK7qGrpwlMs z1zlZ^kGR?3ScCat>-#Fd>wv9Ok_rLs3vBrms?k9?PIEb(Xr?Gfa0Y&y<4rfu^XNkl z;<$hjN;Zm%7( qNzDk|17#C)8ax{6HTZw=2T<{h7Yd%^1+9Zs8nHmnEjY&xDHXnYGql`(OX8f9?5D_!tHof4+PJ&hTb6_~ClzTW#~x ztsLzxG=1hByqVs-Pe(!2==xkx(46fAXYMIM?q(+r$^Hgu#c49KOXh86aGQn&bLIs!VIuX)#MA wYh@+_>hOf8+WE>p(`7l-Bbn#_sY^0eoyQA-U0(7^J|*NBuN4Jxlw$?=FO;QKEC2ui diff --git a/src/FlightRoutesGraph.java b/src/FlightRoutesGraph.java index c06eec4..5c3a821 100644 --- a/src/FlightRoutesGraph.java +++ b/src/FlightRoutesGraph.java @@ -49,7 +49,7 @@ public MathSet getNeighbors(String city){ public static void main(String[] args) { FlightRoutesGraph g = new FlightRoutesGraph(); //add cities -// g.addNode("SEA"); + g.addNode("SEA"); g.addNode("JFK"); g.addNode("ORD"); g.addNode("ATL"); @@ -61,11 +61,15 @@ public static void main(String[] args) { g.addEdge("ATL", "MCO"); g.addEdge("DEN", "ORD"); g.addEdge("ORD", "ATL"); -// g.addEdge("JFK", "MCO"); -// g.addEdge("JFK", "MCO"); -// g.addEdge("JFK", "MCO"); + g.addEdge("SEA", "MCO"); + g.addEdge("SEA", "JFK"); + g.addEdge("JFK", "ATL"); //look for direct flights from JFK MathSet directJFK = g.getNeighbors("JFK"); + for (String a: directJFK.keys()) { + System.out.println(a); + } + } } From 8ff43e1bebae55f30c46c1a20761719e5fddd9d7 Mon Sep 17 00:00:00 2001 From: kat-coding <83139590+kat-coding@users.noreply.github.com> Date: Wed, 15 Mar 2023 14:16:26 -0700 Subject: [PATCH 09/10] fixed small bug in field --- out/production/FinalProject/Main.class | Bin 2322 -> 2278 bytes src/Main.java | 2 +- src/edu/greenriver/sdev333/HashingSet.java | 9 ++------- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/out/production/FinalProject/Main.class b/out/production/FinalProject/Main.class index 0ab0946cd4e042e431d3476375b2806a7b2eb296..bdd959557de3cf94a302b4bfd6f22db864939c97 100644 GIT binary patch delta 975 zcmZuvOHUI~6#njXUJR3ngF=QTh!6t^SVRy7K@>r&P!LKL#Ycr{8NecK!3rj zV#3a7qDzA&kh(Cg-T4FD7-QnvoeAi<(_svWlgT;XJ@f%#4t)N3kC(bzSLT6Do&MN59 zan4y0YSeD@>bQVD=e1B(evzSMCcYF8&Bas6&}cSor;;kd&Q~E=dqu|p1{uVRy=*ZA z>gvN9N-(6O6vH&G3)ja~j5vn^K{={p3^AuCaHRS=!-26#cqmfUwC5>?i5og@V#0YE z7;3#uv~VQaH!|AS8zuHGm(%X*h+~35w^Lawov|jf_Iygkq@#(!GD}B-Z)#I^B4MSi z)TE_g`hBO^&xVr_=)^#kjtVkWn^qy}jJkAm3v9#Po}tROd7Y)I7YLZceOeVEg?XCT z&KD`RdT@LT<%5kzZ5}lO8jS|8H+em@XZ;R}aeNc|8uK{8kViX1gqU3n>o5tNXZVEv z4v~1KNW3?HzH`YXg4D_TGQ%b!e0J5Httt)1;XFnK8dq|PK`#EvxJIM~3L6*PoZZY0 z(GIERAMLSfrcqkW{VI3(6c<&brc^FU|SVoG;ChL0ywW?K*t3;EVOC?4C=UqA$wV9Zn(@)I~!Yy`Q~G(gfEg! zlc9#I_L|@s3h4-Agh9$!%O-=^)*f`B7Na`$AwuQ0V0%=|7Kdoa1lMK3*%9`nnIi0l@QySv-rs%0p z>ah5xYsQMl&9s@CHdV}htdR!U$SefYv;F|p-LsCG&LWO86yawG zd5bv5unL33MTV~k`X%Z!BxXHM( za^Iq+4l=tflzetP{gNR$u8mwdwlWPc=hnjiKtq(f=9^FagDH1JSHXJ7v9sA%0Xn^bf7b&B$h@OU7Q@ two = new HashingSet<>(); + MathSet two = new BSTSet<>(); two.add("second"); two.add("fourth"); two.add("sixth"); diff --git a/src/edu/greenriver/sdev333/HashingSet.java b/src/edu/greenriver/sdev333/HashingSet.java index 87c13f9..58e9a27 100644 --- a/src/edu/greenriver/sdev333/HashingSet.java +++ b/src/edu/greenriver/sdev333/HashingSet.java @@ -1,8 +1,4 @@ package edu.greenriver.sdev333; - -import java.lang.reflect.Array; -import java.security.Key; -import java.util.ArrayList; import java.util.LinkedList; /** @@ -13,7 +9,7 @@ */ public class HashingSet implements MathSet{ - private LinkedList [] hs; + private LinkedList [] hs; private int M; public HashingSet(){ @@ -28,7 +24,6 @@ public HashingSet(int M){ } private int hash(KeyType key){ return (key.hashCode() & 0x7fffffff) % M; -// return 1; } @@ -155,7 +150,7 @@ public Iterable keys() { Queue queue = new Queue<>(); for(int i =0; i Date: Wed, 15 Mar 2023 14:23:34 -0700 Subject: [PATCH 10/10] added to flight routes --- .../FinalProject/FlightRoutesGraph.class | Bin 2588 -> 2739 bytes out/production/FinalProject/Main.class | Bin 2278 -> 2410 bytes .../edu/greenriver/sdev333/HashingSet.class | Bin 3659 -> 3704 bytes src/FlightRoutesGraph.java | 14 ++++++++++++++ src/Main.java | 17 +++++++++++------ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/out/production/FinalProject/FlightRoutesGraph.class b/out/production/FinalProject/FlightRoutesGraph.class index 898ad55391c8e78eb8614034dc25f61153c9554e..67892eb5d88ddfd5def5418e71728606fcaa319e 100644 GIT binary patch delta 903 zcmY+C$xl;J6vlsjZE0zX#wUXynkqpPiVG*eIki-%3__p?iUW%C0OE{89dYCCxiTzG z+_)hS5+!kKV*C$SxX{4=KotG%dlfaWy=S=R`|ds8x#Pu?C6UjIA3g$mcrg)4`m4iq z`|!7?8^iR-Np_{f^vdaIZHy4*NQ|TOJ6V52!SNU;IO#b4=IAL-hZu};hO^F`e{11+ zE`+!kwZEPjhC`j@aAA6|Twp!^^OT8Esmg4*1$>TCj9%e1aiZ8;VCt|=2! z6|822>#{zYXf`38bst%Tfu(A z=+uR(_x**&S;;yV8pkif;w5M?^)A%plJYE}C5Y^h^Ex!*8+MAq8*}FFHR>k8W^QuJ z?QUR+V<3Ngm_BZ+UyD1cH@$ipquE_$q{mOnLgrWdgH0hS7bsoOrYGenh1}!5xxTdd zqKgIvnx7%+OokJ=u4&QW&K z4eh+6gDJYm%?LJ2mT&YhN3T0yGo@J_|3F8WH#pBjaWMsNw^BAwKY3UASUl z;!R}Z#+5r0LS&%{e}D`A3jc~m(eF+x#$@iCbH01NbIko@O|a$641lz`JfUD z0z!t?;Y0hxge2(>pW1RQ7kme$njN|Q0UFM3Eg#HueW1{3tn&m{keo)q(*26ma&y&b8ESRw8U$>aSZ@7u5RlkGl*2DyeVoBBK; z#X}z1_9ejyH5wOb?i-<5P8Q46%<)A|7Bhn_JCqrS;(^RyWcylpU#1$x)fTSklzEft z%AH&1EmHgR`^UV>dRTRi(PoxX8|!6uY3pV7a)4frvX5b@F~)wzIVjx@F{_mrE#*B& zA|0(7vzl*4nprjGc+3;oByV}DB|6F~@$5e}n#f-@*5a-(;}iN6ts)KWHpX++aCyN? QSx;38)a3<{7xD`C4<>YG-v9sr diff --git a/out/production/FinalProject/Main.class b/out/production/FinalProject/Main.class index bdd959557de3cf94a302b4bfd6f22db864939c97..54b8b19d92af8e8503924d41a51e237f2e29c608 100644 GIT binary patch delta 1281 zcmZuwOKcNY6g_vw;~DHx2?ha!qtxM}COE--5|@KnNcbCb1zn!8U;= ztxYS0VAp6iEvxQ|!~zj2P*@;VRm-XpOC%NuwN*FWbx|q6eKV7R1(x;hdH3FP&YO96 z{#^D?B=qFf!$$yi30|?0@$P zHLF}JYS>Ir$|VPGC1}>THRTq%xKJ%!7CqYuL8~-Y6nH10*-YonSYImT=$nJNSm)bc z7zUC$deCb>r?ufd_*lg!I{NUb9hQ2Qq>xt8uj4a2C#};`$msYSU)a-9tZ{(Qbha>6 zNQ@WCV~KpN!UxrmW50Z6D82YB?|KPW;de;KVdM#cYH8Xc$ZhSJ5Ss9%j^!BObX%r< zK*JGM+MCOoeVJ_jJ!)Y`YDmX14BIQ@4Rpdz%F*B{9R-}WkI6YYW8apet4DQ=;WR<# zmu6L})<~^1QPxnhpUcse=X8vVV(3h1bkwR?jdu- z9Eqc{@d4 zzkVqwS%w_r^EgPj4^!j@y_`7DQHirHqN5RELw_4N&P{PPJ1IFni=N4V5%65s2;|u+ ztY9dP?F(Ts;;}6WF2m<5hT`)XdHmoU22>;XR-ot!oMi!r;tK?gpfAA46HvtgRF^NV zDFAUzbLg;7s;!L_mSI04FnQvJu>wV`~I2_zNH5U$kKX?G#3wmZO8B=%hW^MEyumhQHNA*h)j#Ms;-2HFVPr?4Vif zY|u@O%FOmpr#aQ|msp?o;c`Xs}^7v{(2= bh2i{D|D$CA<|2+Qpyj=oO|CFm!nbb#8>#>v delta 1246 zcmZvb%TE(g7{$+>>2zwHM68IZ4=mP4EAmjl2M7vfknu4f9Y9f$f&(4Ys-?w>CUxh= zjZR|X#;6-jT=*a%sS9;y;znKg52$gWOIMnJez%=g7BkofkyRFZAe`l&o{!ia7e*n z93kH+YsO>{Lt)K}GV~}|fnHh;Y2g7+5Pf73>CugLO^+_N;TDF1ehka5+2waRsjIniVkL6$OZnK(JmQo?pB7Lc zO1$KkN<1ltcXQsI=k>h7sAF)34Dv|H!0mUJ3`jW!GB=P58+cBy*adzB_prr&FIQ!| z;X^OA;4zeA1S=6o1ukM0GFXl4ScCgmi^o`pCs>bJ1n?Rg@D@RQ!bW_-X8gbw{6vUV zAj~SUl~tjdg;B$Hpq34wjt$c{8l!L1qO(b&k=;QPyN8|Z0e11@&r$<C^sPmCG%cD5>vGOGIkp&q^VPSSs$iJ3ABx;)c9$L6n>FY9K diff --git a/out/production/FinalProject/edu/greenriver/sdev333/HashingSet.class b/out/production/FinalProject/edu/greenriver/sdev333/HashingSet.class index 36ae82bf92035784a12dc728b07c6cf81e6438d1..e067855ea50fed8d5f7e43cdede577fa5c2ecc5f 100644 GIT binary patch delta 1538 zcmaKsNlz3}6opT9H$BoKQ!@mb$(A@kngAMX5lL8>0Fgi;ARuE4C;~F5tlX)n8&Zi= z{13*MV4{gXK>va(7A{>IBF1yytE%qSgauuXy2JV2eW%{Hs$W&%uYW#$0nmwi@54Vl z(a_M+!ph9%)_U4N{qDP1{zbDly=`uesZU{S}?Vd>3XEIF0}cagD2d<^VyAV3g0XoHy6`pLFo^*R=Nhos-fb&RU=dJ`^K_ z680%YIbulgd4?Sv7XF?yOpl?fivNZ59EzH9aiVT6S>R= z99N|@w4R1q)MjD~0lnN{9}U&dgYV-|ueuxZG2gL5t-Upm8hfr4B<6_GsE6}Zq8Y5|K>4Pt=Gi&T_>WGbiJN?CCuQmRivN|)TyC6-QD&5^1??Z#V-+}2yM z#v^?SypkRO)+x3@uuU{$3+Hej9eALCPg5enuS^32DHk*4Vz#oYgPF-!a4KK3Nxo*2 ze6lqv(-y#ch>`%B0_dnaAaRCu*=Fs}&t`o@*2nbq6SD4*^%+^8yQ~fL^Ua zukc&<@}_KeP1|kHJjlvbtnn1Z5OT}uN=+|WGU;GSrQKzkTnfeT9U>gS72XXY`uW5G REvRR_?oNAyCoi}6)?a1ls)_&r delta 1529 zcmaKsTT4_?7>3_{aE?ymIb|9h&BRkER%9j>Lw6^JJDXYkX&LDqDhX9|B`y=Evh^wyEuu#n1A##XbbGpB* zgw4oOl9(tByKBLO;kX;YM8D{Ws;CKNnd%bryTmYp%jqtem~;UoHpJZLy z<+uf*)(6tLi0nWk6`DxdOpU`nHBjZNRHan{JlQpM5}A+IlPs+#S)w=07@2<~;c1U? zw+6MM&DbNpEq5zaoyBmR6&++a!P_{Q#Zc}ul=}>Y|1n6GW{|8LhEk7VoD3863vZAN zeS8}N8f*N7`WFb=?_gW+xnUzS^K*(sJHwlK#u>7s?u%7VKd(|M|JwJCNmm#nL}cp7_GYl+c36y9R?;br3Y&q;9JxN zzrY;Ygqw;CD25u^8W`tug65n=3oBYNjSEQeuroCLtUBlsR@X60EM+t5t=KV5CaY;y z8H{zaQ;Lc*kWA&MUnwgdL`wDDNa>7UI>XXocO)7w)c%}ha}~#MpH5j*z>SosDk zv;@(S+$M2`buP`inxD=3n5<9e^mVd6CF?V?KKEH`>F~W-=Wl?JC#c$_P-?V4a zGY_$H0XKPzVhFLeuGI9BC6f+ys>WgcIM1&|n0`LEO$+K7FZ$D7!fmFS GSpEkDRi`BY diff --git a/src/FlightRoutesGraph.java b/src/FlightRoutesGraph.java index 5c3a821..73eb33e 100644 --- a/src/FlightRoutesGraph.java +++ b/src/FlightRoutesGraph.java @@ -55,6 +55,11 @@ public static void main(String[] args) { g.addNode("ATL"); g.addNode("MCO"); g.addNode("DEN"); + g.addNode("NED"); + g.addNode("ASE"); + g.addNode("PLD"); + //duplicate + g.addNode("PLD"); //add connections g.addEdge("JFK", "MCO"); @@ -65,6 +70,15 @@ public static void main(String[] args) { g.addEdge("SEA", "JFK"); g.addEdge("JFK", "ATL"); + g.addEdge("JFK", "PLD"); + g.addEdge("ASE", "MCO"); + g.addEdge("DEN", "NED"); + g.addEdge("JFK", "NED"); + g.addEdge("SEA", "ASE"); + g.addEdge("SEA", "DEN"); + //duplicate + g.addEdge("JFK", "ATL"); + //look for direct flights from JFK MathSet directJFK = g.getNeighbors("JFK"); for (String a: directJFK.keys()) { diff --git a/src/Main.java b/src/Main.java index f6c9a60..5f56f0a 100644 --- a/src/Main.java +++ b/src/Main.java @@ -6,32 +6,37 @@ public class Main { public static void main(String[] args) { - System.out.println("ISEMPTY ------------"); - MathSet one = new BSTSet<>(); + System.out.println("ISEMPTY SET ONE ------------"); + MathSet one = new HashingSet<>(); System.out.println(one.isEmpty()); one.add("first"); one.add("second"); one.add("third"); one.add("fourth"); + one.add("first"); + one.add("tenth"); + one.add("ninth"); + one.add("eleventh"); System.out.println(one.isEmpty()); - MathSet two = new BSTSet<>(); + MathSet two = new HashingSet<>(); two.add("second"); two.add("fourth"); two.add("sixth"); two.add("eighth"); two.add("sixth"); + two.add("tenth"); //test add - System.out.println("TEST ADD -----------"); + System.out.println("TEST ADD SET TWO -----------"); for (String a: two.keys()) { System.out.println(a); } //test size - System.out.println("SIZE ---------------"); + System.out.println("SIZE SET ONE ---------------"); System.out.println(one.size()); //test contains - System.out.println("CONTAINS -----------"); + System.out.println("CONTAINS SET ONE -----------"); System.out.println(one.contains("first")); System.out.println(one.contains("sixth")); //test union