FAQ: Asymptotic Notation: Python - Stacks vs. Queues Runtime

This community-built FAQ covers the “Stacks vs. Queues Runtime” exercise from the lesson “Asymptotic Notation: Python”.

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

FAQs on the exercise Stacks vs. Queues Runtime

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, I might just be missing something here (a line I feel I say all too often :sweat_smile:), but I was trying to re-familiarise myself with the queue and stack classes for this exercise and I saw in the dequeue method that if the queue is of size 1, self.head and self.tail get set to None but self.size is NOT reduced by 1 to 0 even though the queue is empty. Won’t this cause problems if you try to enqueue to the same queue later as the helper function .is_empty() (used in the enqueue method) returns True or False on self.size == 0 ?

I did first_value_added_to_stack = [my_stack.pop() for each in range(my_stack.size)][-1]. Is it what it is expected or there is a better way to get it?

I have no problem understanding the math or functions at this point, the issue is that these exercises are presented in a clunky way. For example, I had to change one variable to 1, but it need to be parsed “1” for it to go through. Just a note! I know it’s highlighted as “1” in the explanation, still feels a bit pedantic.

Pedantry is the nature of programming tbh. Computers don’t deal with grey areas or understand that 1 and ‘1’ can mean the same thing sometimes. The checker could definitely be written to accept 1 as a valid answer, but whoever wrote it decided to be explicit and only accept the character ‘1’ and not the number, in order to keep that distinction.