1 Replies - 901 Views - Last Post: 18 October 2010 - 05:49 AM

#1 derycklong   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-October 10

Examples of O(N!)

Posted 18 October 2010 - 04:42 AM

Hi, i have this homework which requires me to write a code with reference to O(N!) time complexity.

I have seen O(N^2), O(LOGN) but not with factorial.
Any advice? Please dont hook me up with tutorials with only n^2,n,1,logn only because i already googled all of them.

      
 public void run(int n) {
      for(int i=1; i<=n; i++) {
            run(n-1);
      }
}


Gave this to the automarker but it never went through.

This post has been edited by derycklong: 18 October 2010 - 04:43 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Examples of O(N!)

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Examples of O(N!)

Posted 18 October 2010 - 05:49 AM

Permutation generation algorithms run in O(n!). Try writing an algorithm to generate all the possible permutations given an array of characters.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1