๐ ูู ุงุฐุง ููุชู ุจุฒู ู ุงูุชูููุฐ ูุงุณุชููุงู ุงูุฐุงูุฑุฉุ
This topic will accompany us throughout our programming career. When writing a program, itโs important to know if itโs fast and efficient. Therefore, we analyze:
Nowadays, we tend to focus more on execution time than memory usage, because modern hardware provides much more memory and processing power than before.
ูุฐุง ุงูู ูุถูุน ุณูู ูุฑุงูููุง ุทูุงู ุญูุงุชูุง ุงูุจุฑู ุฌูุฉุ ุนูุฏู ุง ููุชุจ ุจุฑูุงู ุฌุ ู ู ุงูู ูู ุฃู ูุนุฑู ุฅู ูุงู ุณุฑูุนูุง ูุฐู ุฃุฏุงุก ุนุงูู. ูุฐูู ูููู ุจุชุญููู:
ูู ุงูููุช ุงูุญุงูู ุฃุตุจุญ ุชุฑููุฒูุง ุบุงูุจูุง ุนูู ุงูุฒู ู ุฃูุซุฑ ู ู ุงูู ุณุงุญุฉุ ุจุณุจุจ ุงูุชุทูุฑ ุงููุจูุฑ ูู ูุฏุฑุงุช ุงูุฃุฌูุฒุฉ ู ู ุญูุซ ุงูุฐุงูุฑุฉ ูุณุฑุนุฉ ุงูู ุนุงูุฌุฉ ู ูุงุฑูุฉ ุจุงูู ุงุถู.
Assume we are searching for an element in an array, surely there will be an algorithm that performs the search operation. We may be lucky by finding the element at the beginning of the array, and this is called the best case.
If the element exists but happens to be located at the end of the array, this situation is called the worst case, because the algorithm needs to scan all elements before finding the target.
Sometimes, the element may be found somewhere in the middle of the array or may not exist at all; in such cases, we often refer to the average case, which represents the typical behavior of the algorithm for random inputs.
๐ ุชุนููุฏ ุงูุฒู ู ู Big O Notation
To determine which case we are currently facing (best, worst, or average), we need to understand Time Complexity.