MESSAGE
DATE | 2015-02-18 |
FROM | Ruben Safir
|
SUBJECT | Subject: [LIU Comp Sci] Recursive Allorithms
|
From owner-learn-outgoing-at-mrbrklyn.com Wed Feb 18 03:49:42 2015 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix) id 14F1A1612F8; Wed, 18 Feb 2015 03:49:42 -0500 (EST) Delivered-To: learn-outgoing-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix, from userid 28) id 003461612FB; Wed, 18 Feb 2015 03:49:41 -0500 (EST) Delivered-To: learn-at-nylxs.com Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) by mrbrklyn.com (Postfix) with ESMTP id 48DB91612F8; Wed, 18 Feb 2015 03:49:39 -0500 (EST) Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mailbackend.panix.com (Postfix) with ESMTP id 0DB66126A4; Wed, 18 Feb 2015 03:49:38 -0500 (EST) Received: by panix2.panix.com (Postfix, from userid 20529) id 0588233C90; Wed, 18 Feb 2015 03:49:38 -0500 (EST) Date: Wed, 18 Feb 2015 03:49:37 -0500 From: Ruben Safir To: hangout-at-nylxs.com, learn-at-nylxs.com Subject: [LIU Comp Sci] Recursive Allorithms Message-ID: <20150218084935.GA671-at-panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: owner-learn-at-mrbrklyn.com Precedence: bulk Reply-To: learn-at-mrbrklyn.com
Has anyone ever looked closely and this classic algorithm for the fibonacci sequence
I was listening to this in class and thinking, no that is NOT going to give you the sequence desires.
It is a little snippet of a function that looks something like this
long fib(long in) { long ctch; // std::cout << "a => " << in << std::endl; if(in < 3){ std::cout << in << "| 1" << std::endl; return 1; } ctch = (fib(in - 1) + fib( in - 2) ); std::cout << in << " " << ctch << std::endl; return ctch; }
The problem is it has a double recursion so, amoung other problems it can't guarantee the order of outcomes. There might be a definitive presedence rule, but I'm not certain how it will end up on the stack.
One thing I am certain of is that it is not the same as the polynumerial sequence of
Fn = Fn-1 + Fn-2 where n > 2
That function gives a sequence of: 1 1 2 3 4 8 13 21 34 ...
It will calculate out the last value in the sequence for n. That is the problem it solves. It just bothers me that this is Computer Sciences and they can't be EXACT about the math.
It is just sloppy and then the students get lost.
|
|