The Big O complelxity of this algorithm? via /r/learnprogramming


The Big O complelxity of this algorithm?

http://ift.tt/2tMwnqi

Hey guys, Im working to get better at understanding Big O notation, and Im trying to figure out the complexity of this algorithm. Its a cartesian product, returning all the permutations of a number of sets, and I've read that this is o(n2) but this algorithm uses three foureach loops, so that would make it O(n3), is that correct?

Im not sure I fully understand how to determine the complexity. Any help would be great, thanks.

Edit: I should note that in the above code, I used a and b as examples, but that might be a,b,c,d,e,f etc etc. The first list can have any number of values, and each nested list will have 2 or more values.

Submitted July 12, 2017 at 09:01AM by Kerbobotat
via reddit http://ift.tt/2sPzi0p

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s