Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 9th, 2006, 9:00 AM   #11
MBirchmeier
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 211
Rep Power: 3 MBirchmeier is on a distinguished road
Quote:
Originally Posted by bl00dninja View Post
a c++ while loop and a python one might have different big-O complexity. if you don't know what i mean by that...that's what you're asking so google it.
*I* Dont' know what you mean by that. Unless I'm mistaken big-O is algorithm dependant, not language; Nlog(N) on the python side, is Nlog(N) on the .ASM side.

The various times of their execution might vary, but I doubt the govenor will phone for them at the last second anyway.

-MBirchmeier
MBirchmeier is offline   Reply With Quote
Old Oct 9th, 2006, 9:27 AM   #12
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4 Arevos is on a distinguished road
A language can have an affect on the order of a function, because functions often rely on functions built into the language, or part of a standard library. There's also issues with automatic optimisations leading to asynchronous efficiency gains.

However in practise its rare that a language will make any significant difference in that regard, especially with simple control structures such as while loops. I'd be very surprised indeed if the order of a C fibonacci program and a Python fibonacci program wasn't practically identical.

Also, in this case the order is O(N) in Big O notation; it's a very simple algorithm, and unlikely to be affected significantly by language differences. There's no need to google "big-O complexity" for something like this; it's just overcomplicating things.
Arevos is offline   Reply With Quote
Old Oct 9th, 2006, 10:18 AM   #13
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
This is a strange thread, because the question is appropriate, but the OP should have broken some small amount of sweat on his own initiative, rather than merely looking for mama to break out the sugar tit.

Here are five search results.

There's actually a reason that the forum's rules state that you should seach first. The reason is that I'm going to charge you lebenty-seven trillion dollars for doing it for you, when you could have done it as easily. Google awaits your bidding.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 9th, 2006, 2:01 PM   #14
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Talking

Quote:
Originally Posted by baldy1324 View Post
hi i am diving into programming and wanting to find out the amount of time it takes to execute a fibonacci sequence program. i have had past expirience with c++ so i have that code. to make sure the way the program runs is the same, i would like it if this program used while loops, and other similar things. here is the c++ code -
#include <iostream>
using namespace std;

int main()
{
        int n = 1000;
        double first = 0;
        double second = 1;
        cout<<first<<"    "<<second<<"    ";

        while (n--)
                {
                        double third = first + second;
                        first = second;
                        second = third;
                        cout<<third<<"    ";
                }
}

so if anyone can "convert" this to python it would be appreciated
This is a rather half-baked thread, since by far the slowest performer will be the output to the display and it is part of the loop. So go back and do your homework!
__________________
I looked it up on the Intergnats!
Dietrich is offline   Reply With Quote
Old Oct 10th, 2006, 12:13 AM   #15
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
what i meant by the big-O for diff. languages is that i don't know what they're doing to achieve that, and it may be different..maybe not. don't see why it WOULD be different, but who knows.
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Oct 10th, 2006, 12:19 AM   #16
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 837
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
I think you can safely assume that any popular programming language will execute a while loop in linear time. You have a valid point, just a poor example.
titaniumdecoy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
500 Ways to Print the Fibonacci Sequence uman Coder's Corner Lounge 19 Aug 25th, 2006 12:48 PM
fibonacci sequence angry_asian C++ 12 Aug 15th, 2006 2:53 AM
First Python Programme: Fibonacci Finder UnKnown X Python 2 Dec 15th, 2005 6:19 PM
Fibonacci lingon Python 8 Apr 29th, 2005 6:22 PM
Help - Execution Sequence anandt4u C++ 23 Apr 8th, 2005 3:46 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:13 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC