0

Why do we use circular array concept for implementation of queue using array

1st Sep 2019, 6:24 PM
Nikhil Tale
Nikhil Tale - avatar
5 Réponses
0
do mean why or how?
1st Sep 2019, 6:25 PM
rodwynnejones
rodwynnejones - avatar
0
Why because I know how we do this thing rear = capacity - 1 and then insert element at (real +1%capacity)
1st Sep 2019, 6:28 PM
Nikhil Tale
Nikhil Tale - avatar
0
to access the last element, if u don't know it's current size/ length. (if I understand your question correctly)
1st Sep 2019, 7:40 PM
rodwynnejones
rodwynnejones - avatar
0
Yes, we do this. So we can use our normal concept when we use normal queue
2nd Sep 2019, 4:47 PM
Nikhil Tale
Nikhil Tale - avatar
0
?? if it's 'circular' then it can't have a 'rear', so how can you "insert element at (real +1%capacity)" Are talking about deque?...it does have a 'rotate' method which I suppose could be used as a circular array. Is there an actual container "queue" in python as you can implement it using deque with appropriate method. I'm sure thats why there's no 'stack' as you can just use append() and pop() with 'list'?
2nd Sep 2019, 10:28 PM
rodwynnejones
rodwynnejones - avatar