70 likes | 157 Views
An Assortment of Things. This class will go over the exam. If you haven’t taken the exam yet (like maybe you forgot and didn’t show up) please don’t attend this class. Please get in groups of 3-4 people (4 is better…1 and 2 are NOT ok). The Plan for Today. A Musical Interlude
E N D
An Assortment of Things This class will go over the exam. If you haven’t taken the exam yet (like maybe you forgot and didn’t show up) please don’t attend this class. Please get in groups of 3-4 people (4 is better…1 and 2 are NOT ok)
The Plan for Today • A Musical Interlude • We review a few key questions from the exam • whoWinsPilesList (Recursive backtracking) • getMissingParens (Stacks) • I introduce “Graphs” the final structure we will look at • Hand back exams
The Music Video Project • A student created CompSci 100 tradition • Create a music video, recorded song, or just a set of lyrics about some part of CompSci 100. • Work in groups • Your creations will be played as folks arrive for the final exam • Extra credit (but that’s not really the point)
Work on teams of 3-4 to Solve whoWinsPilesList • Do not work by yourself or with a partner • Snarf the code and check your solution as you develop it • There is a hint at the bottom of the textfile, if everyone on you team really is stuck • When you finish, more on to getMissingParens • Make sure everyone on your team understands how this code works • When you are finished, submit your code via ambient
Graphs • “Nodes” with edges between them • Could be “cyclic” or “acyclic” • Could be “directed” or “undirected” B A D C Might represents a map, where nodes represent cities and edges represent roads
Represent the graph below with all 3 different mechanisms A Node Class…similar to the way we do with linked lists and trees class Node { public String name; public ArrayList<Node> neighbors; } A adjacency list, where each node ‘name’ maps to a list of neighbors HashMap<String,ArrayList<String>> graph; //is there an edge from a to b? booleanedgeExists = graph.get(“A”).contains(“B”); A adjacency matrix, where connections between nodes is represented by a 2D matrix boolean [][] graph; //is there an edge from 3 to 17? booleanedgeExists = graph[3][17]; 1 0 2
Can even be implicit You can move between two words if the last letter of the previous word matches the first letter of the next word grand dog dad