23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The trace for drawTicks is more complicated than <strong>in</strong> the factorial example,<br />

however, because each <strong>in</strong>stance makes two recursive calls. To illustrate this, we<br />

will show the recursion trace <strong>in</strong> a form that is rem<strong>in</strong>iscent of an outl<strong>in</strong>e for a<br />

document. See Figure 3.23.<br />

Figure 3.23: A partial recursion trace for the call<br />

drawTicks(3). The second pattern of calls for<br />

drawTicks(2) is not shown, but it is identical to the<br />

first.<br />

Throughout this book we shall see many other examples of how recursion can be<br />

used <strong>in</strong> the design of data structures <strong>and</strong> algorithms.<br />

193

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!