Deque (double-ended queue)
Në shqip: Radha me dy skaje
ShpjegimiSQ
Deque është radhë ku shton dhe heq shpejt nga të dyja skajet. Përdoret për BFS, për dritare rrëshqitëse (maksimumi në dritare) dhe për histori „para/pas“.
EnglishEN
A deque is a queue where you add and remove quickly at both ends. Used for BFS, sliding windows (maximum in a window) and back/forward history.
Si ta mendosh
Si një tub ku mund të futësh e nxjerrësh topa nga të dyja anët.
Lexoje në anglisht
Like a tube you can push balls into and pull them out of from both ends.
Shembull kodipython
from collections import deque
d = deque([2, 3])
d.appendleft(1); d.append(4) # [1, 2, 3, 4]