an assortment of things 1.this class will go over the exam. if you haven’t taken the exam yet...

7
An Assortment of Things 1.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. 2.Please get in groups of 3-4 people (4 is better…1 and 2 are NOT ok)

Upload: barnaby-powell

Post on 19-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An Assortment of Things 1.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

An Assortment of Things

1. 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.

2. Please get in groups of 3-4 people (4 is better…1 and 2 are NOT ok)

Page 2: An Assortment of Things 1.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

The Plan for Today

1. A Musical Interlude2. We review a few key questions from the

exama. whoWinsPilesList (Recursive backtracking)b. getMissingParens (Stacks)

3. I introduce “Graphs” the final structure we will look at

4. Hand back exams

Page 3: An Assortment of Things 1.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

The Music Video Project

1. A student created CompSci 100 tradition2. Create a music video, recorded song, or just a

set of lyrics about some part of CompSci 100.3. Work in groups4. Your creations will be played as folks arrive

for the final exam5. Extra credit (but that’s not really the point)

Page 4: An Assortment of Things 1.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

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

Page 5: An Assortment of Things 1.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

Graphs

• “Nodes” with edges between them

AB

C

D

•Could be “cyclic” or “acyclic”•Could be “directed” or “undirected”

Might represents a map, where nodes represent cities and edges represent roads

Page 6: An Assortment of Things 1.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

A Node Class…similar to the way we do with linked lists and treesclass Node {

public String name;public ArrayList<Node> neighbors;

}

A adjacency list, where each node ‘name’ maps to a list of neighborsHashMap<String,ArrayList<String>> graph;//is there an edge from a to b?boolean edgeExists = graph.get(“A”).contains(“B”);

A adjacency matrix, where connections between nodes is represented by a 2D matrixboolean [][] graph;//is there an edge from 3 to 17?boolean edgeExists = graph[3][17];

Represent the graph below with all 3 different mechanisms

0

1

2

Page 7: An Assortment of Things 1.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

Can even be implicit

dog

grand

dad

You can move between two words if the last letter of the previous word matches the first letter of the next word