Explain the main idea behind Insertion Sort.

  • Builds the sorted array one element at a time
  • Divides the array into two halves and merges them
  • Selects a pivot and partitions the array
  • Sorts the array in descending order
The main idea behind Insertion Sort is to build the sorted array one element at a time. It starts with the first element and iteratively compares and inserts the current element into its correct position in the already sorted subarray. This process continues until the entire array is sorted.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *