Page 125 - Data Structures Handout_Neat
P. 125

linear time   (  ).

                   10.2    Basic Sorting Methods


                       Basic sorting algorithms are the simplest techniques used to arrange data. They are
               easy  to understand  and  implement,  making them  ideal  for  teaching the  fundamentals  of

               algorithm  design.  However,  they  are  not  efficient  for  large  datasets  because  their  time

                                            2
               complexity  is  generally    (   ).  Despite  this  limitation,  they  are  important  because  they
               introduce key concepts such as comparisons, swaps, and iterative improvement.

                       The three most common basic sorting algorithms are Bubble Sort, Selection Sort, and
               Insertion Sort. Each has its own approach to rearranging elements, but all share the same

               quadratic complexity in the worst case.


                         10.2.1  Bubble Sort


                       Bubble Sort repeatedly compares adjacent elements and swaps them if they are in the
               wrong  order.  This  process  continues until the  entire  array  is  sorted.  Although  inefficient,

               Bubble Sort is conceptually simple and helps students understand the mechanics of sorting.

                       Example: Bubble Sort in C++








































                                                            125
   120   121   122   123   124   125   126   127   128   129   130