Solved

C++ selection sort and insertion sort

Posted on 2010-08-15
2
878 Views
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
0
Comment
Question by:veeaechone
2 Comments
 
LVL 7

Accepted Solution

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

Author Comment

by:veeaechone
ID: 33450472
Got it!  Thanks for your help!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

856 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