Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie...
-
Upload
michael-floyd -
Category
Documents
-
view
212 -
download
0
Transcript of Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie...
Data Structures
IS 101Y/CMSC 101Computational Thinking and Design
Thursday, October 3, 2013
Marie desJardinsUniversity of Maryland, Baltimore County
QuizIndividual quiz: 5 minutes
Team quiz: 5 minutes
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
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
Tree ExerciseUse a tree to alphabetize yourselves
Who is the root of your tree?
Who are the leaves?
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
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?
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
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?
Data Design for the Semester Game
For each week, what do you need to keep track of?
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)
NOTICE: Important
Project HintComing
up!!!
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.