CSE 214 – Computer Science II Maps

Slides:



Advertisements
Similar presentations
Map Collections and Custom Collection Classes Chapter 14.
Advertisements

Chapter 9: Graphs Shortest Paths
P2P data retrieval DHT (Distributed Hash Tables) Partially based on Hellerstein’s presentation at VLDB2004.
CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
Problem Solving Agents A problem solving agent is one which decides what actions and states to consider in completing a goal Examples: Finding the shortest.
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
CS 206 Introduction to Computer Science II 11 / 03 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 03 / 25 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 03 / 30 / 2009 Instructor: Michael Eckmann.
Chapter 3 List Stacks and Queues. Data Structures Data structure is a representation of data and the operations allowed on that data. Data structure is.
Data Structures and Abstract Data Types "Get your data structures correct first, and the rest of the program will write itself." - David Jones.
Week 6 - Friday.  What did we talk about last time?  Recursive running time  Fast exponentiation  Merge sort  Introduced the Master theorem.
CSS446 Spring 2014 Nan Wang.  Java Collection Framework ◦ Set ◦ Map 2.
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
1 C++ Classes and Data Structures Jeffrey S. Childs Chapter 15 Other Data Structures Jeffrey S. Childs Clarion University of PA © 2008, Prentice Hall.
Maps Nick Mouriski.
Week 9 - Friday.  What did we talk about last time?  Collisions  Open addressing ▪ Linear probing ▪ Quadratic probing ▪ Double hashing  Chaining.
Source: CSE 214 – Computer Science II Graphs.
Maps Rem Collier Room A1.02 School of Computer Science and Informatics
Design & Analysis of Algorithm Map
B/B+ Trees 4.7.
May 3rd – Hashing & Graphs
Chapter 22 Elementary Graph Algorithms
CSE 373 Topological Sort Graph Traversals
Efficient implementations of Alignment-based algorithms
Chapter 7: Greedy Algorithms
CSC317 Graph algorithms Why bother?
Week 8 - Friday CS221.
Csc 2720 Instructor: Zhuojun Duan
Cse 373 May 15th – Iterators.
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Road Map CS Concepts Data Structures Java Language Java Collections
structures and their relationships." - Linus Torvalds
CMSC 341 Lecture 21 Graphs (Introduction)
structures and their relationships." - Linus Torvalds
Binary Search Trees < > =
CSE 421: Introduction to Algorithms
Elementary Graph Algorithms
CS 3343: Analysis of Algorithms
CSE 373: Data Structures and Algorithms
Graphs Chapter 13.
Teach A level Computing: Algorithms and Data Structures
Chapter 21 Hashing: Implementing Dictionaries and Sets
Maps.
Lesson 6. Types Equality and Identity. Collections.
Graphs.
CSE 214 – Computer Science II B-Trees
Implementing Hash and AVL
CSE 214 – Computer Science II Graph Walking
"He's off the map!" - Eternal Sunshine of the Spotless Mind
Searching CLRS, Sections 9.1 – 9.3.
CSE 421: Introduction to Algorithms
CS2110: Software Development Methods
Chapter 14 Graphs © 2006 Pearson Addison-Wesley. All rights reserved.
CSE 373: Data Structures and Algorithms
Richard Anderson Winter 2009 Lecture 6
Chapter 8 The Map ADT.
Graphs.
Graphs.
Graphs.
6.170 Recitation Godfrey Tan.
Trees in java.util A set is an object that stores unique elements
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
Graphs.
CO4301 – Advanced Games Development Week 12 Using Trees
structures and their relationships." - Linus Torvalds
Prof. Ramin Zabih Graph Traversal Prof. Ramin Zabih
Week 6 - Monday CS221.
Presentation transcript:

CSE 214 – Computer Science II Maps Source: http://contrailscience.com/wp-content/uploads/usa-flightpaths750.jpg

Maps An abstract data structure for storing (key, value) data pairs called (name, value) on Web maps may also be called dictionaries, associative arrays, etc. What’s a key? a unique identifier for accessing a piece of data like an ID What’s a value? the data

You have already built a type of map PresidentsBST is a Map Each president has a unique ID president number ID provides a natural sorting/ordering Only difference: we didn’t call it a map we didn’t adhere to a specific map interface

Game Programmers Love Maps Why? To store commonly used assets Example: 3D Model of a dragon suppose we need to render 3 or more identical dragons same geometry, same textures, same animations, etc.

What do we do? Construct Dragon object for each one Instead: will keep track of location, animation state, damage, etc. don’t load dragon artwork 3 times Instead: load dragon artwork once store it in a dictionary (map) Optimized for fast access (log N) give map key of dragon to all Dragon objects At render time: retrieve 3D dragon model from dictionary using ID render the 3 models

The java.util.Map interface Map methods: V get(K key, V value) V put(K key, V value) V remove(Object key) Colletions<V> values() – to help with getting an Iterator Manages Map.Entry objects

The java.util.Map.Entry Interface A Map.Entry has: 2 variables Object: key Object: value accessors for getting key & value mutator for setting value

Ex: HashMap vs. TreeMap Both are maps Both classes implement Map both have the same methods Underlying data structures are different HashMap is a hash table TreeMap is a red-black tree a self-balancing binary search tree

So what are we using maps for? Storing our Airports a lookup dictionary Why? because we have a lot of data fast way of getting this info

Our updated AirportGraph public class AirportGraph { // THESE ARE THE NODES IN THE GRAPH public TreeMap<String,Airport> vertices = new TreeMap<String,Airport>(); // THESE ARE THE CONNECTIONS BETWEEN THE NODES // FOR EACH AIRPORT CODE, WE HAVE A SORTED Vector // OF THE ADJACENT AIRPORT CODES public TreeMap<String,Vector<String>> edges = new TreeMap<String,Vector<String>>();

How might we find a shortest path? This is a bonus part of the assignment We can do this by remembering shortest paths to other nodes Let’s do another example

Depth First Search vs. Breadth First Search Again, let’s do an example