Algorithm Analysis (Big Theta)

In summary, the conversation is about determining the theta notation for the runtime of an algorithm. The person has shared a pastebin link containing an algorithm, their trace of the algorithm, and their question. They are considering whether the algorithm runs in n^2 or n lg (n) time, with n^2 being the more likely option. They had some initial confusion about the floor function, but ultimately determined that the algorithm's runtime is closer to n^2 than n lg (n).
  • #1
jhudson1
16
0

Homework Statement


Here is a pastebin link to my question, it contains an algorithm, my trace of the algorithm, and my question.

Homework Equations


I am interested in the theta notation for the runtime of an algorithm

The Attempt at a Solution


Here is the link
http://mathb.in/1202

My thoughts are that the algorithm must run in either n^2 or n lg (n) where lg = log base 2
 
Physics news on Phys.org
  • #2
jhudson1 said:

Homework Statement


Here is a pastebin link to my question, it contains an algorithm, my trace of the algorithm, and my question.


Homework Equations


I am interested in the theta notation for the runtime of an algorithm

The Attempt at a Solution


Here is the link
http://mathb.in/1202

My thoughts are that the algorithm must run in either n^2 or n lg (n) where lg = log base 2

Which of those choices do you think fits better? And why? Think about LARGE n.
 
  • #3
n^2 definitely.

I guess what threw me was the floor function. I wasn't sure if I could multiply through that or not and say n^2/2. Since it seems that you can, 1/2 is clearly scaling the order of the algorithm, which is n^2
 
  • #4
jhudson1 said:
n^2 definitely.

I guess what threw me was the floor function. I wasn't sure if I could multiply through that or not and say n^2/2. Since it seems that you can, 1/2 is clearly scaling the order of the algorithm, which is n^2

Sure. floor(i/2) isn't exactly i/2 but it's pretty close. On the other hand n*log(n) is clearly way off.
 
  • #5
jhudson1 said:
n^2 definitely.

I guess what threw me was the floor function. I wasn't sure if I could multiply through that or not and say n^2/2. Since it seems that you can, 1/2 is clearly scaling the order of the algorithm, which is n^2

Thinking about this a little more, isn't the more accurate estimate (1/4)*n^2? You don't just multiply but it's still basically n^2.
 

FAQ: Algorithm Analysis (Big Theta)

What is Algorithm Analysis (Big Theta)?

Algorithm Analysis (Big Theta) is a method used to evaluate the efficiency and performance of an algorithm. It measures the growth rate of the algorithm's running time as the input size increases.

What is the difference between Big Theta and Big O notation?

Big Theta notation represents the exact growth rate of an algorithm, while Big O notation provides an upper bound on the growth rate. In other words, Big Theta describes the best-case scenario, while Big O describes the worst-case scenario.

How is algorithm analysis helpful in the field of computer science?

Algorithm analysis helps computer scientists evaluate and compare different algorithms to determine which one is the most efficient for a given problem. It also helps in predicting the performance of an algorithm for different input sizes, allowing for optimization and improvement.

What are the three cases in Big Theta notation?

The three cases in Big Theta notation are best-case, worst-case, and average-case. These cases describe the upper and lower bounds of an algorithm's running time for different inputs.

What is the time complexity of an algorithm represented by Big Theta notation?

The time complexity of an algorithm represented by Big Theta notation is the growth rate of the algorithm's running time as the input size increases. It is expressed in terms of the input size (n) and can be used to compare the efficiency of different algorithms.

Back
Top