Maps Chris Piech CS106A, Stanford University. Piech, CS106A, Stanford University

Similar documents
Not All Data is Linear

Introduction to Python Dictionaries

Turtle Ballet: Simulating Parallel Turtles in a Nonparallel LOGO Version. Erich Neuwirth

Package TurtleGraphics

EVENTS OR STEPS The events in the story are the steps that the character takes to solve the problem or reach the goal.

Recursion with Turtles

ACTIVITY KIT. But something is up. There are strange bone-shaped toys lying about...

Print production of this manual has been made possible by the CCWHC and the Government of Nunavut, Department of Environment.

YELLOW VIBRATION BARK COLLAR

1 Turtle Graphics Concepts

APPENDIX A SUMMARY OF PROPOSED TREATMENTS BY UNIT

Our K9 LLC 616 Corporate Way Valley Cottage New York GARNET STATIC SHOCK BARK COLLAR USERS GUIDE

The City School. Learn Create Program

Lesson 5: Turtles P P. 8 Skills P P P P P P P P P P P P. " Materials. ? Big Ideas. How the Turtle Got Its Shell by Justine Fontes, Ron.

Finch Robot: snap level 4

b) Look at the sentences. Where do you find the information in the text? Give line numbers. 1 The kids had a snack on the rocks on Rippon Tor.

Mathematics Reading Writing & Language

Tinbergen s four questions for investigating behavior. Mechanism Ontogeny Function Evolution. Topic for today

GARNET STATIC SHOCK BARK COLLAR

Read each question carefully

Scratch Lesson Plan. Part One: Structure. Part Two: Movement

A Naturalist's Guide to the Snakes of South-east Asia: Including Malaysia, Singapore, Thailand, Myanmar, Borneo, Sumatra, Java and Bali.

DOWNLOAD OR READ : THE DOG WHO CRIED WOLF PDF EBOOK EPUB MOBI

This Adapted Literature resource is available through the Sherlock Center Resource Library.

GARNET STATIC SHOCK BARK COLLAR

Watch Kong Skull Island Full Movie Online Free, Watch Kong Skull Island Full Movie Online Dailymotion, Kong Skull Island Putlocker, download 5Shared,

Susan Boyer Published by Birrong Books, an imprint of Boyer Educational Resources ISBN:

Recurrent neural network grammars. Slide credits: Chris Dyer, Adhiguna Kuncoro

Agenda Item No.: Date: January 26, 2010

Colin Seale, thinklaw Founder CEO

(Name of Project) by (Name of First Writer) (Based on, If Any) Revisions by (Names of Subsequent Writers, in Order of Work Performed)

Fractal. Fractals. L- Systems 1/17/12

Porcupinefish, Zebra Eels, Leopard Geckos, Owl Monkeys, Giraffe Beetles, & 251 other BIZARRE Creatures

Sketch Out the Design

GEODIS 2.0 DOCUMENTATION

SAN ĠORĠ PRECA COLLEGE PRIMARY SCHOOLS. Half Yearly Exams Year 5 ENGLISH Time: 1 hour 15 minutes. Reading Comprehension, Language and Writing

FAST-R + Island of the Blue Dolphins. by Scott O Dell. Formative Assessments of Student Thinking in Reading

Moving towards formalisation COMP62342

Name period date assigned date due date returned. Natural Selection

Free time. A special hobby. 1 Read and speak. In this unit you can. a What do you do in your free time?

Texas Task Force 1. FEMA Canine Search Specialist Certification Evaluation 12 Month Training Objectives

LP-NSM(L) Series. Features. Product Dimensions. Small size of Fast tripping resettable circuit protection

COLLARS STAINLESS STEEL. HERM. SPRENGER GMBH Hundesport Catalogue '12

Reindeer (Read And Learn: A Day In The Life: Polar Animals) By Katie Marsico

Ganges River microbial diversity

Dasher Web Service USER/DEVELOPER DOCUMENTATION June 2010 Version 1.1

Package PetfindeR. R topics documented: May 22, Type Package Title 'Petfinder' API Wrapper Version Author Aaron Schlegel

LP-NSM(L) Series. Features. Product Dimensions. Small size of Fast tripping resettable circuit protection

Extended response passage from Wolves by Seymour Simon (Making Meaning readaloud, grade 7).

EXAMINATION AND DIAGNOSTIC I Muzzles. KRUUSE Muzzle Guide.

PYTHON FOR KIDS A Pl ayfu l I ntrodu ctio n to Prog r am m i ng J a s o n R. B r i g g s

Multilevel Script. Teacher s Guide. Animals, Animals. Level E Level H Level K. Levels: E, H, and K Word Count: 460. Story Summary: Cast of Characters:

Lipsey Clinic fills a need with low-cost vet care at SPCA

EXAMINATION AND DIAGNOSTIC I Muzzles. KRUUSE Muzzle Guide.

STATUS SIGNALING IN DARK-EYED JUNCOS

Dog: 5000 Years Of The Dog In Art By Tamsin Pickeral READ ONLINE

Required and Recommended Supporting Information for IUCN Red List Assessments

!"#$%&&%"'#())*+,-.*#/0-,-"1#)%0#233#4,56*",7!!

Moving toward formalisation COMP62342

In 1996 I acquired a small recipe box that we used

Plants and Animals. What do living organisms need to survive? What can you see in the photos in 1? Unscramble the letters. I can see a lot of

Thank you for being a hero and partner in our lifesaving mission! Tammy Fox Executive Director

BRAND GUIDELINES THE SHEPHERD BRAND

My name is Erin Catto and I want to thank you for coming to my tutorial.

Scratch. To do this, you re going to need to have Scratch!

Uses pet friendly active hygiene technology to keep the mat fresh!

By Matthew Van Fleet. Dear Bookseller, Teacher, or Librarian,

Free Supplemental Lesson Pack 3

Puppy Trouble. Yvette Poshoglian. Danielle McDonald. For Ann Knowles YP For Katelyn Grace, and your cousins Ella and Olivia (and Charlotte) DM

contributes to the response and cite evidence to support an inference about a Read this text and then answer the prompt that follows it.

by Joy Klein illustrated by Rex Barron

Going to a Show Milwaukee Youth Arts Center AT T H E

Semantics. These slides were produced by Hadas Kotek.

Celebrating Felines. Welcome to Crazy for Kitties and Cats!

by Dr. Corey S. Goodman 3. Made false representations of key acoustic data in Chapter 4 of the DEIS. April 24, 2012

Maya Python For Games And Film: A Complete Reference For Maya Python And The Maya Python API By Adam Mechtley, Ryan Trowbridge READ ONLINE

How To Recognize. This online guide was created by Bob Childs to help people recognize the Asian Longhorned Beetle.

Welcome to the 12th Annual Poochapalooza Outdoor Dog Event Saturday, July 7, a.m. -4:00 p.m. Marysville s premier pet party returns! Woof!

PROGRESS REPORT for COOPERATIVE BOBCAT RESEARCH PROJECT. Period Covered: 1 April 30 June Prepared by

50 min. year. Use 2B or HB pencil only. Time available for students to complete test: 50 minutes

Life Cycle of a Leopard

Nonfiction. by Diane Furuichi PAIRED. Poetry READ

Buffalo & WNY Poultry club Newsletter Fall Presidents Message

Small Tales. A short story in four parts

What Pet. Should You Get? What Pet. Should You Get? A Reading A Z Level J Leveled Book Word Count: 451 LEVELED BOOK J.

FOCUS Question. What Whiskers Do

HAT HILL DOG OFF-LEASH AREA MODIFICATIONS

The Blimp. DOWN 1 To steer, the pilot into a place under the air bag. 2 The large air bag is made of. 4 What is floating in the sky?

Prairie Warbler Survival

Tom Mitchell & Lauren Langman

StarLogo Complete Command List (Edited and reformatted by Nicholas Gessler, 6 June 2001.)

The Journey Of The Winter Kittens

Tales 2000 Learningpage.com, inc.

OPERATION AND MAINTENANCE MANUAL

Egg laying vs. Live Birth

parallel and nonparallel

Book Four. o h S. w e l. Written and illustrated by. A Progressive Phonics book Copyright (c) by Miz Katz N. Ratz, patent pending T.M.

Teachers Notes How to Talk to a Frill-neck Lizard

Muse Teacher Guide: February 2018

Follifoot Farm Series 3

Transcription:

Maps Chris Piech CS106A, Stanford University

CS106A Winter 2018 Contest

Why is this so fast?

Where are we?

Where are we? Karel the Robot Java Console Programs Graphics Programs Text Processing Data Structures GUIs Defining our own Variable Types

Collections High Level List: Array: Matrix: ArrayList<type> type[] type[][]

Collections High Level List: Array: Matrix: ArrayList<String> double[] int[][]

ArrayList index -> value

Arrays index -> value

Matrix (row, col) -> value

Maps can have any type for key Many examples

HashMap key -> value

Simple Example 1. Make a new HashMap of animal sounds 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

Simple Example 1. Make a new HashMap of animal sounds 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

Simple Example animalsoundmap Values: Keys: 1. Make a new HashMap of animal sounds 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

Simple Example animalsoundmap Values: Keys: 1. Make a new HashMap of animal sounds 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

Simple Example animalsoundmap Values: Keys: bark dog 1. Make a new HashMap of animal sounds 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

Simple Example animalsoundmap Values: Keys: bark dog 1. Make a new HashMap of animal sounds 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

Simple Example animalsoundmap Values: bark meow Keys: dog cat 1. Make a new HashMap of animal sounds 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

Simple Example animalsoundmap Values: bark meow Keys: dog cat 1. Make a new HashMap of animal sounds 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

Simple Example animalsoundmap Values: bark ow ow ow meow Keys: dog seal cat 1. Make a new HashMap of animal sounds 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

Simple Example animalsoundmap Values: bark ow ow ow meow Keys: dog seal cat 1. Make a new HashMap of animal sounds 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

Simple Example animalsoundmap Values: bark ow ow ow meow Keys: dog seal cat 1. Make a new HashMap of animal sounds 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

Simple Example animalsoundmap Values: bark ow ow ow meow Keys: dog seal cat 1. Make a new HashMap of animal sound 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

Simple Example animalsoundmap Values: bark ow ow ow meow Keys: dog seal cat 1. Make a new HashMap of animal sound 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = cat ]

Simple Example animalsoundmap Values: bark ow ow ow meow Keys: dog seal cat 1. Make a new HashMap of animal sound 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = cat ]

Simple Example animalsoundmap Values: bark ow ow ow meow Keys: dog seal cat 1. Make a new HashMap of animal sound 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = cat ]

My First Map HashMap<String, String> animalsoundmap = new HashMap<String, String>();

My First Map Key Type Value Type HashMap<String, String> animalsoundmap = new HashMap<String, String>();

My First Map HashMap<String, String> animalsoundmap = new HashMap<String, String>();

My First Map HashMap<String, String> animalsoundmap = new HashMap<String, String>();

My First Map HashMap<String, String> animalsoundmap = new HashMap<String, String>(); animalsoundmap.put( dog, bark );

My First Map HashMap<String, String> animalsoundmap = new HashMap<String, String>(); animalsoundmap.put( dog, bark );

My First Map HashMap<String, String> animalsoundmap = new HashMap<String, String>(); animalsoundmap.put( dog, bark );

My First Map HashMap<String, String> animalsoundmap = new HashMap<String, String>(); animalsoundmap.put( dog, bark );

My First Map HashMap<String, String> animalsoundmap = new HashMap<String, String>(); animalsoundmap.put( dog, bark ); animalsoundmap.get( dog );

My First Map HashMap<String, String> animalsoundmap = new HashMap<String, String>(); animalsoundmap.put( dog, bark ); animalsoundmap.get( dog );

My First Map HashMap<String, String> animalsoundmap = new HashMap<String, String>(); animalsoundmap.put( dog, bark ); animalsoundmap.get( dog );

animalsoundmap My First Map Values: bark ow ow ow meow Keys: dog seal cat 1. Make a new HashMap of animal sound 2. Add elements: Put [key = dog, value = bark ] Put [key= cat, value= meow ] Put [key= seal, value= ow ow ow ] 3. Get elements: Get [key = dog ]

animalsoundmap My First Map Values: bark ow ow ow meow Keys: dog seal cat // 1. Make a new map HashMap<String, String> animalsoundmap = new HashMap<String, String>(); // 2. Put things into the map animalsoundmap.put("dog", "woof"); animalsoundmap.put("cat", "meow"); animalsoundmap.put("seal", "ow ow ow"); // 3. Get things out of the map animalsoundmap.get("dog"); // "woof

animalsoundmap My First Map Values: bark ow ow ow meow Keys: dog seal cat // 1. Make a new map HashMap<String, String> animalsoundmap = new HashMap<String, String>(); // 2. Put things into the map animalsoundmap.put("dog", "woof"); animalsoundmap.put("cat", "meow"); animalsoundmap.put("seal", "ow ow ow"); // 3. Get things out of the map animalsoundmap.get("dog"); // "woof" animalsoundmap.get("fox"); Piech, CS106A, Stanford // University?

brothers Vegard and Bård Ylvisåker Circa 2013

Ylvis Piech, The CS106A, Fox. Stanford Permission University asked. Pending.

animalsoundmap My First Map Values: bark ow ow ow meow Keys: dog seal cat // 1. Make a new map HashMap<String, String> animalsoundmap = new HashMap<String, String>(); // 2. Put things into the map animalsoundmap.put("dog", "woof"); animalsoundmap.put("cat", "meow"); animalsoundmap.put("seal", "ow ow ow"); // 3. Get things out of the map animalsoundmap.get("dog"); // "woof" animalsoundmap.get("fox"); Piech, CS106A, Stanford // University?

animalsoundmap My First Map Values: bark ow ow ow meow Keys: dog seal cat // 1. Make a new map HashMap<String, String> animalsoundmap = new HashMap<String, String>(); // 2. Put things into the map animalsoundmap.put("dog", "woof"); animalsoundmap.put("cat", "meow"); animalsoundmap.put("seal", "ow ow ow"); // 3. Get things out of the map animalsoundmap.get("dog"); // "woof" animalsoundmap.get("fox"); Piech, CS106A, Stanford // University null

HashMaps on one slide 1. Make a HashMap HashMap<keyType, valuetype> mymap = new HashMap<keyType, valuetype>(); 2. Put and get values into a map mymap.put(key, value); mymap.get(key) // returns the corresponding value 3. Some useful other methods int size = mymap.size(); mymap.containskey(key); // returns true or false if key is in map mymap.keyset(); mymap.remove(key); // make like a tree and leave! 4. Iterate using a foreach loop for(keytype key : mymap.keyset()){ // not ordered mymap.get(key); // do something with the key/value pair }

Phone Book 6701678

Make a keyboard

Why is this so fast?

Why is this so fast? int hash(string key); * Piech, Learn CS106A, more Stanford in CS106B University