Lecture 4

Let try s to decompose the problem 1 writing an array

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ; x >= 0 ; --x) loop, but we will do it recursively. Let’ try s to decompose the problem. 1 - Writing an array of length “n” can be decomposed into writing a single character (that’ easy) and writing and array of length s “n-1” backwards, which is a problem of the same kind as writing an array of length “n”, but it’ “simpler”. s 13 2 - If we keep reducing the length of the array that we have to write backwards, we will eventually end up with an array of size 1. That is: a character, and writing a character is “easy”. EVEN BETTER, we can go to an array of size ZERO and then we have to do NOTHING. 14 Still, nothing in this description results in something written backward! We refine: An array is written backward by FIRST writing its last element, and then writin...
View Full Document

Ask a homework question - tutors are online