Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie...

13
Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County

Transcript of Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie...

Page 1: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

Data Structures

IS 101Y/CMSC 101Computational Thinking and Design

Thursday, October 3, 2013

Marie desJardinsUniversity of Maryland, Baltimore County

Page 2: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

QuizIndividual quiz: 5 minutes

Team quiz: 5 minutes

Page 3: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

Data StructuresDefinition:

A particular way of storing and organizing data in a computer so that it can be used efficiently

ExamplesVariable – a single data element - the simplest data

structureArray – an ordered list of data elementsTree – stay tunedGraph – dittoPriority, FIFO and LIFO queues – sorted arraysTuple – a defined collection of related data elements

Page 4: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

TreesA set of nodes and edges

An edge between two nodes indicates there is some sort of relationship between them

No circular relationshipsHas a “root” node and “leaf” nodes

ExamplesTelephone treeFamily treeFunctional decomposition

Page 5: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

Tree ExerciseUse a tree to alphabetize yourselves

Who is the root of your tree?

Who are the leaves?

Page 6: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

GraphsA set of nodes and edges

An edge between two nodes indicates there is some sort of relationship between them

No circular relationships

ExamplesMapsSocial networksSemantic networks

Page 7: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

Semantic NetworkA graph where the nodes represent concepts

and the edges represent relationships between those conceptsUsed to organize complex information

ExamplesOntologies – includes terms and definitions in a

particular domain, e.g. medicine, architectureBrainstorming – some techniques use a semantic

network as a way to capture the results of the brainstorming

The human brain?

Page 8: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

Recursion A structure or process that is defined self-referentially

Recursive definition of a list of items: A list is either:

an empty list (no items) or a single item followed by a list

Recursive definition of an algorithm for searching for a particular item in a list: Find the middle item in the list If that’s the item you’re looking for

You’re done Else

Search the first half of the list Search the second half of the list

Page 9: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

Semester GameWhat information needs to be stored?

How might you organize it?By week?By choice?By outcome?

Could you use a tree?

Could you use a graph?

Page 10: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

Data Design for the Semester Game

For each week, what do you need to keep track of?

Page 11: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

Similarly, for CrashFor each “floating animal”, what do we need to

keep track of? image – the picture of the animalxpos – the current X position of the pictureypos – the current Y position of the picturexdir – the current horizontal direction and speedydir – the current vertical direction and speedtimes – how long the picture has been on the

screen

Solution: we’re using an array for each of these data items (see CrashBasics.pde)

Page 12: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

NOTICE: Important

Project HintComing

up!!!

Page 13: Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.

Data Design for the Semester Game

Crash, conceptually, is a very similar problem to the Semester Game

The same approach (using arrays) that we used in CrashBasics can be used for the Semester Game.