FAQ: Asymptotic Notation: Conceptual - Big Theta (Θ)

This community-built FAQ covers the “Big Theta (Θ)” exercise from the lesson “Asymptotic Notation: Conceptual”.

Paths and Courses
This exercise can be found in the following Codecademy content:

FAQs on the exercise Big Theta (Θ)

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hi there,

In the video he say that 1 divided by 2 is equal to zero but I couldn’t figure out why. I didn’t understand what he said.

Would love a clarification.

Thanks.

2 Likes

I think that this is because N is an integer, and not a float. Since 1/2 is 0.5, we could say that this is equal to 0.

Yea, doesn’t make sense to me either. The explanation is not good.

1 Like

The video mentions that because the number is an integer, when divided it’s equal to zero (because the result is 0.5)

In Python, if you devide 2 integers you will get an integer out of it. And it will always be rounded down. So for example even if you get 0.999 out of a division of 2 integers, the output would be 0

I wrote this code:

def function(n):
    count = 0
    while n/2 != 0:
        count += 1
        n = n / 2
    return print(count)

function(2)

to try out the logic behind the exercise and for some reason the print output would give me a value of 1075.
so I guess the logic that whenever you divide 2 integers will give out a integer back makes no sense to me.
so to fix this problem I tried instead:

def function(n):
    count = 0
    while int(n/2) != 0:
        count += 1
        n = n / 2
    return print(count)

function(2)

only after adding int() in the while statement i could get 1 as a value to be returned… this is a very confusing topic.

why would i need to specify int() in the while statement?
and why would it work without changing the n = n / 2 inside the while loop?

This may be because the course may have been written for Python 2 rather than Python 3 (not completely sure though). In Python 2, the division operator / would always return an integer because it did floor division. In Python 3, / will return a decimal if applicable. You can use // for floor division in Python 3 if you’d like.

Can you post a link to this exercise or explain what the goal of this function is?

2 Likes

https://www.codecademy.com/paths/computer-science/tracks/cspath-asymptotic-notation/modules/cspath-asymptotic-notation/lessons/asymptotic-notation-conceptual/exercises/big-theta

By the time i am writing you this Ive noticed I made a mistake while writing the function, it was supposed to be this instead:

def function(n):
    count = 0
    while n != 1:
        count += 1
        n = n / 2
    return print(count)

function(2)
            

but the fact that I wasn’t getting a integer dividing 2 integer in my previous code was happening… =D
Thank you, for your explanation about the python 2 thing ^^

actually…I did not made a mistake on my first post.
The function I wrote there was based on the video not the exercise… (I got confused when I went to look up for the lesson since you asked for the link.)

in the video he does express that function I wrote and I still get the same troubles as before if I do not declare int(n/2) in the while loop

I am quite confused to everything since this is a very complicated topic and I feel like the fact this may be written for python 2 makes me more confused, I am sorry for the double post and all the confusion.

Since I started to learn Python, I meet more and more troubles about Python versions mismatch. I think it is a good habit to put at the beginning of your script which version of Python was used as a comment.

1 Like

Hi, thank you for the explanation. I have a question. When the instructor says “lower bounded power of 2” what does he mean?
What boundary is implied here? Could you please explain?