ch 7 Recursion - called triangles A, B, C, and D, with D in...

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

View Full Document Right Arrow Icon
An Introduction to Programming Using Alice Data Structures
Background image of page 1

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

View Full DocumentRight Arrow Icon
An Introduction to Programming Using Alice Recursion Something is said to be recursive if each of the parts that make up the thing have a structure — in other words, a design or pattern — that repeats the structure of the whole thing itself. The fern shown here is recursive because each of its leaves has a structure like that of the entire fern itself.
Background image of page 2
An Introduction to Programming Using Alice Recursion The image shown here, a “Sierpinski gasket” is a recursive structure. It is generated by a recursive algorithm. A recursive algorithm is one that calls itself.
Background image of page 3

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

View Full DocumentRight Arrow Icon
An Introduction to Programming Using Alice Here is an algorithm to draw a Sierpinski Gasket. It splits a triangle into four smaller triangles, and then calls itself for three of the four smaller triangles. It is a recursive algorithm. Sierpinski (triangle) Start Find the mid point of each side of the triangle Draw lines connecting the midpoints, which will form four smaller triangles that can be
Background image of page 4
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: called triangles A, B, C, and D, with D in the center and the others around it. Color in (or cut out) the center triangle Do Sierpinski (triangle A) Do Sierpinski (triangle B) Do Sierpinski (triangle C) Stop An Introduction to Programming Using Alice Recursive algorithms can generate complex structures from a simple instruction set. They are among the most powerful and useful of all algorithms. Sierpinski (triangle) Start Find the mid point of each side of the triangle Draw lines connecting the midpoints, which will form four smaller triangles that can be called triangles A, B, C, and D, with D in the center and the others around it. Color in (or cut out) the center triangle Do Sierpinski (triangle A) Do Sierpinski (triangle B) Do Sierpinski (triangle C) Stop An Introduction to Programming Using Alice Recursion Recursive algorithms can generate complex structures from a simple instruction set. They are among the most powerful and useful of all algorithms....
View Full Document

This note was uploaded on 10/17/2011 for the course CIS 106 taught by Professor Alice during the Spring '11 term at Community College of Philadelphia.

Page1 / 6

ch 7 Recursion - called triangles A, B, C, and D, with D in...

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

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