naxprofessionals.blogg.se

Theory 11 playing cards
Theory 11 playing cards








theory 11 playing cards

Insertion sort takes maximum time to sort if elements are sorted in reverse order. Finally, the array is completely sorted.Īuxiliary Space: O(1) What are the Boundary Cases of the Insertion Sort algorithm?.Here, also swapping makes 11 and 6 unsorted hence, swap again.Now, 6 is smaller than 12, hence, swap again.Clearly, they are not sorted, thus perform swap between both.Moving to the next two elements 13 and 6.Now, the elements which are present in the sorted sub-array are 5, 11 and 12.Here, again 11 and 5 are not sorted, hence swap again.After swapping, elements 12 and 5 are not sorted, thus swap again.Both 5 and 13 are not present at their correct place so swap them.Moving forward to the next two elements which are 13 and 5.Now, two elements are present in the sorted sub-array which are 11 and 12.12 also stored in a sorted sub-array along with 11

theory 11 playing cards

  • Here, 13 is greater than 12, thus both elements seems to be in ascending order, hence, no swapping will occur.
  • Now, move to the next two elements and compare them.
  • So, for now 11 is stored in a sorted sub-array.
  • Here, 12 is greater than 11 hence they are not in the ascending order and 12 is not at its correct position.
  • Initially, the first two elements of the array are compared in insertion sort.
  • theory 11 playing cards theory 11 playing cards

    it is appropriate for data sets which are already partially sorted.Ĭonsider an example: arr: 12

  • Insertion sort is adaptive in nature, i.e.
  • Basically, Insertion sort is efficient for small data values.
  • This algorithm is one of the simplest algorithm with simple implementation.
  • Values from the unsorted part are picked and placed at the correct position in the sorted part. The array is virtually split into a sorted and an unsorted part. Insertion sort is a simple sorting algorithm that works similar to the way you sort playing cards in your hands.
  • ISRO CS Syllabus for Scientist/Engineer Exam.
  • ISRO CS Original Papers and Official Keys.
  • GATE CS Original Papers and Official Keys.









  • Theory 11 playing cards