Topic#11 - CS162 - Topic #11 Lecture: Recursion Problem...

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

View Full Document Right Arrow Icon
CS162 - Topic #11 Lecture: Recursion Problem solving with recursion Work through examples to get used to the recursive process Programming Project Any questions on the User’s Manual and External Design Document?
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS162 - Using Recursion Today we will walk through examples solving problems with recursion To get used to this process we will select simple problems that in reality should be solved using iteration and not recursion but, it should give you an understanding of how to design using recursion which we will need to understand for CS163
Background image of page 2
CS162 - Example #1 First, let’s display the contents of a linear linked list, recursively obviously this is should be done iteratively! but, as an exercise determine what the stopping condition should be first: when the head pointer is NULL what should be done when this condition is reached? return what should be done otherwise? display and call the function recursively
Background image of page 3

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

View Full DocumentRight Arrow Icon
If we were to do this iteratively: void display(node * head) { while (head) { cout <<head->data->title <<endl; head = head->next; } } Why is it ok in this case to change head? Look at the stopping condition
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/17/2010 for the course CS 162 taught by Professor Fant during the Spring '08 term at Portland State.

Page1 / 15

Topic#11 - CS162 - Topic #11 Lecture: Recursion Problem...

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

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