Build a program to implement the selection sort algorithm

Assignment Help Computer Engineering
Reference no: EM1327747

1. Draw the decision tree for the insertion sort algorithm for the following array of names: [Mickey, Minnie, Donald, Goofy].

2. Create a program to implement the selection sort algorithm, which will sort a list of strings. Selection sort function should sort the list of strings in alphabetical order. You only need to provide the details for the selectionSort() function based on the given framework.

#include < iostream >
#include < string >
#include < stdlib.h >

using namespace std;
void selectionSort(string items[], int numberOfItems)
{
//
// Hints:
// (1) You will need two for loops.
//
// (2) Use the strcmp() function in your if-statement
// to determine when one string is less than another.
// You will need to call this function with the c_str()
// method. For example:
// strcmp(items[i].c_str(), items[j].c_str());
//
// (3) You will need a temporary string when swapping
// the two strings.
//
return;
}

// Print the items in the list.
void printItems(string items[], int numberOfItems)
{
for (int i=0; i < numberOfItems; i++)
{
cout << items[i] << endl;
}
cout << endl;
return;
}

int main(int argc, char **argv)
{
string starTrekCharacters[] = {
"Picard", "Riker", "Data", "La Forge", "Worf", "Dr. Crusher",
"Dr. Pulaski", "Wesley", "Troi", "Tasha", "Sisko", "Odo",
"Dax", "O'Brien", "Quark", "Dr. Bashier", "Kira", "B'Elanna",
"Chakotay", "Janeway", "Neelix", "Seven of Nine", "Tuvok",
"Doctor", "Harry", "Tom", "Kes", "Archer", "T'Pol", "Tucker",
"Reed", "Travis", "Hoshi", "Dr. Phlox", "Kirk", "Spock",
"Bones", "Scotty", "Chekov", "Uhura", "Sulu", "Nurse Chapel"
};

int numberOfCharacters = 41;

// Print the unsorted items

cout << "Items unsorted:" << endl;

printItems(starTrekCharacters, numberOfCharacters);

// Sort the items

selectionSort(starTrekCharacters, numberOfCharacters);

// Print the sorted items

cout << "Items sorted:" << endl;

printItems(starTrekCharacters, numberOfCharacters);

return 0;

}

Reference no: EM1327747

Questions Cloud

Exercises which can improve student learning : What are some activities and exercises that can improve a student's learning in this area? What are the current and future applications and revelance to the workplace?
Who should lead the migration plan from an existing process : Leading Departmental Change - What should be included in the term "systems" as related to the department? Does the term include people? Explain.
Application and implication of laws : Explain the application and implication of the following laws for your employer. Be sure to analyze (but is not limited to) the following employee safety, health.
Four most important ways a firm''s international strategy : What are the four most important ways a firm's international strategy can be related to its competitive advantage?
Build a program to implement the selection sort algorithm : build a program to implement the selection sort algorithm, which will sort a list of strings. Selection sort function should sort the list of strings in alphabetical order. You only need to provide the details for the selectionSort() function base..
Suppose demand for abc product has an elasticity coefficient : Suppose the demand for ABC product has an elasticity coefficient. Explain how many it will sell per month if the price
Steps-restore organizational growth-halt decline by leaders : What steps can organizational leaders take to halt decline and restore organizational growth?
Explain external and internal factors analysis - nestle : Explain External and Internal Factors Analysis - Nestle and using your research findings from the Library and the Internet
Show the common business practices : Common Business Practices - Human resources needs to be able to track employees from recruitment to retirement, including roles, salary, compensation, benefits selected, annual reviews, competencies, skills and training taken.

Reviews

Write a Review

Computer Engineering Questions & Answers

  What are pros and cons of society''s increasing reliance data

What are pros and cons of society's increasing reliance data

  Risk assessment of ict system

Risk Assessment of ICT System and Developing Computer Incident Response System on WAMP platform

  Describes a function named insidecircle

Describes a function named insideCircle

  Create an xml document containing information

Create an XML document containing information.

  Write down an sql statement

Write down an SQL statement

  Determining the output

Specify the output if input is diamond diamond? State the output if the input is diamond gold?

  Give the type of clip art found at the sites

search on the Internet for at least 2 additional sites other than Microsoft's that offer clip art, either free or for a price. If you have real-life or professional experience with clip art sites.

  Wordpad application

Whenever you select the print from WordPad application. Which printer among the three starts to print? Why? Explain is it possible to state which printer to print from the WordPad or any other application? Explain why?

  Implementing the java application

Write down a Java application which enables a user to enter 10 numbers (double precision) into an array and then sorts and shows the numbers from lowest to highest.

  Explain the concept of scalability to the team

The project leader wants you to explain the concept of scalability to team. How would you do that? Several managers on the team have heard of TCO but are not quite sure what it is. How would you explain it to them.

  Explain fast process of distributing the cards to accountant

Explain fast process of distributing the cards to accountant.

  Distributed database

A distributed database is also termed as the Replicated Virtualized Rendered Concatenated database.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd