Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Use the insertion sort to sort the list in Exercise 35, showing the list obtained at each step.

Short Answer

Expert verified

The sorted list using insertion sort is a,b,d,f,k,m.

Step by step solution

01

Step 1

We have to sort the list d,f,k,m,a,b using insertion sort Begin with comparing first and second letter in the list d,f,k,m,a,b

No interchange required

Now the list becomes d,f,k,m,a,b.

02

Step 2

Now we will compare third letter with first and second letter (comparing ‘k’ with d,f)

no interchange required

Now the list becomes d,f,k,m,a,b.

03

Step 3

Now we will compare fourth letter with first, second, third letters (comparing ‘m’ with d,f,k) no interchange required.

Now the list becomes d,f,k,m,a,b.

04

Step 4

Now we will compare fifth letter with first, second, third, fourth letters (comparing ‘a’ with d,f,k,m) So ‘a’ will be inserted before ‘d’.

Now the list becomes a,d,f,k,m,b.

05

Step 4

Now we will compare fifth letter with first, second, third, fourth letters (comparing ‘b’ with a,d,f,k,m) So ‘b’ will be inserted before ‘d’.

Now the list becomes a,b,d,f,k,m,.

06

Final answer                                                                                                                        

The sorted list using insertion sort is a,b,d,f,k,m.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Study anywhere. Anytime. Across all devices.

Sign-up for free