Choosing the right data structure
Në shqip: Zgjedhja e strukturës së duhur
ShpjegimiSQ
Pyet: çfarë veprimi bëj më shpesh? Gjetje sipas çelësit → hash map; renditje gjithmonë → pemë e balancuar ose heap; shtim/heqje nga skajet → deque; „a ekziston?“ → set; lidhje → graf. Zgjedhja e duhur shpesh ndryshon O(n²) në O(n).
EnglishEN
Ask: what operation do I do most? Lookup by key → hash map; always sorted → balanced tree or heap; add/remove at the ends → deque; “does it exist?” → set; connections → graph. The right choice often turns O(n²) into O(n).
Si ta mendosh
Si të zgjedhësh enën e duhur në kuzhinë: tavë, tenxhere apo tigan.
Lexoje në anglisht
Like picking the right kitchen container: tray, pot or pan.