├── .gitignore
├── Assignments
├── Assignment 1
│ ├── Assignment 1.docx
│ ├── Assignment 1.pdf
│ ├── Question3.java
│ ├── Question4.java
│ └── Questions.pdf
├── Assignment 2
│ ├── 1d.pdf
│ ├── 1e1.pdf
│ ├── 1e2.pdf
│ ├── 2a1.pdf
│ ├── 2a2.pdf
│ ├── 2a3.pdf
│ ├── 2a4.pdf
│ ├── 2b.pdf
│ ├── 2c1.pdf
│ ├── 2c2.pdf
│ ├── 2c3.pdf
│ ├── 31.pdf
│ ├── 310.pdf
│ ├── 311.pdf
│ ├── 312.pdf
│ ├── 313.pdf
│ ├── 314.pdf
│ ├── 315.pdf
│ ├── 316.pdf
│ ├── 317.pdf
│ ├── 318.pdf
│ ├── 319.pdf
│ ├── 32.pdf
│ ├── 320.pdf
│ ├── 321.pdf
│ ├── 322.pdf
│ ├── 323.pdf
│ ├── 324.pdf
│ ├── 33.pdf
│ ├── 34.pdf
│ ├── 35.pdf
│ ├── 36.pdf
│ ├── 37.pdf
│ ├── 38.pdf
│ ├── 39.pdf
│ ├── Assignment 2.pdf
│ ├── Assignment 2.tex
│ └── Graphs
│ │ ├── Q1
│ │ ├── D
│ │ │ └── BT1D.gv
│ │ └── E
│ │ │ ├── BT1E1.gv
│ │ │ └── BT1E2.gv
│ │ ├── Q2
│ │ ├── A
│ │ │ ├── BT2A1.gv
│ │ │ ├── BT2A2.gv
│ │ │ ├── BT2A3.gv
│ │ │ └── BT2A4.gv
│ │ ├── B
│ │ │ └── BT2B.gv
│ │ └── C
│ │ │ ├── BT2C1.gv
│ │ │ ├── BT2C2.gv
│ │ │ └── BT2C3.gv
│ │ └── Q3
│ │ ├── BT31.gv
│ │ ├── BT310.gv
│ │ ├── BT311.gv
│ │ ├── BT312.gv
│ │ ├── BT313.gv
│ │ ├── BT314.gv
│ │ ├── BT315.gv
│ │ ├── BT316.gv
│ │ ├── BT317.gv
│ │ ├── BT318.gv
│ │ ├── BT319.gv
│ │ ├── BT32.gv
│ │ ├── BT320.gv
│ │ ├── BT321.gv
│ │ ├── BT322.gv
│ │ ├── BT323.gv
│ │ ├── BT324.gv
│ │ ├── BT33.gv
│ │ ├── BT34.gv
│ │ ├── BT35.gv
│ │ ├── BT36.gv
│ │ ├── BT37.gv
│ │ ├── BT38.gv
│ │ └── BT39.gv
├── Assignment 3
│ ├── Assignment 3.pdf
│ ├── DecisionStump.java
│ ├── DecisionStumpTest.java
│ ├── DecisionTree.java
│ ├── DecisionTreeTest.java
│ ├── NodeReplaceException.java
│ ├── Printout.txt
│ ├── Readme.txt
│ └── iris.data.txt
├── Assignment 4
│ ├── 1a1.pdf
│ ├── 1b1.pdf
│ ├── 1b2.pdf
│ ├── 1b3.pdf
│ ├── 1b4.pdf
│ ├── 1b5.pdf
│ ├── 1c1.pdf
│ ├── 1c2.pdf
│ ├── 1c3.pdf
│ ├── 1c4.pdf
│ ├── 1c5.pdf
│ ├── 3a1.pdf
│ ├── Assignment 4.pdf
│ ├── Assignment 4.tex
│ └── Graphs
│ │ ├── Q1
│ │ ├── A
│ │ │ └── a1.gv
│ │ ├── B
│ │ │ ├── b1.gv
│ │ │ ├── b2.gv
│ │ │ ├── b3.gv
│ │ │ ├── b4.gv
│ │ │ └── b5.gv
│ │ └── C
│ │ │ ├── c1.gv
│ │ │ ├── c2.gv
│ │ │ ├── c3.gv
│ │ │ ├── c4.gv
│ │ │ └── c5.gv
│ │ └── Q3
│ │ └── A
│ │ └── a1.gv
├── Assignment 5
│ ├── AdjacencyListGraph.java
│ ├── BuildItinerary.java
│ ├── BuildItineraryTest.java
│ ├── DijkstraAlgorithm.java
│ ├── Flight.java
│ ├── Integral.java
│ ├── Printout.txt
│ ├── ReadFlights.java
│ ├── Readme.txt
│ ├── SimpleGraphDijkstra.java
│ ├── Time.java
│ ├── flights1.txt
│ └── flights2.txt
└── resources
│ ├── Readme.md
│ └── binarytree.gv
├── LICENSE
├── Labs
├── Lab 0
│ ├── GNode.java
│ ├── LinkList.java
│ └── me
│ │ └── matt
│ │ ├── DoublyLinkList.java
│ │ └── Node.java
├── Lab 1
│ ├── AlgAnalysis.java
│ ├── Unique1.java
│ └── Unique2.java
├── Lab 10
│ └── SEE LAB 5
├── Lab 2
│ ├── balance
│ │ ├── ArrayStack.java
│ │ ├── Stack.java
│ │ ├── StackEmptyException.java
│ │ ├── StackFullException.java
│ │ └── bracketsBalance.java
│ ├── dLinkList
│ │ ├── DLinkedList.java
│ │ ├── ListNode.java
│ │ └── TestDLinkedList.java
│ ├── index.html
│ └── stack
│ │ ├── ArrayStack.java
│ │ ├── EmptyStackException.java
│ │ ├── FullStackException.java
│ │ ├── Node.java
│ │ ├── NodeStack.java
│ │ ├── Stack.java
│ │ ├── tryStack1.java
│ │ └── tryStack2.java
├── Lab 3
│ ├── NodeList.java
│ ├── Sentence.java
│ └── TestListImplementation.java
├── Lab 5
│ ├── LinkedBinarySearchTree.java
│ └── TestTree.java
├── Lab 6
│ └── Verify.java
├── Lab 7
│ ├── ArrayHashTable.java
│ ├── ChainedHashTable.java
│ ├── DoubleHashStep.java
│ ├── HashFunction.java
│ ├── HashTable.java
│ ├── HashingTest.java
│ ├── LinearProbeStep.java
│ ├── QuadraticDoubleHashStep.java
│ ├── QuadraticProbeStep.java
│ ├── ReverseStringHash.java
│ ├── SteppingFunction.java
│ ├── StringHash.java
│ ├── TheAeneidBook1-3.txt
│ ├── TheOdysseyBook1.txt
│ └── ToyTest.java
├── Lab 8
│ ├── BubbleSort.java
│ ├── HeapSortInPlace.java
│ ├── MergeSort.java
│ ├── QuickSortInPlace.java
│ └── TrySorts.java
├── Lab 9
│ ├── SimpleGraphDFS.java
│ ├── graph.txt
│ └── graph2.txt
└── resources
│ └── net
│ └── datastructures
│ ├── AVLTreeMap.java
│ ├── AbstractBinaryTree.java
│ ├── AbstractHashMap.java
│ ├── AbstractMap.java
│ ├── AbstractPriorityQueue.java
│ ├── AbstractSortedMap.java
│ ├── AbstractTree.java
│ ├── AdaptablePriorityQueue.java
│ ├── AdjacencyMapGraph.java
│ ├── ArrayList.java
│ ├── ArrayQueue.java
│ ├── ArrayStack.java
│ ├── BinaryTree.java
│ ├── ChainHashMap.java
│ ├── CircularQueue.java
│ ├── CircularlyLinkedList.java
│ ├── DefaultComparator.java
│ ├── Deque.java
│ ├── DoublyLinkedList.java
│ ├── Edge.java
│ ├── Entry.java
│ ├── Graph.java
│ ├── GraphAlgorithms.java
│ ├── GraphExamples.java
│ ├── HeapAdaptablePriorityQueue.java
│ ├── HeapPriorityQueue.java
│ ├── LinkedBinaryTree.java
│ ├── LinkedCircularQueue.java
│ ├── LinkedPositionalList.java
│ ├── LinkedQueue.java
│ ├── LinkedStack.java
│ ├── List.java
│ ├── Map.java
│ ├── Partition.java
│ ├── Position.java
│ ├── PositionalList.java
│ ├── PriorityQueue.java
│ ├── ProbeHashMap.java
│ ├── Queue.java
│ ├── RBTreeMap.java
│ ├── SinglyLinkedList.java
│ ├── SortedMap.java
│ ├── SortedPriorityQueue.java
│ ├── SortedTableMap.java
│ ├── SplayTreeMap.java
│ ├── Stack.java
│ ├── Tree.java
│ ├── TreeMap.java
│ ├── UnsortedPriorityQueue.java
│ ├── UnsortedTableMap.java
│ └── Vertex.java
├── Lectures
└── Tests
│ └── test.java
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | CSI2110.iml
2 | out/
3 |
--------------------------------------------------------------------------------
/Assignments/Assignment 1/Assignment 1.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 1/Assignment 1.docx
--------------------------------------------------------------------------------
/Assignments/Assignment 1/Assignment 1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 1/Assignment 1.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 1/Question3.java:
--------------------------------------------------------------------------------
1 | public class Question3 {
2 |
3 |
4 | public static void main(String[] args) {
5 | int size = 10;
6 | System.out.println(perm(size));
7 | System.out.println(calculateSwaps(size));
8 | System.out.println(calculateSwapsString(size));
9 | }
10 |
11 | //Initial recursive call to perm
12 | private static int perm(int size) {
13 | return perm(size, 0);
14 | }
15 |
16 | //Recursive method to calculate number of swaps, based on the algorithm given in class
17 | private static int perm(int n, int i) {
18 | int swaps = 0;
19 | if (i != n) {
20 | for (int j = i; j < n; j++) {
21 | swaps += perm(n, i + 1);
22 | }
23 | }
24 | return swaps + 2*(n-i);
25 | }
26 |
27 | //Iterative method to calculate number of swaps
28 | private static int calculateSwaps(int n) {
29 | int swaps = 0;
30 | for (int i = 1; i <= n; i++) {
31 | int innerResult = n;
32 | for (int j = 1; j <= (n - i); j++) {
33 | innerResult*= (n - j);
34 | }
35 | swaps += innerResult;
36 | }
37 | return 2 * swaps; // The 2 has been factored out
38 |
39 | //size 3: 2(3+3(3-1)+3(3-1)(3-2))
40 | }
41 |
42 | //Iterative method to build the string for the number of swaps
43 | static String calculateSwapsString(int n) {
44 | String sum = "2(";
45 | //Case to handle 0
46 | if (n <= 0) {
47 | return sum + "0)";
48 | }
49 | //Build the string to determine the amount of swaps, not simplified but has 2 factored out
50 | for (int i = n; i > 0; i--) {
51 | String product = String.valueOf(n);
52 | for (int j = 1; j <= (n - i); j++) {
53 | product += "(" + n +"-" +j+")";
54 | }
55 | sum += product + "+";
56 | }
57 | return sum.substring(0, sum.length() - 1) + ")";
58 | }
59 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 1/Question4.java:
--------------------------------------------------------------------------------
1 | import java.util.LinkedList;
2 | import java.util.Queue;
3 | import java.util.Stack;
4 |
5 | public class Question4 {
6 |
7 | public static void main(String[] args) {
8 | Stack s = new Stack<>();
9 | s.push("a");
10 | s.push("b");
11 | s.push("c");
12 | s.push("d");
13 | s.push("e");
14 | System.out.println(s);
15 | swap(s, 1, 3);
16 | System.out.println(s);
17 | }
18 |
19 | public static void swap(Stack stack, int i, int j) {
20 | Queue q = new LinkedList<>();
21 | Stack s = new Stack<>();
22 | int size = stack.size();
23 | for (int n = 0; n < size; n++) {
24 | if (n==i || n == j) {
25 | q.add(stack.pop());
26 | } else {
27 | s.push(stack.pop());
28 | }
29 | }
30 | for (int n = 0; n < size; n++) {
31 | if (n==i || n == j) {
32 | stack.push(q.poll());
33 | } else {
34 | stack.push(s.pop());
35 | }
36 | }
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/Assignments/Assignment 1/Questions.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 1/Questions.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/1d.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/1d.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/1e1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/1e1.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/1e2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/1e2.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/2a1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/2a1.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/2a2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/2a2.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/2a3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/2a3.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/2a4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/2a4.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/2b.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/2b.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/2c1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/2c1.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/2c2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/2c2.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/2c3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/2c3.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/31.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/31.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/310.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/310.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/311.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/311.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/312.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/312.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/313.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/313.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/314.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/314.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/315.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/315.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/316.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/316.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/317.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/317.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/318.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/318.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/319.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/319.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/32.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/32.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/320.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/320.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/321.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/321.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/322.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/322.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/323.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/323.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/324.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/324.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/33.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/33.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/34.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/34.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/35.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/35.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/36.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/36.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/37.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/37.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/38.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/38.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/39.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/39.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Assignment 2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 2/Assignment 2.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q1/D/BT1D.gv:
--------------------------------------------------------------------------------
1 | digraph BT1D {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 20 -> 15;
9 | 20 -> 35;
10 | 15 -> 10;
11 | 15 -> 19;
12 | 35 -> 25;
13 | 35 -> 40;
14 | 10 -> 5;
15 | 10 -> 13;
16 | 19 -> 16 [side="left"];
17 | 25 -> 21 [side="left"];
18 | 40 -> 38 [side="left"];
19 | 5 -> 3;
20 | 5 -> 7;
21 | 13 -> 12[ side="left"];
22 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q1/E/BT1E1.gv:
--------------------------------------------------------------------------------
1 | digraph BT1E1 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 20 -> 16;
9 | 20 -> 35;
10 | 16 -> 10;
11 | 16 -> 19;
12 | 35 -> 25;
13 | 35 -> 40;
14 | 10 -> 5;
15 | 10 -> 13;
16 | 40 -> 38 [side="left"];
17 | 5 -> 3;
18 | 5 -> 7;
19 | 13 -> 12[ side="left"];
20 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q1/E/BT1E2.gv:
--------------------------------------------------------------------------------
1 | digraph BT1E2 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 20 -> 13;
9 | 20 -> 35;
10 | 13 -> 10;
11 | 13 -> 19;
12 | 35 -> 25;
13 | 35 -> 40;
14 | 10 -> 5;
15 | 10 -> 12;
16 | 19 -> 16 [side="left"];
17 | 40 -> 38 [side="left"];
18 | 5 -> 3;
19 | 5 -> 7;
20 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q2/A/BT2A1.gv:
--------------------------------------------------------------------------------
1 | digraph BT2A1 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 1 -> 14;
9 | 1 -> 10;
10 | 14 -> 8;
11 | 14 -> 7;
12 | 10 -> 9;
13 | 10 -> 3;
14 | 8 -> 2;
15 | 8 -> 4;
16 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q2/A/BT2A2.gv:
--------------------------------------------------------------------------------
1 | digraph BT2A2 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 14 -> 1 [arrowhead=vee, arrowtail=vee, dir=both];
9 | 14 -> 10;
10 | 1 -> 8;
11 | 1 -> 7;
12 | 10 -> 9;
13 | 10 -> 3;
14 | 8 -> 2;
15 | 8 -> 4;
16 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q2/A/BT2A3.gv:
--------------------------------------------------------------------------------
1 | digraph BT2A3 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 14 -> 8;
9 | 14 -> 10;
10 | 8 -> 1 [arrowhead=vee, arrowtail=vee, dir=both];
11 | 8 -> 7;
12 | 10 -> 9;
13 | 10 -> 3;
14 | 1 -> 2;
15 | 1 -> 4;
16 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q2/A/BT2A4.gv:
--------------------------------------------------------------------------------
1 | digraph BT2A4 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 14 -> 8;
9 | 14 -> 10;
10 | 8 -> 4;
11 | 8 -> 7;
12 | 10 -> 9;
13 | 10 -> 3;
14 | 4 -> 2;
15 | 4 -> 1 [arrowhead=vee, arrowtail=vee, dir=both];
16 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q2/B/BT2B.gv:
--------------------------------------------------------------------------------
1 | digraph BT2B {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 16 -> 14;
9 | 16 -> 10;
10 | 14 -> 8;
11 | 14 -> 7;
12 | 10 -> 9;
13 | 3.1 [label="3"]; //Special case to allow duplicates
14 | 10 -> 3.1;
15 | 8 -> 2;
16 | 8 -> 4;
17 | 7 -> 1;
18 | 3.2 [label="3"]; //Special case to allow duplicates
19 | 7 -> 3.2;
20 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q2/C/BT2C1.gv:
--------------------------------------------------------------------------------
1 | digraph BT2C1 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 16 -> 14;
9 | 16 -> 10;
10 | 14 -> 8;
11 | 14 -> 7;
12 | 10 -> 9;
13 | 10 -> 3;
14 | 8 -> 2;
15 | 8 -> 4;
16 | 7 -> 1;
17 | 7 -> 15;
18 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q2/C/BT2C2.gv:
--------------------------------------------------------------------------------
1 | digraph BT2C1 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 16 -> 14;
9 | 16 -> 10;
10 | 14 -> 8;
11 | 14 -> 15;
12 | 10 -> 9;
13 | 10 -> 3;
14 | 8 -> 2;
15 | 8 -> 4;
16 | 15 -> 1;
17 | 15 -> 7 [arrowhead=vee, arrowtail=vee, dir=both];
18 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q2/C/BT2C3.gv:
--------------------------------------------------------------------------------
1 | digraph BT2C1 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 16 -> 15;
9 | 16 -> 10;
10 | 15 -> 8;
11 | 15 -> 14 [arrowhead=vee, arrowtail=vee, dir=both];
12 | 10 -> 9;
13 | 10 -> 3;
14 | 8 -> 2;
15 | 8 -> 4;
16 | 14 -> 1;
17 | 14 -> 7;
18 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT31.gv:
--------------------------------------------------------------------------------
1 | digraph BT31 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 20 -> 3;
9 | 20 ->17;
10 | 3 -> 5;
11 | 3 -> 9;
12 | 17 -> 21;
13 | 17 -> 8;
14 | 5 -> 12;
15 | 5 -> 32;
16 | 9 -> 2 [side="left"];
17 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT310.gv:
--------------------------------------------------------------------------------
1 | digraph BT310 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 20 -> 12;
9 | 20 -> 17;
10 | 12 -> 5;
11 | 12 -> 9;
12 | 17 -> 2;
13 | 17 -> 8;
14 | 5 -> 3 [side="left"];
15 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT311.gv:
--------------------------------------------------------------------------------
1 | digraph BT311 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 3 -> 12;
9 | 3 -> 17;
10 | 12 -> 5;
11 | 12 -> 9;
12 | 17 -> 2;
13 | 17 -> 8;
14 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT312.gv:
--------------------------------------------------------------------------------
1 | digraph BT312 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 17 -> 12;
9 | 17 -> 8;
10 | 12 -> 5;
11 | 12 -> 9;
12 | 8 -> 2;
13 | 8 -> 3;
14 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT313.gv:
--------------------------------------------------------------------------------
1 | digraph BT313 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 3 -> 12;
9 | 3 -> 8;
10 | 12 -> 5;
11 | 12 -> 9;
12 | 8 -> 2 [side="left"];
13 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT314.gv:
--------------------------------------------------------------------------------
1 | digraph BT314 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 12 -> 9;
9 | 12 -> 8;
10 | 9 -> 5;
11 | 9 -> 3;
12 | 8 -> 2 [side="left"];
13 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT315.gv:
--------------------------------------------------------------------------------
1 | digraph BT315 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 2 -> 9;
9 | 2 -> 8;
10 | 9 -> 5;
11 | 9 -> 3;
12 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT316.gv:
--------------------------------------------------------------------------------
1 | digraph BT316 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 9 -> 5;
9 | 9 -> 8;
10 | 5 -> 2;
11 | 5 -> 3;
12 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT317.gv:
--------------------------------------------------------------------------------
1 | digraph BT317 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 3 -> 5;
9 | 3 -> 8;
10 | 5 -> 2 [side="left"];
11 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT318.gv:
--------------------------------------------------------------------------------
1 | digraph BT318 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 8 -> 5;
9 | 8 -> 3;
10 | 5 -> 2 [side="left"];
11 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT319.gv:
--------------------------------------------------------------------------------
1 | digraph BT319 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 2 -> 5;
9 | 2 -> 3;
10 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT32.gv:
--------------------------------------------------------------------------------
1 | digraph BT32 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 20 -> 3;
9 | 20 ->17;
10 | 3 -> 32;
11 | 3 -> 9;
12 | 17 -> 21;
13 | 17 -> 8;
14 | 32 -> 12;
15 | 32 -> 5 [arrowhead="vee", arrowtail="vee", dir="both"];
16 | 9 -> 2 [side="left"];
17 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT320.gv:
--------------------------------------------------------------------------------
1 | digraph BT320 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 5 -> 2;
9 | 5 -> 3;
10 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT321.gv:
--------------------------------------------------------------------------------
1 | digraph BT321 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 3 -> 2;
9 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT322.gv:
--------------------------------------------------------------------------------
1 | digraph BT323 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 3 -> 2 [side="left"];
9 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT323.gv:
--------------------------------------------------------------------------------
1 | digraph BT323 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 2;
9 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT324.gv:
--------------------------------------------------------------------------------
1 | digraph BT324 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 2 -> 3;
9 | 2 -> 5;
10 | 3 -> 8;
11 | 3 -> 9;
12 | 5 -> 12;
13 | 5 -> 17;
14 | 8 -> 20;
15 | 8 -> 21;
16 | 9 -> 32 [side="left"];
17 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT33.gv:
--------------------------------------------------------------------------------
1 | digraph BT33 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 20 -> 3;
9 | 20 -> 21;
10 | 3 -> 32;
11 | 3 -> 9;
12 | 21 -> 17 [arrowhead="vee", arrowtail="vee", dir="both"];
13 | 21 -> 8;
14 | 32 -> 12;
15 | 32 -> 5;
16 | 9 -> 2 [side="left"];
17 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT34.gv:
--------------------------------------------------------------------------------
1 | digraph BT34 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 20 -> 32;
9 | 20 -> 21;
10 | 32 -> 3 [arrowhead="vee", arrowtail="vee", dir="both"];
11 | 32 -> 9;
12 | 21 -> 17;
13 | 21 -> 8;
14 | 3 -> 12;
15 | 3 -> 5;
16 | 9 -> 2 [side="left"];
17 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT35.gv:
--------------------------------------------------------------------------------
1 | digraph BT35 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 20 -> 32;
9 | 20 -> 21;
10 | 32 -> 12;
11 | 32 -> 9;
12 | 21 -> 17;
13 | 21 -> 8;
14 | 12 -> 3 [arrowhead="vee", arrowtail="vee", dir="both"];
15 | 12 -> 5;
16 | 9 -> 2 [side="left"];
17 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT36.gv:
--------------------------------------------------------------------------------
1 | digraph BT36 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 32 -> 20 [arrowhead="vee", arrowtail="vee", dir="both"];
9 | 32 -> 21;
10 | 20 -> 12;
11 | 20 -> 9;
12 | 21 -> 17;
13 | 21 -> 8;
14 | 12 -> 3;
15 | 12 -> 5;
16 | 9 -> 2 [side="left"];
17 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT37.gv:
--------------------------------------------------------------------------------
1 | digraph BT37 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 2 -> 20;
9 | 2 -> 21;
10 | 20 -> 12;
11 | 20 -> 9;
12 | 21 -> 17;
13 | 21 -> 8;
14 | 12 -> 3;
15 | 12 -> 5;
16 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT38.gv:
--------------------------------------------------------------------------------
1 | digraph BT38 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 21 -> 20;
9 | 21 -> 17;
10 | 20 -> 12;
11 | 20 -> 9;
12 | 17 -> 2;
13 | 17 -> 8;
14 | 12 -> 3;
15 | 12 -> 5;
16 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 2/Graphs/Q3/BT39.gv:
--------------------------------------------------------------------------------
1 | digraph BT39 {
2 | nodesep=1;
3 | ranksep=0.1;
4 | margin=0;
5 | graph [ordering="out"]
6 | node [shape=circle];
7 | edge [arrowsize=0.8, arrowhead=none, arrowtail=none];
8 | 5 -> 20;
9 | 5 -> 17;
10 | 20 -> 12;
11 | 20 -> 9;
12 | 17 -> 2;
13 | 17 -> 8;
14 | 12 -> 3 [side="left"];
15 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 3/Assignment 3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 3/Assignment 3.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 3/DecisionStumpTest.java:
--------------------------------------------------------------------------------
1 | public class DecisionStumpTest {
2 |
3 | public static void main(String[] args) {
4 |
5 | // Build a decision tree
6 | // feature 0 is gender (0: female 1:male)
7 | // feature 1 is age
8 | // class 0 is does not wear glasses
9 | // class 1 is wear glasses
10 | DecisionStump.nClasses = 2;
11 | DecisionStump.dim = 2;
12 |
13 | // is age < 45
14 | DecisionStump s1 = new DecisionStump(1, 45);
15 | DecisionStump s2 = new DecisionStump(); // leaf
16 | s2.setProb(1, 89); // wear glasses at 89%
17 |
18 | // is man?
19 | DecisionStump s3 = new DecisionStump(0, 0.5);
20 |
21 | DecisionStump s4 = new DecisionStump(); // leaf
22 | s4.setProb(0, 61); // does not wear glasses at 61%
23 |
24 | // is age < 24
25 | DecisionStump s5 = new DecisionStump(1, 24);
26 | DecisionStump s6 = new DecisionStump(); // leaf
27 | s6.setProb(0, 62); // does not wear glasses at 62%
28 | DecisionStump s7 = new DecisionStump(); // leaf
29 | s7.setProb(1, 53); // wear glasses at 53%
30 |
31 | s1.setSmallerBranch(s3);
32 | s1.setGreaterBranch(s2);
33 | s3.setSmallerBranch(s5);
34 | s3.setGreaterBranch(s4);
35 | s5.setSmallerBranch(s6);
36 | s5.setGreaterBranch(s7);
37 |
38 | double[] test1 = {1, 55};
39 | System.out.println("Man age 55 = " + s1.getDecision(test1));
40 | double[] test2 = {1, 35};
41 | System.out.println("Man age 35 = " + s1.getDecision(test2));
42 | double[] test3 = {0, 75};
43 | System.out.println("Woman age 75 = " + s1.getDecision(test3));
44 | double[] test4 = {0, 27};
45 | System.out.println("Woman age 27 = " + s1.getDecision(test4));
46 | double[] test5 = {1, 15};
47 | System.out.println("Woman age 15 = " + s1.getDecision(test5));
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/Assignments/Assignment 3/NodeReplaceException.java:
--------------------------------------------------------------------------------
1 | public class NodeReplaceException extends Exception {
2 |
3 | public NodeReplaceException(String message) {
4 | super(message);
5 | }
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/Assignments/Assignment 3/Readme.txt:
--------------------------------------------------------------------------------
1 | I have created DecisionTreeTest and a DecisionStumpTest classes to perform tests on each of the datatypes.
2 |
3 | DecisionTreeTest produces the output for answers B and C.
4 |
5 | DecisionTreeTest take the full path to a file on the system to perform the tests. The file must be of the same format as iris.data.txt, with the same number of columns of the same data type.
6 |
7 | I have added a method called getAvgExternalProbibality to DecisionTree which determines the avg max probability of all external decision stumps. This is used to calculate the statistics in part C.
--------------------------------------------------------------------------------
/Assignments/Assignment 4/1a1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/1a1.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/1b1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/1b1.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/1b2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/1b2.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/1b3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/1b3.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/1b4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/1b4.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/1b5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/1b5.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/1c1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/1c1.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/1c2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/1c2.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/1c3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/1c3.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/1c4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/1c4.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/1c5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/1c5.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/3a1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/3a1.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Assignment 4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Assignments/Assignment 4/Assignment 4.pdf
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Graphs/Q1/A/a1.gv:
--------------------------------------------------------------------------------
1 | digraph a1 {
2 | //Global graph settings
3 | graph[splines="false",ordering="out"];
4 | node [shape = record,height=.1,label="| "];
5 |
6 | //Root
7 | n0:f0:sw -> n1:f1:ne;
8 | n0 -> n2;
9 | n0:f1:se -> n3:f0:nw;
10 |
11 | //Left child of root
12 | n1:f0:sw -> n4:f1:ne;
13 | n1:f0:se -> n5:f1:nw;
14 | n1:f1:se -> n6:f0:nw;
15 |
16 | //center child of root
17 | n2:f0:sw -> n7:f1:ne;
18 | n2 -> n8;
19 | n2:f1:se -> n9:f0:nw;
20 |
21 | //Right child of root
22 | n3:f0:sw -> n10:f1:ne;
23 | n3:f0:se -> n11:f1:nw;
24 | n3:f1:se -> n12:f0:nw;
25 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Graphs/Q1/B/b1.gv:
--------------------------------------------------------------------------------
1 | digraph b1 {
2 | //Global graph settings
3 | graph[splines="false",ordering="out"];
4 | node [shape = record,height=.1,label="| "];
5 |
6 | //Special nodes
7 | n4[label="||"]
8 |
9 | //Root node
10 | n0:f0:sw -> n1:f1:ne;
11 | n0 -> n2;
12 | n0:f1:se -> n3:f0:nw;
13 |
14 | //Left child of root
15 | n1:f0:sw -> n4:f2:ne;
16 | n1:f0:se -> n5:f1:nw;
17 | n1:f1:se -> n6:f0:nw;
18 |
19 | //Center child of root
20 | n2:f0:sw -> n7:f1:ne;
21 | n2 -> n8;
22 | n2:f1:se -> n9:f0:nw;
23 |
24 | //Right child of root
25 | n3:f0:sw -> n10:f1:ne;
26 | n3:f0:se -> n11:f1:nw;
27 | n3:f1:se -> n12:f0:nw;
28 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Graphs/Q1/B/b2.gv:
--------------------------------------------------------------------------------
1 | digraph b2 {
2 | //Global graph settings
3 | graph[splines="false",ordering="out"];
4 | node [shape = record,height=.1,label="| "];
5 |
6 | //Special labels
7 | n1[label="||"];
8 | nIns[width=.4, label=""];
9 |
10 | //Root node
11 | n0:f0:sw -> n1:f2:ne;
12 | n0 -> n2;
13 | n0:f1:se -> n3:f0:nw;
14 |
15 | //Left child of root
16 | n1:f0:sw -> n4:f1:ne;
17 | n1:f0:se -> nIns:f0:n;
18 | n1:f1:se -> n5:f0:ne;
19 | n1:f2:se -> n6:f0:nw;
20 |
21 | //Center child of root
22 | n2:f0:sw -> n7:f1:ne;
23 | n2 -> n8;
24 | n2:f1:se -> n9:f0:nw;
25 |
26 | //Right child of root
27 | n3:f0:sw -> n10:f1:ne;
28 | n3:f0:se -> n11:f1:nw;
29 | n3:f1:se -> n12:f0:nw;
30 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Graphs/Q1/B/b3.gv:
--------------------------------------------------------------------------------
1 | digraph b3 {
2 | //Global graph settings
3 | graph[splines="false",ordering="out"];
4 | node [shape = record,height=.1,label="| "];
5 |
6 | //Special labels
7 | n1[label="||"];
8 | n4[label="||"];
9 | nIns[width=.4, label=""];
10 |
11 | //Root node
12 | n0:f0:sw -> n1:f2:ne;
13 | n0 -> n2;
14 | n0:f1:se -> n3:f0:nw;
15 |
16 | //Left child of root
17 | n1:f0:sw -> n4:f2:ne;
18 | n1:f0:se -> nIns:f0:n;
19 | n1:f1:se -> n5:f0:ne;
20 | n1:f2:se -> n6:f0:nw;
21 |
22 | //Center child of root
23 | n2:f0:sw -> n7:f1:ne;
24 | n2 -> n8;
25 | n2:f1:se -> n9:f0:nw;
26 |
27 | //Right child of root
28 | n3:f0:sw -> n10:f1:ne;
29 | n3:f0:se -> n11:f1:nw;
30 | n3:f1:se -> n12:f0:nw;
31 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Graphs/Q1/B/b4.gv:
--------------------------------------------------------------------------------
1 | digraph b4 {
2 | //Global graph settings
3 | graph[splines="false",ordering="out"];
4 | node [shape = record,height=.1,label="| "];
5 |
6 | //Special labels
7 | n0[label="||"];
8 | n2[label="",width=.4];
9 | n6[label=""width=.4];
10 | n7[label=""width=.4];
11 |
12 | //Root node
13 | n0:f0:sw -> n1:f1:ne;
14 | n0:f0:se -> n2:f0:n;
15 | n0:f1:se -> n3:f0:ne;
16 | n0:f2:se -> n4:f0:nw;
17 |
18 | //Left child of root
19 | n1:f0:sw -> n5:f1:ne;
20 | n1:f0:se -> n6:f0:n;
21 | n1:f1:se -> n7:f0:nw;
22 |
23 | //Center left child of root
24 | n2:f0:sw -> n8:f1:ne;
25 | n2:f0:se -> n9:f0:nw;
26 |
27 | //Center right child of root
28 | n3:f0:sw -> n10:f1:ne;
29 | n3:f1:sw -> n11:f0:nw;
30 | n3:f1:se -> n12:f0:nw;
31 |
32 | //Right child of root
33 | n4:f0:sw -> n13:f1:ne;
34 | n4:f1:sw -> n14:f0:nw;
35 | n4:f1:se -> n15:f0:nw;
36 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Graphs/Q1/B/b5.gv:
--------------------------------------------------------------------------------
1 | digraph b5 {
2 | //Global graph settings
3 | graph[splines="false",ordering="out"];
4 | node [shape = record,height=.1,label="| "];
5 |
6 | //Special labels
7 | n0[label="||"];
8 | n2[label="",width=.4];
9 | n5[label="||"];
10 | n6[label=""width=.4];
11 | n7[label=""width=.4];
12 |
13 | //Root node
14 | n0:f0:sw -> n1:f1:ne;
15 | n0:f0:se -> n2:f0:n;
16 | n0:f1:se -> n3:f0:ne;
17 | n0:f2:se -> n4:f0:nw;
18 |
19 | //Left child of root
20 | n1:f0:sw -> n5:f2:ne;
21 | n1:f0:se -> n6:f0:n;
22 | n1:f1:se -> n7:f0:nw;
23 |
24 | //Center left child of root
25 | n2:f0:sw -> n8:f1:ne;
26 | n2:f0:se -> n9:f0:nw;
27 |
28 | //Center right child of root
29 | n3:f0:sw -> n10:f1:ne;
30 | n3:f1:sw -> n11:f0:nw;
31 | n3:f1:se -> n12:f0:nw;
32 |
33 | //Right child of root
34 | n4:f0:sw -> n13:f1:ne;
35 | n4:f1:sw -> n14:f0:nw;
36 | n4:f1:se -> n15:f0:nw;
37 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Graphs/Q1/C/c1.gv:
--------------------------------------------------------------------------------
1 | digraph c1 {
2 | //Global graph settings
3 | graph[splines="false",ordering="out"];
4 | node [shape = record,height=.1,label="| "];
5 |
6 | //Special nodes
7 | n12[label="",width=.4];
8 |
9 | //Root
10 | n0:f0:sw -> n1:f1:ne;
11 | n0 -> n2;
12 | n0:f1:se -> n3:f0:nw;
13 |
14 | //Left child of root
15 | n1:f0:sw -> n4:f1:ne;
16 | n1:f0:se -> n5:f1:nw;
17 | n1:f1:se -> n6:f0:nw;
18 |
19 | //center child of root
20 | n2:f0:sw -> n7:f1:ne;
21 | n2 -> n8;
22 | n2:f1:se -> n9:f0:nw;
23 |
24 | //Right child of root
25 | n3:f0:sw -> n10:f1:ne;
26 | n3:f0:se -> n11:f1:nw;
27 | n3:f1:se -> n12:f0:nw;
28 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Graphs/Q1/C/c2.gv:
--------------------------------------------------------------------------------
1 | digraph c2 {
2 | //Global graph settings
3 | graph[splines="false",ordering="out"];
4 | node [shape = record,height=.1,label="| "];
5 |
6 | //Special nodes
7 | n11[label="",width=.4];
8 | n12[label="",width=.4];
9 |
10 | //Root
11 | n0:f0:sw -> n1:f1:ne;
12 | n0 -> n2;
13 | n0:f1:se -> n3:f0:nw;
14 |
15 | //Left child of root
16 | n1:f0:sw -> n4:f1:ne;
17 | n1:f0:se -> n5:f1:nw;
18 | n1:f1:se -> n6:f0:nw;
19 |
20 | //center child of root
21 | n2:f0:sw -> n7:f1:ne;
22 | n2 -> n8;
23 | n2:f1:se -> n9:f0:nw;
24 |
25 | //Right child of root
26 | n3:f0:sw -> n10:f1:ne;
27 | n3:f0:se -> n11:f0:n;
28 | n3:f1:se -> n12:f0:nw;
29 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Graphs/Q1/C/c3.gv:
--------------------------------------------------------------------------------
1 | digraph c3 {
2 | //Global graph settings
3 | graph[splines="false",ordering="out"];
4 | node [shape = record,height=.1,label="| "];
5 |
6 | //Special nodes
7 | n3[label="",width=.4];
8 |
9 | //Root
10 | n0:f0:sw -> n1:f1:ne;
11 | n0 -> n2;
12 | n0:f1:se -> n3:f0:nw;
13 |
14 | //Left child of root
15 | n1:f0:sw -> n4:f1:ne;
16 | n1:f0:se -> n5:f1:nw;
17 | n1:f1:se -> n6:f0:nw;
18 |
19 | //center child of root
20 | n2:f0:sw -> n7:f1:ne;
21 | n2 -> n8;
22 | n2:f1:se -> n9:f0:nw;
23 |
24 | //Right child of root
25 | n3:f0:sw -> n10:f1:ne;
26 | n3:f0:se -> n11:f0:nw;
27 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Graphs/Q1/C/c4.gv:
--------------------------------------------------------------------------------
1 | digraph c4 {
2 | //Global graph settings
3 | graph[splines="false",ordering="out"];
4 | node [shape = record,height=.1,label="| "];
5 |
6 | //Special nodes
7 | n3[label="",width=.4];
8 | n11[label="",width=.4];
9 |
10 | //Root
11 | n0:f0:sw -> n1:f1:ne;
12 | n0 -> n2;
13 | n0:f1:se -> n3:f0:nw;
14 |
15 | //Left child of root
16 | n1:f0:sw -> n4:f1:ne;
17 | n1:f0:se -> n5:f1:nw;
18 | n1:f1:se -> n6:f0:nw;
19 |
20 | //center child of root
21 | n2:f0:sw -> n7:f1:ne;
22 | n2 -> n8;
23 | n2:f1:se -> n9:f0:nw;
24 |
25 | //Right child of root
26 | n3:f0:sw -> n10:f1:ne;
27 | n3:f0:se -> n11:f0:nw;
28 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Graphs/Q1/C/c5.gv:
--------------------------------------------------------------------------------
1 | digraph c5 {
2 | //Global graph settings
3 | graph[splines="false",ordering="out"];
4 | node [shape = record,height=.1,label="| "];
5 |
6 | //Special nodes
7 | n3[label="",width=.4];
8 | n10[label="",width=.4];
9 | n11[label="",width=.4];
10 |
11 | //Root
12 | n0:f0:sw -> n1:f1:ne;
13 | n0 -> n2;
14 | n0:f1:se -> n3:f0:nw;
15 |
16 | //Left child of root
17 | n1:f0:sw -> n4:f1:ne;
18 | n1:f0:se -> n5:f1:nw;
19 | n1:f1:se -> n6:f0:nw;
20 |
21 | //center child of root
22 | n2:f0:sw -> n7:f1:ne;
23 | n2 -> n8;
24 | n2:f1:se -> n9:f0:nw;
25 |
26 | //Right child of root
27 | n3:f0:sw -> n10:f0:ne;
28 | n3:f0:se -> n11:f0:nw;
29 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 4/Graphs/Q3/A/a1.gv:
--------------------------------------------------------------------------------
1 | digraph a1 {
2 | node [shape = circle]
3 | S -> U;
4 | S -> P;
5 | U -> X;
6 | U -> V;
7 | P -> Q;
8 | X -> Y;
9 | V -> W;
10 | Y -> R;
11 | R -> T;
12 | }
--------------------------------------------------------------------------------
/Assignments/Assignment 5/BuildItineraryTest.java:
--------------------------------------------------------------------------------
1 | import java.util.ArrayList;
2 |
3 |
4 | public class BuildItineraryTest {
5 |
6 |
7 | public static BuildItinerary readFlightsIntoGraph(String flightFileName, boolean verbose) throws Exception{
8 |
9 | ReadFlights mine = new ReadFlights();
10 | ArrayList f = mine.read(flightFileName);
11 | if (verbose) {
12 | System.out.println("\n**** Flights Available ****");
13 | for (Flight aF : f) {
14 | System.out.println(aF);
15 | }
16 | System.out.println("**** End of Flights Available ****\n");
17 | }
18 |
19 | BuildItinerary buildItiner= new BuildItinerary(f);
20 | AdjacencyListGraph myGraph = buildItiner.getGraph();
21 |
22 | if (verbose) {
23 | System.out.println("**** Displaying Complete Graph Information ****");
24 | myGraph.print();
25 | System.out.println("**** End of Displaying Complete Graph Information **** \n");
26 | }
27 | return buildItiner;
28 |
29 | }
30 |
31 | public static void main(String[] args) throws Exception {
32 |
33 | //AdjacencyListGraph myGraph;
34 |
35 | boolean verbose=false;
36 | System.out.println("\n----- Starting Test for file flights1.txt (verbose="+verbose+")\n");
37 |
38 | BuildItinerary buildItiner= readFlightsIntoGraph("flights1.txt",verbose);
39 |
40 | ArrayList itin;
41 |
42 | itin=buildItiner.cheapestItinerary("YOW","YVR",new Time("8:10"), new Time("22:30"),verbose);
43 |
44 | itin=buildItiner.cheapestItinerary("YOW","YVR",new Time("10:00"), new Time("18:30"),verbose);
45 |
46 | itin=buildItiner.cheapestItinerary("YOW","YVR",new Time("10:00"), new Time("24:00"),verbose);
47 |
48 | itin=buildItiner.cheapestItinerary("YOW","YVR",new Time("13:30"), new Time("15:30"),verbose);
49 |
50 | itin=buildItiner.cheapestItinerary("YUL","YVR",new Time("12:00"), new Time("24:00"),verbose);
51 |
52 | System.out.println("\n----- Ending Test for file flight1.txt\n");
53 |
54 |
55 | verbose=false;
56 | System.out.println("\n----- Starting Test for file flights2.txt (verbose="+verbose+")\n");
57 |
58 | buildItiner= readFlightsIntoGraph("flights2.txt",verbose);
59 |
60 | itin=buildItiner.cheapestItinerary("YOW","YVR",new Time("8:10"), new Time("22:30"),verbose);
61 |
62 | itin=buildItiner.cheapestItinerary("YOW","YVR",new Time("10:00"), new Time("18:30"),verbose);
63 |
64 | itin=buildItiner.cheapestItinerary("YOW","YVR",new Time("10:00"), new Time("24:00"),verbose);
65 |
66 | itin=buildItiner.cheapestItinerary("YOW","YVR",new Time("13:30"), new Time("15:30"),verbose);
67 |
68 | itin=buildItiner.cheapestItinerary("YUL","YVR",new Time("12:00"), new Time("24:00"),verbose);
69 |
70 | System.out.println("\n----- Ending Test for file flight2.txt\n");
71 |
72 | //*************************** part 3 ***************************************************//
73 | System.out.println("\nNow tests for Part 3:");
74 |
75 | buildItiner= readFlightsIntoGraph("flights1.txt",false);
76 |
77 | verbose=false;
78 | buildItiner.whereMoneyCanGetMe("YOW", new Time("5:00"), 500, verbose);
79 | buildItiner.whereMoneyCanGetMe("YOW", new Time("5:00"), 1000, verbose);
80 |
81 |
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/Assignments/Assignment 5/Flight.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Store Flight Information
3 | */
4 | public class Flight implements Integral {
5 |
6 | String flightNumber;
7 | String airportDepart;
8 | String airportDestin;
9 | Time timeDepart;
10 | Time timeDestin;
11 | String cityDepart;
12 | String cityDestin;
13 | int costFlight;
14 |
15 | public Flight(String flightN, String airDep, String airDest, String cityDep,String citDest,
16 | Time timeDep, Time timeDest, int cost) {
17 | flightNumber=flightN;
18 | airportDepart=airDep;
19 | airportDestin=airDest;
20 | timeDepart=timeDep;
21 | timeDestin=timeDest;
22 | cityDepart=cityDep;
23 | cityDestin=citDest;
24 | costFlight=cost;
25 | }
26 |
27 | public String getflightNumber() {
28 | return flightNumber;
29 | }
30 |
31 | public String getAirportDepart() {
32 | return airportDepart;
33 | }
34 |
35 | public String getAirportDestin() {
36 | return airportDestin;
37 | }
38 |
39 | public Time getTimeDepart() {
40 | return timeDepart;
41 | }
42 |
43 | public Time getTimeDestin() {
44 | return timeDestin;
45 | }
46 |
47 | public String getCityDepart() {
48 | return cityDepart;
49 | }
50 |
51 | public String getityDestin() {
52 | return cityDestin;
53 | }
54 |
55 | public int getCost() {
56 | return costFlight;
57 | }
58 | public String toString() {
59 | return flightNumber+" "+ airportDepart+" "+cityDepart+ " " + timeDepart+
60 | " "+ airportDestin+" "+cityDestin+ " " + timeDestin+ " $"+costFlight;
61 | }
62 |
63 | public int toIntegral() {
64 | return costFlight;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/Assignments/Assignment 5/Integral.java:
--------------------------------------------------------------------------------
1 |
2 | public interface Integral {
3 | int toIntegral();
4 | }
5 |
--------------------------------------------------------------------------------
/Assignments/Assignment 5/Printout.txt:
--------------------------------------------------------------------------------
1 | ----- Starting Test for file flights1.txt (verbose=false)
2 |
3 |
4 | >>>Customer requested departure from YOW after 8:10 arriving at YVR before 22:30
5 | Official Itinerary: YOW 12:00 to YVR 18:31
6 | WS363 YOW Ottawa 12:00 YYZ Toronto 13:04 $200
7 | AC161 YYZ Toronto 16:15 YVR Vancouver 18:31 $600
8 | Total cost=800
9 |
10 | >>>Customer requested departure from YOW after 10:00 arriving at YVR before 18:30
11 | No itineraries available; please widen your search times.
12 |
13 | >>>Customer requested departure from YOW after 10:00 arriving at YVR before 24:00
14 | Official Itinerary: YOW 12:00 to YVR 23:47
15 | WS363 YOW Ottawa 12:00 YYZ Toronto 13:04 $200
16 | AC161 YYZ Toronto 16:15 YVR Vancouver 18:31 $600
17 | Total cost=800
18 |
19 | >>>Customer requested departure from YOW after 13:30 arriving at YVR before 15:30
20 | No itineraries available; please widen your search times.
21 |
22 | >>>Customer requested departure from YUL after 12:00 arriving at YVR before 24:00
23 | Official Itinerary: YUL 14:05 to YVR 23:47
24 | WJ217 YUL Montreal 19:15 YYC Calgary 21:59 $700
25 | WJ131 YYC Calgary 23:15 YVR Vancouver 23:47 $83
26 | Total cost=783
27 |
28 | ----- Ending Test for file flight1.txt
29 |
30 |
31 | ----- Starting Test for file flights2.txt (verbose=false)
32 |
33 |
34 | >>>Customer requested departure from YOW after 8:10 arriving at YVR before 22:30
35 | Official Itinerary: YOW 8:20 to YVR 22:19
36 | WS363 YOW Ottawa 12:00 YYZ Toronto 13:04 $200
37 | AC33 YYZ Toronto 20:05 YVR Vancouver 22:05 $200
38 | Total cost=400
39 |
40 | >>>Customer requested departure from YOW after 10:00 arriving at YVR before 18:30
41 | Official Itinerary: YOW 12:00 to YVR 18:15
42 | AC104 YOW Ottawa 13:20 YUL Montreal 14:05 $150
43 | AC_195 YUL Montreal 17:50 YVR Vancouver 18:15 $500
44 | Total cost=650
45 |
46 | >>>Customer requested departure from YOW after 10:00 arriving at YVR before 24:00
47 | Official Itinerary: YOW 12:00 to YVR 23:47
48 | WS363 YOW Ottawa 12:00 YYZ Toronto 13:04 $200
49 | AC145 YYZ Toronto 22:55 YYC Calgary 23:12 $51
50 | WJ131 YYC Calgary 23:15 YVR Vancouver 23:47 $83
51 | Total cost=334
52 |
53 | >>>Customer requested departure from YOW after 13:30 arriving at YVR before 15:30
54 | No itineraries available; please widen your search times.
55 |
56 | >>>Customer requested departure from YUL after 12:00 arriving at YVR before 24:00
57 | Official Itinerary: YUL 13:30 to YVR 23:47
58 | AC_183 YUL Montreal 13:30 YVR Vancouver 16:07 $478
59 | Total cost=478
60 |
61 | ----- Ending Test for file flight2.txt
62 |
63 |
64 | Now tests for Part 3:
65 | >>>> Here you will provide info on where to go under $500
66 | ----Itenerary----
67 | WS363 YOW Ottawa 12:00 YYZ Toronto 13:04 $200
68 | Total cost=200
69 |
70 | ----Itenerary----
71 | AC104 YOW Ottawa 13:20 YUL Montreal 14:05 $150
72 | Total cost=150
73 |
74 | ----Itenerary----
75 | AC455 YOW Ottawa 14:00 YYZ Toronto 15:07 $225
76 | Total cost=225
77 |
78 | >>>> Here you will provide info on where to go under $1000
79 | ----Itenerary----
80 | WS363 YOW Ottawa 12:00 YYZ Toronto 13:04 $200
81 | Total cost=200
82 |
83 | ----Itenerary----
84 | AC104 YOW Ottawa 13:20 YUL Montreal 14:05 $150
85 | Total cost=150
86 |
87 | ----Itenerary----
88 | WS363 YOW Ottawa 12:00 YYZ Toronto 13:04 $200
89 | AC161 YYZ Toronto 16:15 YVR Vancouver 18:31 $600
90 | Total cost=800
91 |
92 | ----Itenerary----
93 | AC104 YOW Ottawa 13:20 YUL Montreal 14:05 $150
94 | WJ217 YUL Montreal 19:15 YYC Calgary 21:59 $700
95 | Total cost=850
96 |
97 | ----Itenerary----
98 | AC455 YOW Ottawa 14:00 YYZ Toronto 15:07 $225
99 | Total cost=225
100 |
101 |
102 | Process finished with exit code 0
--------------------------------------------------------------------------------
/Assignments/Assignment 5/ReadFlights.java:
--------------------------------------------------------------------------------
1 | import java.io.BufferedReader;
2 | import java.io.FileReader;
3 | import java.io.IOException;
4 | import java.util.ArrayList;
5 | import java.util.StringTokenizer;
6 |
7 |
8 | public class ReadFlights {
9 |
10 | ArrayList read( String fileName) throws Exception, IOException {
11 | ArrayList a = new ArrayList();
12 | Flight fly;
13 | String line;
14 | BufferedReader flightFile =
15 | new BufferedReader( new FileReader(fileName));
16 | line = flightFile.readLine( ); // read header line
17 |
18 | while( ( line = flightFile.readLine( ) ) != null ) {
19 | StringTokenizer st = new StringTokenizer( line, ",");
20 | String aDp,cDp,tDp,aDs,cDs,tDs,fN, costS; int cost;
21 | aDp=st.nextToken(); cDp=st.nextToken(); aDs=st.nextToken(); cDs=st.nextToken();
22 | fN=st.nextToken(); tDp=st.nextToken(); tDs=st.nextToken(); costS=st.nextToken();
23 | Time timeDep=new Time(tDp);
24 | Time timeDes=new Time(tDs);
25 | cost=Integer.parseInt(costS);
26 | fly= new Flight(fN,aDp,aDs,cDp,cDs,timeDep,timeDes,cost);
27 | a.add(fly);
28 | }
29 | return a;
30 | }
31 |
32 | public static void main(String[] args) throws IOException, Exception {
33 | // TODO Auto-generated method stub
34 | ReadFlights mine = new ReadFlights();
35 | ArrayList f = mine.read("flights.txt");
36 | for (int i=0; i< f.size(); i++) {
37 | System.out.println(f.get(i));
38 | }
39 |
40 |
41 |
42 |
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/Assignments/Assignment 5/Readme.txt:
--------------------------------------------------------------------------------
1 | In part 3 I chose to print out the itineraries instead of just the final vertices so that more information would be available to the end user.
2 |
3 | Part 3 also uses the original question from the assignment, showing all flights under the cost, and not just the minimal ones. The prof stated this was okay and to leave it this way.
--------------------------------------------------------------------------------
/Assignments/Assignment 5/Time.java:
--------------------------------------------------------------------------------
1 |
2 | public class Time implements Comparable{
3 |
4 | int hour;
5 | int min;
6 |
7 | public Time(int hour, int min) {
8 | this.hour=hour;
9 | this.min=min;
10 | }
11 |
12 | public Time (String hhmm) throws IllegalArgumentException { // convert string in the form hh:mm
13 | int endofHour=hhmm.indexOf(":");
14 | if (endofHour==-1) throw new IllegalArgumentException("Invalid Time");
15 | this.hour=Integer.parseInt(hhmm.substring(0, endofHour));
16 | this.min=Integer.parseInt(hhmm.substring(hhmm.length()-2,hhmm.length()));
17 |
18 | }
19 |
20 | public int getHour() { return hour;}
21 | public int getMin() {return min;}
22 |
23 | public String toString() {
24 | String s;
25 | if (min<10) s=":0"+min;
26 | else s=":"+min;
27 | if (hour<10) s=" "+hour+s;
28 | else s=hour+s;
29 | return s;
30 | }
31 |
32 | @Override
33 | public int compareTo(Object o) {
34 | Time time = (Time) o;
35 | int compare = this.hour-time.hour;
36 | if (compare==0)
37 | compare = this.min-time.min;
38 | return compare;
39 | }
40 |
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/Assignments/Assignment 5/flights1.txt:
--------------------------------------------------------------------------------
1 | Origin Airport,Origin city,Destination Airport,Destination city,flight number,departure,arrival,price
YOW,Ottawa,YYZ,Toronto,WS363,12:00,13:04,200
2 | YOW,Ottawa,YYZ,Toronto,AC455,14:00,15:07,225
3 | YOW,Ottawa,YUL,Montreal,AC104,13:20,14:05,150
4 | YYZ,Toronto,YVR,Vancouver,WJ709,12:55,15:11,324
5 | YYZ,Toronto,YVR,Vancouver,AC161,16:15,18:31,600
6 | YUL,Montreal,YYC,Calgary,WJ217,19:15,21:59,700
7 | YYC,Calgary,YVR,Vancouver,WJ101,13:25,13:57,150
8 | YYC,Calgary,YVR,Vancouver,WJ131,23:15,23:47,83
--------------------------------------------------------------------------------
/Assignments/Assignment 5/flights2.txt:
--------------------------------------------------------------------------------
1 | Origin Airport,Origin city,Destination Airport,Destination city,flight number,departure,arrival,price
YOW,Ottawa,YYZ,Toronto,WS363,12:00,13:04,200
YOW,Ottawa,YYZ,Toronto,AC451,12:00,13:07,222
YOW,Ottawa,YYZ,Toronto,AC453,13:00,14:07,224
YOW,Ottawa,YYZ,Toronto,WS3465,13:40,14:59,225
YOW,Ottawa,YYZ,Toronto,AC455,14:00,15:07,225
YOW,Ottawa,YYZ,Toronto,JV503,14:45,15:55,226
YOW,Ottawa,YYZ,Toronto,AC457,15:00,16:07,227
YYZ,Toronto,YVR,Vancouver,AC101,12:10,14:26,300
YYZ,Toronto,YVR,Vancouver,WJ709,12:55,15:11,324
YYZ,Toronto,YVR,Vancouver,WJ713,14:00,16:16,450
YYZ,Toronto,YVR,Vancouver,AC109,14:20,16:36,550
YYZ,Toronto,YVR,Vancouver,AC161,16:15,18:31,600
YYZ,Toronto,YVR,Vancouver,AC137,18:00,20:00,700
YYZ,Toronto,YVR,Vancouver,WJ719,18:30,20:46,560
YYZ,Toronto,YVR,Vancouver,AC149,19:00,21:00,300
YYZ,Toronto,YVR,Vancouver,AC33,20:05,22:05,200
YUL,Montreal,YYC,Calgary,AC165,7:50,10:34,60
YUL,Montreal,YYC,Calgary,AC187,14:15,17:04,400
YUL,Montreal,YYC,Calgary,WJ217,19:15,21:59,700
YUL,Montreal,YYC,Calgary,AC155,19:45,22:29,680
YYC,Calgary,YVR,Vancouver,AC213,12:35,13:09,100
YYC,Calgary,YVR,Vancouver,WJ101,13:25,13:57,150
YYC,Calgary,YVR,Vancouver,AC215,13:35,14:09,250
YYC,Calgary,YVR,Vancouver,AC217,14:15,14:47,333
YYC,Calgary,YVR,Vancouver,WJ311,16:08,16:40,200
YYC,Calgary,YVR,Vancouver,WJ531,17:00,17:32,230
YYC,Calgary,YVR,Vancouver,AC223,17:15,17:49,202
YYC,Calgary,YVR,Vancouver,WJ553,18:20,18:52,222
YYC,Calgary,YVR,Vancouver,AC225,19:15,19:49,220
YYC,Calgary,YVR,Vancouver,AC229,21:45,22:19,200
YYC,Calgary,YVR,Vancouver,WJ557,22:00,22:32,100
YYC,Calgary,YVR,Vancouver,WJ131,23:15,23:47,83
YYZ,Toronto,YYC,Calgary,AC173,12:10,14:30,490
YYZ,Toronto,YYC,Calgary,AC121,14:05,16:25,399
YYZ,Toronto,YYC,Calgary,AC125,16:05,18:25,357
YYZ,Toronto,YYC,Calgary,WJ669,18:00,20:20,400
YYZ,Toronto,YYC,Calgary,AC133,18:10,20:30,250
YYZ,Toronto,YYC,Calgary,WJ671,19:45,22:05,345
YYZ,Toronto,YYC,Calgary,WJ673,20:40,23:00,79
YYZ,Toronto,YYC,Calgary,AC145,22:55,23:12,51
YOW,Ottawa,YUL,Montreal,AC7556,5:45,6:25,60
YOW,Ottawa,YUL,Montreal,AC8976,6:30,7:08,70
YOW,Ottawa,YUL,Montreal,AC8978,8:20,9:02,70
YOW,Ottawa,YUL,Montreal,AC8658,9:15,9:57,88
YOW,Ottawa,YUL,Montreal,AC104,13:20,14:05,150
YOW,Ottawa,YUL,Montreal,AC8980,15:40,16:22,300
YOW,Ottawa,YUL,Montreal,AC8986,18:20,19:00,256
YOW,Ottawa,YUL,Montreal,AC8988,19:20,19:58,66
YOW,Ottawa,YUL,Montreal,AC8660,20:15,20:57,40
YUL,Montreal,YVR,Vancouver,AC111,8:05,10:42,678
YUL,Montreal,YVR,Vancouver,AC_183,13:30,16:07,478
YUL,Montreal,YVR,Vancouver,AC_195,17:50,18:15,500
--------------------------------------------------------------------------------
/Assignments/resources/Readme.md:
--------------------------------------------------------------------------------
1 | # Resources
2 |
3 | 1. binarytree.gv - A simple dot script to generate clean horizontal trees usage: `[sudo] dot MyTree.gv | gvpr -c -f binarytree.gv | neato -n -T pdf -o out.pdf`
4 |
5 | sudo dot ~/Documents/Programming/School/CSI2110/Assignments/Assignment\ 2/Graphs/Q2/B/BT2B.gv | gvpr -c -f /Users/mattlanglois/Documents/Programming/School/CSI2110/Assignments/resources/binarytree.gv | neato -n -T pdf -o ~/Downloads/2B.pdf
6 |
--------------------------------------------------------------------------------
/Assignments/resources/binarytree.gv:
--------------------------------------------------------------------------------
1 | // http://stackoverflow.com/questions/10902745/enforcing-horizontal-node-ordering-in-a-dot-tree
2 |
3 | BEGIN {
4 | double tw[node_t]; // width of tree rooted at node
5 | double nw[node_t]; // width of node
6 | double xoff[node_t]; // x offset of root from left side of its tree
7 | double sp = 36; // extra space between left and right subtrees
8 | double wd, w, w1, w2;
9 | double x, y, z;
10 | edge_t e1, e2;
11 | node_t n;
12 | }
13 | BEG_G {
14 | $.bb = "";
15 | $tvtype=TV_postfwd; // visit root after all children visited
16 | }
17 | N {
18 | sscanf ($.width, "%f", &w);
19 | w *= 72; // convert inches to points
20 | nw[$] = w;
21 | if ($.outdegree == 0) {
22 | tw[$] = w;
23 | xoff[$] = w/2.0;
24 | }
25 | else if ($.outdegree == 1) {
26 | e1 = fstout($);
27 | w1 = tw[e1.head];
28 | tw[$] = w1 + (sp+w)/2.0;
29 | if (e1.side == "left")
30 | xoff[$] = tw[$] - w/2.0;
31 | else
32 | xoff[$] = w/2.0;
33 | }
34 | else {
35 | e1 = fstout($);
36 | w1 = tw[e1.head];
37 | e2 = nxtout(e1);
38 | w2 = tw[e2.head];
39 | wd = w1 + w2 + sp;
40 | if (w > wd)
41 | wd = w;
42 | tw[$] = wd;
43 | xoff[$] = w1 + sp/2.0;
44 | }
45 | }
46 | BEG_G {
47 | $tvtype=TV_fwd; // visit root first, then children
48 | }
49 | N {
50 | if ($.indegree == 0) {
51 | sscanf ($.pos, "%f,%f", &x, &y);
52 | $.pos = sprintf("0,%f", y);
53 | }
54 | if ($.outdegree == 0) return;
55 | sscanf ($.pos, "%f,%f", &x, &y);
56 | wd = tw[$];
57 | e1 = fstout($);
58 | n = e1.head;
59 | sscanf (n.pos, "%f,%f", &z, &y);
60 | if ($.outdegree == 1) {
61 | if (e1.side == "left")
62 | n.pos = sprintf("%f,%f", x - tw[n] - sp/2.0 + xoff[n], y);
63 | else
64 | n.pos = sprintf("%f,%f", x + sp/2.0 + xoff[n], y);
65 | }
66 | else {
67 | n.pos = sprintf("%f,%f", x - tw[n] - sp/2.0 + xoff[n], y);
68 | e2 = nxtout(e1);
69 | n = e2.head;
70 | sscanf (n.pos, "%f,%f", &z, &y);
71 | n.pos = sprintf("%f,%f", x + sp/2.0 + xoff[n], y);
72 | }
73 | }
--------------------------------------------------------------------------------
/Labs/Lab 0/GNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Node of a singly linked list, which stores references to its
3 | * element and to the next node in the list.
4 | *
5 | * @author Natasha Gelfand
6 | * @author Roberto Tamassia
7 | * @author Michael Goodrich
8 | */
9 | //begin#fragment Node
10 | public class GNode {
11 | // Instance variables:
12 | private E element;
13 | private GNode next;
14 |
15 | /**
16 | * Creates a node with null references to its element and next node.
17 | */
18 | public GNode() {
19 | this(null, null);
20 | }
21 |
22 | /**
23 | * Creates a node with the given element and next node.
24 | */
25 | public GNode(E e, GNode n) {
26 | element = e;
27 | next = n;
28 | }
29 |
30 | // Accessor methods:
31 | public E getElement() {
32 | return element;
33 | }
34 |
35 | public GNode getNext() {
36 | return next;
37 | }
38 |
39 | // Modifier methods:
40 | public void setElement(E newElem) {
41 | element = newElem;
42 | }
43 |
44 | public void setNext(GNode newNext) {
45 | next = newNext;
46 | }
47 | }
48 | //end#fragment Node
49 |
--------------------------------------------------------------------------------
/Labs/Lab 0/LinkList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Builds a singly linked list of size 5 and prints it to the console.
3 | *
4 | * @author Jochen Lang
5 | */
6 |
7 | class LinkList {
8 | GNode llist;
9 |
10 | LinkList(int sz) {
11 | if (sz <= 0) {
12 | llist = null;
13 | } else {
14 | // start with list of size 1
15 | llist = new GNode("0", null);
16 | GNode current = llist; // temp GNode for loop
17 | // add further nodes
18 | for (int i = 1; i < sz; ++i) {
19 | // create GNode and attach it to the list
20 | GNode node2Add = new GNode(Integer.toString(i), null);
21 | current.setNext(node2Add); // add first GNode
22 | current = node2Add;
23 | }
24 | }
25 | }
26 |
27 | /**
28 | * Print all the elements of the list assuming that they are Strings
29 | */
30 | public void print() {
31 | /* Print the list */
32 | GNode current = llist; // point to the first GNode
33 | while (current != null) {
34 | System.out.print(current.getElement() + " ");
35 | current = current.getNext(); // move to the next
36 | }
37 | System.out.println();
38 | }
39 |
40 | public void deleteFirst() {
41 | if (llist != null) {
42 | llist = llist.getNext();
43 | }
44 | }
45 |
46 | public void deleteLast() {
47 | if (llist == null) return; // no GNode
48 | GNode prev = llist;
49 | GNode current = prev.getNext();
50 | if (current == null) { // only 1 GNode
51 | llist = null;
52 | return;
53 | }
54 | while (current.getNext() != null) { // more than 1 GNode
55 | prev = current;
56 | current = current.getNext();
57 | }
58 | prev.setNext(null);
59 | }
60 |
61 | // create and display a linked list
62 | public static void main(String[] args) {
63 | /* Create the list */
64 | LinkList llist = new LinkList(5);
65 | /* Print the list */
66 | llist.print();
67 | /* delete first and print */
68 | llist.deleteFirst();
69 | llist.print();
70 | /* delete last and print 5 times */
71 | for (int i = 0; i < 5; ++i) {
72 | llist.deleteLast();
73 | llist.print();
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Labs/Lab 0/me/matt/DoublyLinkList.java:
--------------------------------------------------------------------------------
1 | package me.matt;
2 |
3 | /**
4 | * Builds a singly linked list of size 5 and prints it to the console.
5 | *
6 | * @author Jochen Lang
7 | */
8 |
9 | class DoublyLinkList {
10 | Node llist;
11 |
12 | DoublyLinkList(int sz) {
13 | if (sz <= 0) {
14 | llist = null;
15 | } else {
16 | // start with list of size 1
17 | llist = new Node("0", null, null);
18 | Node current = llist; // temp Node for loop
19 | // add further nodes
20 | for (int i = 1; i < sz; ++i) {
21 | // create Node and attach it to the list
22 | Node node2Add = new Node(Integer.toString(i), null, null);
23 | current.setNext(node2Add); // add first Node
24 | current = node2Add;
25 | }
26 | }
27 | }
28 |
29 | /**
30 | * Print all the elements of the list assuming that they are Strings
31 | */
32 | public void print() {
33 | /* Print the list */
34 | Node current = llist; // point to the first Node
35 | while (current != null) {
36 | System.out.print(current.getElement() + " ");
37 | current = current.getNext(); // move to the next
38 | }
39 | System.out.println();
40 | }
41 |
42 | public void deleteFirst() {
43 | if (llist != null) {
44 | llist = llist.getNext();
45 | }
46 | }
47 |
48 | public void deleteLast() {
49 | if (llist == null) return; // no Node
50 | Node prev = llist;
51 | Node current = prev.getNext();
52 | if (current == null) { // only 1 Node
53 | llist = null;
54 | return;
55 | }
56 | while (current.getNext() != null) { // more than 1 Node
57 | prev = current;
58 | current = current.getNext();
59 | }
60 | prev.setNext(null);
61 | }
62 |
63 | // create and display a linked list
64 | public static void main(String[] args) {
65 | /* Create the list */
66 | DoublyLinkList llist = new DoublyLinkList(5);
67 | /* Print the list */
68 | llist.print();
69 | /* delete first and print */
70 | llist.deleteFirst();
71 | llist.print();
72 | /* delete last and print 5 times */
73 | for (int i = 0; i < 5; ++i) {
74 | llist.deleteLast();
75 | llist.print();
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/Labs/Lab 0/me/matt/Node.java:
--------------------------------------------------------------------------------
1 | package me.matt;
2 | /**
3 | * Node of a singly linked list, which stores references to its
4 | * element and to the next node in the list.
5 | *
6 | * @author Natasha Gelfand
7 | * @author Roberto Tamassia
8 | * @author Michael Goodrich
9 | */
10 | //begin#fragment Node
11 | public class Node {
12 | // Instance variables:
13 | private E element;
14 | private Node prev;
15 | private Node next;
16 |
17 | /**
18 | * Creates a node with null references to its element and next node.
19 | */
20 | public Node() {
21 | this(null, null, null);
22 | }
23 |
24 | /**
25 | * Creates a node with the given element and next node.
26 | */
27 | public Node(E e, Node p, Node n) {
28 | element = e;
29 | prev = p;
30 | next = n;
31 | }
32 |
33 |
34 |
35 | // Accessor methods:
36 | public E getElement() {
37 | return element;
38 | }
39 |
40 | public Node getNext() {
41 | return next;
42 | }
43 |
44 | // Modifier methods:
45 | public void setElement(E newElem) {
46 | element = newElem;
47 | }
48 |
49 | public void setNext(Node newNext) {
50 | next = newNext;
51 | }
52 | }
53 | //end#fragment Node
54 |
--------------------------------------------------------------------------------
/Labs/Lab 1/Unique1.java:
--------------------------------------------------------------------------------
1 | // CSI2110 Fall 2015 Laboratory 1.5: Algorithm Runtimes
2 | // ==========================================================================
3 | // (C)opyright:
4 | //
5 | // Lachlan Plant
6 | // SITE, University of Ottawa
7 | // 800 King Edward Ave.
8 | // Ottawa, On., K1N 6N5
9 | // Canada.
10 | // http://www.site.uottawa.ca
11 | //
12 | // Creator: lplant (Lachlan Plant)
13 | // Email: lplan053@uottawa.ca
14 | // ==========================================================================
15 | // $Log: Unique1.java,v $
16 | // Revision 1.0 2015/09/14 01:20:40 lplant
17 | // ==========================================================================
18 |
19 | public class Unique1{
20 |
21 | public static boolean unique1(int[] input){
22 | for(int i = 0; i < input.length-1; i++){
23 | for(int j = i+1; j < input.length; j++){
24 | if(input[i] == input[j])
25 | return false;
26 | }
27 | }
28 | return true;
29 | }
30 |
31 | }
--------------------------------------------------------------------------------
/Labs/Lab 1/Unique2.java:
--------------------------------------------------------------------------------
1 | // CSI2110 Fall 2015 Laboratory 1.5: Algorithm Runtimes
2 | // ==========================================================================
3 | // (C)opyright:
4 | //
5 | // Lachlan Plant
6 | // SITE, University of Ottawa
7 | // 800 King Edward Ave.
8 | // Ottawa, On., K1N 6N5
9 | // Canada.
10 | // http://www.site.uottawa.ca
11 | //
12 | // Creator: lplant (Lachlan Plant)
13 | // Email: lplan053@uottawa.ca
14 | // ==========================================================================
15 | // $Log: Unique2.java,v $
16 | // Revision 1.0 2015/09/14 01:20:40 lplant
17 | // ==========================================================================
18 | import java.util.*;
19 | public class Unique2{
20 |
21 | public static boolean unique2(int[] input){
22 | Arrays.sort(input);
23 | for(int i = 0; i < input.length-1; i++){
24 | if(input[i] == input[i+1])
25 | return false;
26 | }
27 | return true;
28 | }
29 |
30 |
31 | }
--------------------------------------------------------------------------------
/Labs/Lab 10/SEE LAB 5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fletchto99/CSI2110/5448a41b425d81ad2cce860599a2936301e22e90/Labs/Lab 10/SEE LAB 5
--------------------------------------------------------------------------------
/Labs/Lab 2/balance/ArrayStack.java:
--------------------------------------------------------------------------------
1 | package balance;
2 |
3 | public class ArrayStack implements Stack{
4 |
5 | public static final int CAPACITY = 1000; //# default capacity of the stack
6 | private int capacity; // maximum capacity of the stack.
7 | private Object S[]; // S holds the elements of the stack
8 | private int top = -1; // the top element of the stack.
9 |
10 | public ArrayStack() { //# Initialize the stack with default capacity
11 | this(CAPACITY);
12 | }
13 |
14 | public ArrayStack(int cap) { //# Initialize the stack with given capacity
15 | capacity = cap;
16 | S = new Object[capacity];
17 | }
18 |
19 | public int size() { //# Return the current stack size
20 | return (top + 1);
21 | }
22 |
23 | public boolean isEmpty() { //# Return true iff the stack is empty
24 | return (top < 0);
25 | }
26 |
27 | public void push(Object obj) throws StackFullException { //# Push a new object on the stack
28 | if (size() == capacity)
29 | throw new StackFullException("Stack overflow.");
30 | S[++top] = obj;
31 | }
32 |
33 | public Object top() throws StackEmptyException { //# Return the top stack element
34 | if (isEmpty())
35 | throw new StackEmptyException("Stack is empty.");
36 | return S[top];
37 | }
38 |
39 | public Object pop() throws StackEmptyException { //# Pop off the stack element
40 | Object elem;
41 | if (isEmpty())
42 | throw new StackEmptyException("Stack is Empty.");
43 | elem = S[top];
44 | S[top--] = null; //# Dereference S[top] and decrement top
45 | return elem;
46 | }
47 | }
--------------------------------------------------------------------------------
/Labs/Lab 2/balance/Stack.java:
--------------------------------------------------------------------------------
1 | package balance;
2 |
3 | public interface Stack {
4 |
5 | // Return the number of elements.
6 | public abstract int size();
7 |
8 | // Tests if the stack is empty.
9 | public abstract boolean isEmpty();
10 |
11 | // Inspect the top element, without removing it or otherwise modifying the stack.
12 | public abstract Object top() throws StackEmptyException;
13 |
14 | // Insert an element at the top.
15 | public abstract void push(Object element) throws StackFullException;
16 |
17 | // Remove the top element.
18 | public abstract Object pop() throws StackEmptyException;
19 |
20 | }
--------------------------------------------------------------------------------
/Labs/Lab 2/balance/StackEmptyException.java:
--------------------------------------------------------------------------------
1 | package balance;
2 |
3 | public class StackEmptyException extends RuntimeException {
4 | public StackEmptyException(String err) {
5 | super(err);
6 | }
7 | }
--------------------------------------------------------------------------------
/Labs/Lab 2/balance/StackFullException.java:
--------------------------------------------------------------------------------
1 | package balance;
2 |
3 | public class StackFullException extends RuntimeException {
4 | public StackFullException(String err) {
5 | super(err);
6 | }
7 | }
--------------------------------------------------------------------------------
/Labs/Lab 2/balance/bracketsBalance.java:
--------------------------------------------------------------------------------
1 | package balance;/* CSI2114 Lab 3 - lab3.java
2 | *
3 | * Class to check balanced brackets in math expressions
4 | *
5 | * Usage: java bracketsBalance
6 | *
7 | * by Jeff Souza
8 | *
9 | */
10 |
11 | class bracketsBalance {
12 |
13 | private boolean bBalance(String exp) {
14 | Stack sq = new ArrayStack();
15 | Stack rd = new ArrayStack();
16 | Stack o = new ArrayStack();
17 | for (char c : exp.toCharArray()) {
18 | if (c == '[') {
19 | sq.push('[');
20 | } else if (c == ']') {
21 | sq.pop();
22 | } else if (c == '(') {
23 | rd.push('(');
24 | } else if (c == ')') {
25 | rd.pop();
26 | } else if (c == '{') {
27 | o.push('(');
28 | } else if (c == '}') {
29 | o.pop();
30 | }
31 | }
32 | return rd.isEmpty() && sq.isEmpty() && o.isEmpty();
33 |
34 | }
35 |
36 | public static void main(String[] args) {
37 |
38 | bracketsBalance b = new bracketsBalance();
39 | boolean result = b.bBalance("{{(})}");
40 |
41 | if (result) System.out.println("The expression is balanced.");
42 | else System.out.println("The expression is NOT balanced.");
43 | }
44 | }
--------------------------------------------------------------------------------
/Labs/Lab 2/dLinkList/DLinkedList.java:
--------------------------------------------------------------------------------
1 | /* CSI2114 Lab 2 - DLinkedList.java
2 | *
3 | * Class doubly linked list
4 | *
5 | * by Jeff Souza
6 | *
7 | */
8 |
9 | package dLinkList;
10 |
11 | class DLinkedList {
12 |
13 | ListNode firstNode;
14 | ListNode lastNode;
15 |
16 | // Appends a node to the end of the list
17 | void AppendNode(ListNode nNode) {
18 | InsertNode(nNode, lastNode);
19 | }
20 |
21 | // Inserts a node into the list after pAfter
22 | void InsertNode(ListNode nNode, ListNode pAfter) {
23 | nNode.next = pAfter.next;
24 | nNode.previous = pAfter;
25 | nNode.next.previous = nNode;
26 | pAfter.next = nNode;
27 | }
28 |
29 | // Removes the specified node from the list
30 | void RemoveNode(ListNode nNode) {
31 | nNode.previous.next = nNode.next;
32 | nNode.next.previous = nNode.previous;
33 | }
34 |
35 | // print the content of the list
36 | void print() {
37 | ListNode nNode = null;
38 | System.out.print("Current list: ");
39 | for (nNode = firstNode; nNode != null; nNode = nNode.next) {
40 | System.out.print(nNode.data + " ");
41 | }
42 | System.out.println("");
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/Labs/Lab 2/dLinkList/ListNode.java:
--------------------------------------------------------------------------------
1 | package dLinkList;/* CSI2114 Lab 2 - ListNode.java
2 | *
3 | * Class node of a doubly linked list
4 | *
5 | * by Jeff Souza
6 | *
7 | */
8 |
9 | class ListNode {
10 | int data;
11 | ListNode next;
12 | ListNode previous;
13 | }
14 |
--------------------------------------------------------------------------------
/Labs/Lab 2/dLinkList/TestDLinkedList.java:
--------------------------------------------------------------------------------
1 | package dLinkList;/* CSI2114 Lab 2 - TestDLinkedList.java
2 | *
3 | * Class to test doubly linked list
4 | *
5 | * by Jeff Souza
6 | *
7 | */
8 |
9 | class TestDLinkedList {
10 |
11 | public static void main(String[] args) {
12 |
13 | ListNode nNode = new ListNode();
14 | nNode.data = 1;
15 | DLinkedList list = new DLinkedList();
16 | list.firstNode = nNode;
17 | list.lastNode = nNode;
18 |
19 | // add items to linked list
20 | for (int i = 2; i < 11; i++) {
21 | nNode = new ListNode();
22 | nNode.data = i;
23 | list.AppendNode(nNode);
24 | }
25 |
26 | System.out.println();
27 |
28 | // print the content of the list
29 | list.print();
30 |
31 | System.out.println("items removed.");
32 |
33 | // remove items from linked list
34 | list.RemoveNode(list.firstNode);
35 | list.RemoveNode(list.firstNode);
36 | list.RemoveNode(list.lastNode);
37 |
38 | // print the content of the list
39 | list.print();
40 | }
41 | }
--------------------------------------------------------------------------------
/Labs/Lab 2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Lab 2
6 |
7 |
8 |
Lab 2
9 |
10 | 1) Stacks. Array and linked list implementation of stacks.
11 |
12 |
13 |
14 | -
15 | Download the archive Lab2.zip and extract subdirectory stack
16 | with the stack implementation contained in the following files
17 |
18 | - Stack.java
19 | - Node.java
20 | - NodeStack.java
21 | - ArrayStack.java
22 | - StackEmptyException.java
23 | - FullStackException.java
24 |
25 |
26 | -
27 | The archive also contains the files tryStack1.java
28 | and tryStack2.java
29 |
30 | - Compile tryStack1 and run it
31 | - Compile tryStack2 and run it
32 |
33 |
34 |
35 |
36 | 2) Doubly Linked Lists in Java
37 |
38 |
39 | -
40 | Extract the subdirectory dLinkList from the archive Lab2.zip
41 | with the implementation of the doubly-linked list contained in the following files.
42 |
43 | - ListNode.java
44 | - DLinkedList.java
45 |
46 |
47 |
48 |
49 | - In DLinkedList.java implement the following methods:
50 |
51 | - InsertNode(ListNode nNode, ListNode pAfter)
52 |
53 | - inserts the node nNode after node pAfter in the
54 | current list
55 |
56 |
57 | - RemoveNode(ListNode nNode)
58 |
59 | - removes node nNode from current list
60 |
61 |
62 |
63 |
64 | - Compile TestDLinkedList.java and run it
65 |
66 |
67 | 3) Checking Balanced Brackets in Expressions with Stacks
68 |
69 |
70 | -
71 | Extract the subdirectory balance from the archive
72 | Lab2.zip with the implementation of the stack ADT with an
73 | array list contained in the following files:
74 |
75 | - Stack.java
76 | - ArrayStack.java
77 | - StackEmptyException.java
78 | - StackFullException.java
79 |
80 |
81 |
82 |
83 | -
84 | The archive also contains the file bracketsBalance.java in which you should implement the
85 | following method:
86 |
87 | - boolean bBalance (String exp)
88 |
89 | - that evaluates exp for balanced brackets and returns true
90 | (if balanced) and false otherwise
91 | - use the stack implementation in ArrayStack.java.
92 |
93 |
94 |
95 |
96 | - Compile bracketsBalance.java and run it with different expressions
97 |
98 |
99 |
100 |
101 |
102 |