01 Introduction

01 Introduction - Welcome and Introduction 15-211...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
Welcome and Introduction 15-211 Fundamental Data Structures and Algorithms Charlie Garrod and Margaret Reid-Miller http://www.cs.cmu.edu/{~charlie,~mrmiller} 12 January 2010
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Today An illustrative problem: Mazes What the course is about Algorithms and data structures Analysis of algorithm efficiency Reasoning about correctness Abstraction for problem-solving Mechanics of the course Website: http://www.cs.cmu.edu/~211 Textbook Staff and recitations Assignments and FrontDesk Assessment
Background image of page 2
Mazes Mazes as an illustration of 15-211 thinking
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Mazes: Our Intent Here We want to write a program to generate and solve mazes Our requirements: Solvable There is a path from start to finish “Game-play” assumptions 1. Upper left to lower right 2. The entire area is reachable 3. One solution path and no loops or cycles 4. Random designs How should we develop our solution?
Background image of page 4
Approach 1: Let’s hack
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Approach 2: Let’s think
Background image of page 6
How do these mazes differ?
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Thinking about the problem Think about a grid of rooms separated by walls. Each room can be given a name. a b c d h g f e i j k l p o n m Create starting configuration [1] Knock out upper left Knock out lower right Randomly [4] knock out walls until we get a good maze: No loops (cycles) [3] All rooms are reachable [2]
Background image of page 8
Mathematical formulation A set of rooms: {a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p} Pairs of adjacent rooms that have an open wall between them. (a,b) and (g,k) are pairs (j,n) and (c,p) are not Abstractly speaking, this is a mathematical structure called a graph . a b c d h g f e i j k l p o n m
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Mazes as graphs Informally: A graph consists of a set of nodes and a set of edges . A maze is represented by a graph where Each node represents a room, and An edge from node x to node y represents that (1) rooms x and y are adjacent and (2) there is no wall in between them. We will study graph algorithms d h k n o p
Background image of page 10
Mazes as graphs Informally: A graph consists of a set of nodes and a set of edges . Mathematically: An undirected graph is a structure G = < N,E > where N is a set of nodes and E is a set of edges, which are unordered pairs of nodes. A path in a graph is a sequence of nodes n 0 , n 1 , n 2 , …, n m where each pair ( n i , n i+1 ) E . The node n 0 is the source of the path and n m its target The length of the path is m . A node k is reachable from n is there is a path from k to n . d h k n o p
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Why math? Q : Why is it useful to formulate the problem so that mazes are graphs ? A-1 : Data structures are typically defined as mathematical structures . A-2
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 64

01 Introduction - Welcome and Introduction 15-211...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online