From bb7dfe733e311f7acd8ce376d78978cab4f72949 Mon Sep 17 00:00:00 2001 From: bkpham <60329930+bkpham@users.noreply.github.com> Date: Sun, 23 Feb 2020 15:51:13 -0800 Subject: [PATCH 1/5] Create 3-CHECKPOINT --- Module4_Labs/Lab3_File_System/Cards/3-CHECKPOINT | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Module4_Labs/Lab3_File_System/Cards/3-CHECKPOINT diff --git a/Module4_Labs/Lab3_File_System/Cards/3-CHECKPOINT b/Module4_Labs/Lab3_File_System/Cards/3-CHECKPOINT new file mode 100644 index 00000000..108c6fb6 --- /dev/null +++ b/Module4_Labs/Lab3_File_System/Cards/3-CHECKPOINT @@ -0,0 +1,3 @@ +Name: Lab 4.3 Grading +Instruction: Submit your code to have it graded +Type: Autograder From 5fe706870bc9c8fffafe217a6150e4a7635a6f68 Mon Sep 17 00:00:00 2001 From: bkpham <60329930+bkpham@users.noreply.github.com> Date: Sun, 23 Feb 2020 16:06:12 -0800 Subject: [PATCH 2/5] Create 5-CHECKPOINT --- Module4_Labs/Lab2_Doubly_Linked_List/Cards/5-CHECKPOINT | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Module4_Labs/Lab2_Doubly_Linked_List/Cards/5-CHECKPOINT diff --git a/Module4_Labs/Lab2_Doubly_Linked_List/Cards/5-CHECKPOINT b/Module4_Labs/Lab2_Doubly_Linked_List/Cards/5-CHECKPOINT new file mode 100644 index 00000000..26465141 --- /dev/null +++ b/Module4_Labs/Lab2_Doubly_Linked_List/Cards/5-CHECKPOINT @@ -0,0 +1,3 @@ +Name: Insertion in list excercise grading +Instruction: Submit your code to be graded +Type: Autograder From 9761a3d5caf250e450c2b9fcfd77b77ddf9a7cd1 Mon Sep 17 00:00:00 2001 From: bkpham <60329930+bkpham@users.noreply.github.com> Date: Wed, 26 Feb 2020 17:47:55 -0800 Subject: [PATCH 3/5] Create checkpoint1_ans.py --- .../Checkpoint/checkpoint1_ans.py | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 Module4_Labs/Lab7_Zoologist/Student-Starter/Checkpoint/checkpoint1_ans.py diff --git a/Module4_Labs/Lab7_Zoologist/Student-Starter/Checkpoint/checkpoint1_ans.py b/Module4_Labs/Lab7_Zoologist/Student-Starter/Checkpoint/checkpoint1_ans.py new file mode 100644 index 00000000..80496fcc --- /dev/null +++ b/Module4_Labs/Lab7_Zoologist/Student-Starter/Checkpoint/checkpoint1_ans.py @@ -0,0 +1,106 @@ +from math import log +from math import sqrt +import csv +def assignRankings(equations): + # rank values descending order + rankings = [] + while (not max(equations) == -1): + nextValue = max(equations) + index = equations.index(nextValue) # find index + rankings.append(index) + equations[index] = -1 + # get ascending order + rankings.reverse() + return rankings +def bubbleSort(arr): + n = len(arr) + print(arr) + # Traverse through all array elements + for i in range(n): + # Last i elements are already in place + for j in range(0, n-i-1): + # traverse the array from 0 to n-i-1 + # Swap if the element found is greater + # than the next element + if (arr[j] > arr[j+1]): + arr[j], arr[j+1] = arr[j+1], arr[j] + print(arr) +# Function to do insertion sort +def insertionSort(arr): + # Traverse through 1 to len(arr) + for i in range(1, len(arr)): + key = arr[i] + # Move elements of arr[0..i-1], that are + # greater than key, to one position ahead + # of their current position + j = i-1 + while j >= 0 and key < arr[j] : + arr[j + 1] = arr[j] + j -= 1 + arr[j + 1] = key + print(arr) +def selectionSort(arr): + # Traverse through all array elements + for i in range(len(arr)): + # Find the minimum element in remaining + # unsorted array + min_idx = i + for j in range(i+1, len(arr)): + if arr[min_idx] > arr[j]: + min_idx = j + # Swap the found minimum element with + # the first element + arr[i], arr[min_idx] = arr[min_idx], arr[i] + print(arr) +def readFileintoDict(): + filename= “Animals.txt” + with open(filename, ‘r’) as file: + result = {} + index = 0 + for line in file.read().split(“\n”): + noTabs = line.split(“\t”) + lastElement = noTabs[len(noTabs) - 1] + result[index] = lastElement + index += 1 + return result +def main(): + n = 1 + equations = [ + n**2, + 20*n**2+5*n+7, + n+log(n)+7, + 3**n, + log(n)/(n**2), + (n+1)/(sqrt(1+n**2)), + (n**n)/(sqrt(log(n**4))+10), + n*log(n**2), + 6**n, + sqrt(log(n)), + n**n, + n**3*log(n)+100, + sqrt(n**3), + n**3, + (n+1)/(sqrt(1+n**2)) + ] + animals = readFileintoDict() # animals = {index : animalName} + ranks = assignRankings(equations.copy()) # ranks = {index : rank} + for i in range(len(ranks)): + print(animals[ranks[i]]) + invalidInput=True + while (invalidInput): + print(“Please chose a sorting method:“) + print(“1.(Bubble) Sort”) + print(“2.(Insertion) Sort”) + print(“3.(Selection) Sort”) + x=input(“”) + if(x==“1”or x==“bubble”): + bubbleSort(ranks.copy()) + invalidInput=False + elif(x==“2”or x==“insertion”): + insertionSort(ranks.copy()) + invalidInput=False + elif(x==“3”or x==“selection”): + selectionSort(ranks.copy()) + invalidInput=False + else: + print(“Not a valid input, try again.“) From 7ac36bebe3906ad1a5168cdb3682fd6bcd138801 Mon Sep 17 00:00:00 2001 From: bkpham <60329930+bkpham@users.noreply.github.com> Date: Wed, 26 Feb 2020 17:51:17 -0800 Subject: [PATCH 4/5] Create test_case_1.py --- .../Lab7_Zoologist/Student-Starter/Overall/test_case_1.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 Module4_Labs/Lab7_Zoologist/Student-Starter/Overall/test_case_1.py diff --git a/Module4_Labs/Lab7_Zoologist/Student-Starter/Overall/test_case_1.py b/Module4_Labs/Lab7_Zoologist/Student-Starter/Overall/test_case_1.py new file mode 100644 index 00000000..86de0c93 --- /dev/null +++ b/Module4_Labs/Lab7_Zoologist/Student-Starter/Overall/test_case_1.py @@ -0,0 +1 @@ +do stuff From 10b779815e29cbf8f463897edc22249de68b8c7b Mon Sep 17 00:00:00 2001 From: bkpham <60329930+bkpham@users.noreply.github.com> Date: Sun, 1 Mar 2020 16:00:24 -0800 Subject: [PATCH 5/5] Create introToGraphs.md --- Module4_Labs/concepts/introToGraphs.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Module4_Labs/concepts/introToGraphs.md diff --git a/Module4_Labs/concepts/introToGraphs.md b/Module4_Labs/concepts/introToGraphs.md new file mode 100644 index 00000000..5a2a71e2 --- /dev/null +++ b/Module4_Labs/concepts/introToGraphs.md @@ -0,0 +1,25 @@ +There are two types of graphs - undirected and directed. + +The following is an example of a directed graph: + +![alt text](https://computersciencewiki.org/images/c/c6/Directed_graph.png) + +Here is an example of an undirected graph: + +![alt text](https://pediaa.com/wp-content/uploads/2019/01/Difference-Between-Directed-and-Undirected-Graph_Figure-2.png) + +The key difference between these two graphs is that directed graphs have an arrow on their edges which point to the direction of that edge +while undirected graphs do not. + +Graphs can be used to represent a variety of things. They are used to represent networks like a newtwork of airplane routes or a network of +water pipes. They are also used in social media like Facebook to represent connections between users. + +Graphs are commonly stored in two different ways: adjacency lists and adjacency matrices. + +The adjacency list of a given node is the list of all other nodes that are adjacent to that node. +An adjacency matrix is a 2D array of size NxN where N is the number of nodes in the graph. In each cell of the array there is either a +1 or a 0 to represent if the node is adjacent or not. + +Adjacency lists take up less space than adjacency matrices, but are slower in determining whether or not a node has an edge to another. + +