如何使用斐波那契数来教递归编程

J. Gerhard
{"title":"如何使用斐波那契数来教递归编程","authors":"J. Gerhard","doi":"10.5206/mt.v1i1.14038","DOIUrl":null,"url":null,"abstract":"There are too many examples and programming guides (which, e.g., an internet search for \"recursive procedure Fibonacci\" will turn up) to count that use Fibonacci numbers as an example to illustrate recursive programming. The motivation for this article is to show why the naive way of doing this is a bad idea, as it is horrendously inefficient. We will exhibit much more efficient ways of computing Fibonacci numbers, both iterative and recursive, and analyze and compare worst case running times and memory usages. Using some mathematical properties of Fibonacci numbers leads to the most efficient method for their computation. For illustration and benchmarking, we will use Maple and its programming language, however, similar behaviour can be demonstrated in almost any other programming language. This exposition combines and explores the mathematical properties of Fibonacci numbers, notions of algorithmic complexity, and efficient Maple programming and profiling techniques, and may be used as an introduction to any of these three subjects. The techniques described can be readily generalized to more general types of linear recurrences with constant coefficients.","PeriodicalId":355724,"journal":{"name":"Maple Transactions","volume":"43 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2021-10-06","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"title\":\"How to use Fibonacci numbers to teach recursive programming\",\"authors\":\"J. Gerhard\",\"doi\":\"10.5206/mt.v1i1.14038\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"There are too many examples and programming guides (which, e.g., an internet search for \\\"recursive procedure Fibonacci\\\" will turn up) to count that use Fibonacci numbers as an example to illustrate recursive programming. The motivation for this article is to show why the naive way of doing this is a bad idea, as it is horrendously inefficient. We will exhibit much more efficient ways of computing Fibonacci numbers, both iterative and recursive, and analyze and compare worst case running times and memory usages. Using some mathematical properties of Fibonacci numbers leads to the most efficient method for their computation. For illustration and benchmarking, we will use Maple and its programming language, however, similar behaviour can be demonstrated in almost any other programming language. This exposition combines and explores the mathematical properties of Fibonacci numbers, notions of algorithmic complexity, and efficient Maple programming and profiling techniques, and may be used as an introduction to any of these three subjects. The techniques described can be readily generalized to more general types of linear recurrences with constant coefficients.\",\"PeriodicalId\":355724,\"journal\":{\"name\":\"Maple Transactions\",\"volume\":\"43 1\",\"pages\":\"0\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2021-10-06\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"0\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"Maple Transactions\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/10.5206/mt.v1i1.14038\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"Maple Transactions","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.5206/mt.v1i1.14038","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

摘要

有太多的例子和编程指南(例如,在互联网上搜索“斐波那契递归过程”会出现)来计算使用斐波那契数作为示例来说明递归编程。本文的目的是说明为什么这种简单的方法是一个坏主意,因为它的效率非常低。我们将展示更有效的计算斐波那契数的方法,包括迭代和递归,并分析和比较最坏情况下的运行时间和内存使用。利用斐波那契数的一些数学性质,我们可以找到最有效的计算方法。为了说明和基准测试,我们将使用Maple及其编程语言,然而,类似的行为可以在几乎任何其他编程语言中进行演示。本文结合并探讨了斐波那契数的数学特性、算法复杂性的概念以及高效的Maple编程和分析技术,可以作为这三个主题中的任何一个的介绍。所描述的技术可以很容易地推广到更一般类型的常系数线性递归。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
How to use Fibonacci numbers to teach recursive programming
There are too many examples and programming guides (which, e.g., an internet search for "recursive procedure Fibonacci" will turn up) to count that use Fibonacci numbers as an example to illustrate recursive programming. The motivation for this article is to show why the naive way of doing this is a bad idea, as it is horrendously inefficient. We will exhibit much more efficient ways of computing Fibonacci numbers, both iterative and recursive, and analyze and compare worst case running times and memory usages. Using some mathematical properties of Fibonacci numbers leads to the most efficient method for their computation. For illustration and benchmarking, we will use Maple and its programming language, however, similar behaviour can be demonstrated in almost any other programming language. This exposition combines and explores the mathematical properties of Fibonacci numbers, notions of algorithmic complexity, and efficient Maple programming and profiling techniques, and may be used as an introduction to any of these three subjects. The techniques described can be readily generalized to more general types of linear recurrences with constant coefficients.
求助全文
通过发布文献求助,成功后即可免费获取论文全文。 去求助
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信