fib( fib( fib( fib( fib( fib( fib( fib( fib( fib( fib( fib( fib( fib( fib( figure computations performed for fib( than looping versionin that case use recursion oftenthe looping and recursive versions are quite similarin that casethe edge probably goes to the loopas it will be slightly faster sometimes the recursive version is terribly inefficient in that caseavoid itunlessof courseyou can' come up with an iterative algorithm as you'll see later in the sometimes there just isn' good solution sorting algorithms the sorting problem provides nice test bed for the algorithm design techniques we have been discussing rememberthe basic sorting problem is to take list and rearrange it so that the values are in increasing (actuallynondecreasingorder naive sortingselection sort let' start with simple "be the computerapproach to sorting suppose you have stack of index cardseach with number on it the stack has been shuffledand you need to put the cards back in order how would you accomplish this taskthere are any number of good systematic approaches one simple method is to look through the deck to find the smallest value and then place that value at the front of the stack (or perhaps in separate stackthen you could go through and find the smallest of the remaining cards and put it next in lineetc of coursethis means that you'll also need an algorithm for finding the smallest remaining value you can use the same approach we used for finding the max of list (see as you go throughyou keep track of the smallest value seen so farupdating that value whenever you find smaller one the algorithm just described is called selection sort basicallythe algorithm consists of loop