My Math Forum  

Go Back   My Math Forum > Science Forums > Computer Science

Computer Science Computer Science Forum


Reply
 
LinkBack Thread Tools Display Modes
August 31st, 2010, 02:55 AM   #1
Member
 
Joined: Aug 2008

Posts: 44
Thanks: 0

Big O complexity

Please, help me correct (if necessary) and complement my "solutions".
Expressions can't be simplified, that is, you can not change into .
  • recursive
    Code:
    int RECURSION(int n, int m){
         if (m > 1) 
         {
             for (int i = 0; i < n; i++)
             {
                 return RECURSION(n, m-1);
             }
         }
    [/*:m:3bzix122]
  • iterative (Should be done by using stack, but how exactly?)
    [/*:m:3bzix122]
  • iterative
    Code:
    int counter = n;
    int factorial = 1; // Will store the final result n!
    while (counter > 1)
    {
        factorial *= counter--;
    }
    [/*:m:3bzix122]
  • recursive
    Code:
    int RECURSION(int n)
    {
        int factorial;
        if (n > 1)
            return ( factorial * RECURSION(n-1) );
        else
            return 1;
    }
    [/*:m:3bzix122]

  • Code:
    for (int i = sqrt(n)/m; i > 0; i /= 10) // Assume 10-base logarithm.
    One "for" loop is not allowed, so how should above one-liner be rewritten?[/*:m:3bzix122]
courteous is offline  
 
Reply

  My Math Forum > Science Forums > Computer Science

Tags
big, complexity



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Computational Complexity rhymin Computer Science 3 March 29th, 2013 04:39 PM
Rhythmic complexity dwnielsen Number Theory 2 February 26th, 2013 09:19 PM
complexity of this function stribor Computer Science 3 January 24th, 2013 12:32 AM
O(sin n), ?(sin n), ?(sin n) complexity ulita Computer Science 2 August 18th, 2010 07:56 AM
Complexity of Problem UnOriginal Applied Math 2 August 26th, 2009 08:05 AM





Copyright © 2017 My Math Forum. All rights reserved.