Got a little techonology problem that you need fixed pronto? Post it here and we'll see what we can do.
Topic locked

Big Oh Notation

Mon Sep 20, 2004 4:01 pm

I was just about going crazy over my Data Structures and Algorithms homework when I thought mebby I should pay a visit to good old PPT and see if y'all could help me. Guess it's been awhile, since my username didn't exist anymore! Anyhow, we're learning about Big Oh notation, which I should know by now, since I learned about it for the first time three semesters ago. But, I just don't get it. Think any of you could help me on the basics? I know the Big Oh for searches, etc, like a linear search takes O(n), and a binary search takes O(log n), but how do you decide what Big Oh is for a regular snippet of code? It's so confusing!

Thanks, m'dears!

Mon Sep 20, 2004 9:35 pm

When you go through say a for-loop. Go through the loop and figure out what exactly is going on inside, and then determine in your head how many times the index will iterate through the loop.

If you have a nested for-loop iterating the same number of times, the Big-Oh notation would be O(n^2). The loop inside the outer for-loop needs to finish completely before the outer for-loop iterates to the next index.

Tue Sep 21, 2004 7:26 pm

Thanks, that helped a bit, and another comp sci major told me about a book that will help, too! :-)
Topic locked