Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


C++ selection sort and insertion sort

Posted on 2010-08-15
Medium Priority
Last Modified: 2013-11-17
I would like it if someone would check my answers to make sure I am understanding the sorts properly.  Please and thank you.

Consider the array based list of (10, 4, 8, 2, 7) as input for selection sort and insertion sort algorithms in the following questions:

The number of comparisons made by the selection sort is:   3
The number of comparisons made by the insertion sort is:   7
Note that each swap requires 3 moves.  The number of moves made by the selection sort is:   9
The number of moves made by the insertion sort is:   7
Question by:veeaechone
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

jhp333 earned 2000 total points
ID: 33443062
The number of comparison by selection sort is always n(n-1)/2, which is 10 when n=5.

Author Comment

ID: 33450472
Got it!  Thanks for your help!

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question