Page 24 - Data Structures Interactive Book
P. 24

Chapter 2



                  2.1   Algorithm Efficiency

                       Algorithm  efficiency  refers  to  how  effectively  an  algorithm  uses  computational

               resources such as time and memory. Since different algorithms can solve the same problem

               in  varying  ways,  efficiency  provides  a  framework  for  comparing  them.  A  highly  efficient
               algorithm minimizes execution time and memory usage, making it suitable for large-scale

               applications. Understanding efficiency is crucial in data structures, as the choice of algorithm

               directly impacts performance.


                      2.1.1  Time Complexity


                       Time complexity measures the amount of time an algorithm takes to run as a function

               of  the  input  size.  It  provides  a  theoretical  estimate  of  performance  rather  than  exact

               execution time. For example, searching an element in an unsorted array requires checking

               each element, resulting in a time complexity of   (  ). In contrast, binary search on a sorted

               array reduces the complexity to   (      ⁡   ). Time complexity helps programmers predict how
               algorithms will scale as input size increases.


                      2.1.2  Time Complexity


                       Time complexity measures the amount of time an algorithm takes to run as a function

               of  the  input  size.  It  provides  a  theoretical  estimate  of  performance  rather  than  exact
               execution time. For example, searching an element in an unsorted array requires checking

               each element, resulting in a time complexity of   (  ). In contrast, binary search on a sorted

               array reduces the complexity to   (      ⁡   ). Time complexity helps programmers predict how
               algorithms will scale as input size increases.



                  2.2      Big-O Notation


                       Big-O notation is a mathematical representation used to describe the upper bound of

               an algorithm’s growth rate. It abstracts away machine-specific details and focuses on how
               performance scales with input size. By categorizing algorithms into classes such as constant

                                                             24
   19   20   21   22   23   24   25   26   27   28   29