01 Introduction

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

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

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

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

View Full Document
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
Mazes Mazes as an illustration of 15-211 thinking

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

View Full Document
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?
Approach 1: Let’s hack

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

View Full Document
Approach 2: Let’s think
How do these mazes differ?

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

View Full Document
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]
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

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

View Full Document
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
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

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

View Full Document
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
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online