View Full Version : what is the "base case" of a function/algorithm?
nite owl
November 5th, 2007, 08:46 AM
Hi came across a question from past papers I have been looking at preparing for exams.I am totally stumped as to what this is...
Gives me a procedure, then asks: what constitutes the base case in this procedure? I would post the procedure, except its in a pdf format that you can not copy and paste.
bunker
November 5th, 2007, 09:18 AM
Is it looking for a best case on the problem or on an algorithm? The former case is rather difficult, but best case of the algorithm is a bit easier -- you need to use omega notation. Wikipedia has some decent info: http://en.wikipedia.org/wiki/Big_O_notation
Basically what you need to do is approximate each part of the procedure and decide in the best possible case, what is the minimum number of times it will happen. So, say for a linear search of a list the best case is omega(1), when the first item in the list is the target you're looking for.
CptPicard
November 5th, 2007, 09:20 AM
The "base case" would be the "trivial, obvious case" of a function, and in particular in recursion, the termination condition (which often is trivial, just returning some particular value).
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.