Lec12RecursionInClass

# Lec12RecursionInClass - Base case The case for which the...

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

Base case: The case for which the solution can be stated nonrecursively Smaller case – The recursive call that is a smaller version of the original problem General case – This expresses the relationship between the smaller case (recursive call) and the answer to the larger case General case – sometimes called recursive case Recursive algorithm – a solution that is expressed in terms of a base case and recursive case Recursive call – a method (or function) call in which the method/function being called is the same one as the one making the call Direct recursion – uses recursive calls to call itself Indirect recursion – there is a chain of calls in which the last in the chain calls the first in the chain (uncommon) Linked List – count the item in a linked list Base case: head == null -> 0 Smaller case: all but the last element in the list count the items in a linked list one smaller than mine General case: smaller case + 1 int LinkedList::countItems(Link *h) { if (h == NULL)

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.

{[ snackBarMessage ]}

### Page1 / 2

Lec12RecursionInClass - Base case The case for which the...

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

View Full Document
Ask a homework question - tutors are online