|
C M S C 2 1 4 C o m p u t e r S c i e n c e I I F a l l 2 0 0 2 |
Remove loops from ItemSortedList and implement using recursion. Note: this is practice writing recursive methods. Using recursion is best when applied to problems where the recursion is not too deep (i.e., not too many recursive calls). For a DLL, the recursion is likely to go O(n), which is rather deep. Despite this problem (which is why you would realistically not use recursion in this situation), it's practice writing recursive functions, so you'll do it anyway. (Our tests will rarely put more than 10 elements in the SortedList, so it really won't cause problems).
It's generally best to write recursive functions that only go O(lg n) function calls deep.
To read about recursive functions, go to the main webpage and click on Tutorial. At the bottom are two webpages on recursion. The second one (version 2) has useful information about how to convert a loop to recursion. The link is at the very bottom.
The first tutorial is useful too. Yes, they should be merged
into one tutorial, but they aren't. So, there's some overlap.
|
See the class syllabus for policies concerning email Last Modified: Sat Sep 28 23:08:44 EDT 2002 |
|
|
|
|
|