Skip to content
Advertisement

printing elements of circular queue in python

I am not understanding what this part of code (to print elements of circular queue) is doing and how?

JavaScript

at function printCQueue . why tail needs to go self.tail +1 , why it goes where head is? , how it doesn’t print same value twice (head)

Full code:

JavaScript

Advertisement

Answer

for range function in python ie range(start, end, step=1) here end part is exclusive. ie it doesn’t count.

example: list(range(1, 5)) will give [1,2,3,4] here ned which is 5 is not included in final list.

So to include self.tail we have to give +1 so. self.tail become inclusive.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement