Page 31 - Data Structures Interactive Book
P. 31

3.2   Operations on Arrays


                       Arrays support several basic operations that are essential for manipulating data.


                       3.2.1  Traversal

                       Traversal refers to visiting each element of the array sequentially. This is often done

               using loops.

                       Example:











                       3.2.2  Insertion


                       Insertion involves adding a new element at a specific position. Since arrays have fixed

               size,  insertion  may  require  shifting  elements  to  make  space.  This  operation  has  a  time

               complexity of   (  ).




                       3.2.3  Deletion


                       Deletion removes an element from the array. Like insertion, elements may need to be

               shifted to fill the gap. This also has a time complexity of    (    ).




                       3.2.4  Searching


                       Searching is the process of finding whether a particular element exists in the array.

                       •  Linear search checks each element sequentially (  (  )).

                       •  Binary search works on sorted arrays and reduces complexity to   (      ⁡   ).






                                                             31
   26   27   28   29   30   31   32   33   34   35   36