(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 6861, 250]*) (*NotebookOutlinePosition[ 7946, 285]*) (* CellTagsIndexPosition[ 7902, 281]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell[TextData["16. Recursion I: Passing the Buck: Problems"], "Title", Evaluatable->False, AspectRatioFixed->True], Cell["Last revision: March 23, 1998", "SmallText", Evaluatable->False, AspectRatioFixed->True], Cell[CellGroupData[{ Cell[TextData["Author: YourNameGoesHere"], "Subtitle", CellFrame->True, Evaluatable->False, AspectRatioFixed->True, Background->GrayLevel[0.899992]], Cell[CellGroupData[{ Cell[TextData["Doubling"], "Section", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["Use recursion to double each element in a list: \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["double[{1,2,3}]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" should return \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["{2,4,6}", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\". Of course, don't multiply the list by 2.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]], Cell[CellGroupData[{ Cell[TextData["Partitioning"], "Section", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["Use recursion to partition a list: \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["recurPartition[L_List,k_Integer]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" should return the same thing as \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Partition[L,k]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\". Of course, don't use \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Partition[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\".", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]], Cell[CellGroupData[{ Cell[TextData["Counting Until Base Case"], "Section", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "Use recursion to count how many times the argument can have its square \ root taken before the result is less than 2: \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["manySqrt[x_Real]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" should report how many times the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Sqrt[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" function has to be applied to \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["x", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" before the result is less than 2. For instance, ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Sqrt[81.0]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[" is ", Evaluatable->False, AspectRatioFixed->True], StyleBox["9.0", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[", Sqrt[9.0] is ", Evaluatable->False, AspectRatioFixed->True], StyleBox["3.0", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[" and ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Sqrt[3.0]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[" is less than 2 so, \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["manySqrt[81.0]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" is ", Evaluatable->False, AspectRatioFixed->True], StyleBox["3", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[". Of course, don't use a logarithm.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]], Cell[CellGroupData[{ Cell[TextData["Summing a List"], "Section", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["Use recursion to sum the elements of a list: \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["addUp[{a,1,3,b}]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" should return \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["4+a+b", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\". Of course, don't use \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Plus[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" on a list.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]] }, Open ]] }, Open ]] }, FrontEndVersion->"Macintosh 3.0", ScreenRectangle->{{0, 832}, {0, 604}}, WindowToolbars->{}, WindowSize->{520, 509}, WindowMargins->{{52, Automatic}, {Automatic, 16}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False}, MacintoshSystemPageSetup->"\<\ 00<0004/0B`000003809T?o>old" ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1731, 51, 120, 2, 136, "Title", Evaluatable->False], Cell[1854, 55, 99, 2, 26, "SmallText", Evaluatable->False], Cell[CellGroupData[{ Cell[1978, 61, 156, 4, 78, "Subtitle", Evaluatable->False], Cell[CellGroupData[{ Cell[2159, 69, 85, 2, 50, "Section", Evaluatable->False], Cell[2247, 73, 604, 20, 48, "Text", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[2888, 98, 89, 2, 30, "Section", Evaluatable->False], Cell[2980, 102, 794, 27, 48, "Text", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[3811, 134, 101, 2, 30, "Section", Evaluatable->False], Cell[3915, 138, 2009, 71, 97, "Text", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[5961, 214, 91, 2, 30, "Section", Evaluatable->False], Cell[6055, 218, 766, 27, 48, "Text", Evaluatable->False] }, Closed]] }, Open ]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)