{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ch 7 Recursion

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

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

An Introduction to Programming Using Alice Data Structures

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

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

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

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

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

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

{[ snackBarMessage ]}

### Page1 / 6

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

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

View Full Document
Ask a homework question - tutors are online