Create a program to implement the selection sort algorithm

Assignment Help Operating System
Reference no: EM13943731

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: EM13943731

Questions Cloud

Dealing with problems stemming from deals : You are a junior manager in Your Company Limited's (YourCo) Glasgow head office. You are dealing with problems stemming from deals with a good client, Generation Company (GenCo).
Prepare a project proposal on pashmina business in nepal : Define your 1st key word or phrase. Provide strengths and weaknesses from literature about the topic. Provide at least 4 references. Analyse your hypothesis about this topic and discuss your conclusion.
What monthly payment will the taylors be required to make : The Taylors have purchased a $220,000 house. They made an initial down payment of $10,000 and secured a mortgage with interest charged at the rate of 6%/year on the unpaid balance. Interest computations are made at the end of each month. If the loan ..
Assume that an individual makes a down payment : The price of a new car is $40,000. Assume that an individual makes a down payment of 25% toward the purchase of the car and secures financing for the balance at the rate of 9%/year compounded monthly. What monthly payment will she be required to make..
Create a program to implement the selection sort algorithm : Draw the decision tree for the insertion sort algorithm for the following array of names
Overall thermal efficiency on gross c.v. : QUESTION 11 - Steam boiler plant in a petroleum refinery has an overall thermal efficiency on gross C.V . of the fuel of 85 % and an out put of 90720 kg of steam per hour. The steam is produced at a pressure ..
Projects npv is more sensitive to changes in wacc : Project S and L both have an initial cost of $10,000 followed by a series of positive cash inflows. Project S's undiscounted net cash flows total $20,000, while L's total undiscounted flows are $30,000. At a WACC of 10% the two projects have identica..
How would you mitigate against it : Which of the chronic disasters facing the world's population today is likeliest to cause the most harm? How would you mitigate against it?
Reflection on personal learning during module : You are required to submit an individual reflection on your personal learning during this module. Students are expected to include their thoughts and learning from working with others in a group in order to produce the report in addition to reflec..

Reviews

Write a Review

Operating System Questions & Answers

  Implementation of algorithms for process management

The Shortest Job Next (SJN) algorithm queues processes in a way that the ones that use the shortest CPU cycle will be selected for running rst.

  Develop a user mode command interpreter

Develop a user mode command interpreter which support list-short.

  Memory allocation in operating system

Analysis and implementation of algorithms for memory allocation in operating system, Explain First- t and best- t methods are used in memory allocation in operating systems.

  Stand alone child process

Forking the child process

  Write a multi-threaded program

Write a multi-threaded program to solve producer and consumer problem

  Marginal and average cost curves

n a competitive market place (pure competition) is it possible to continually sell your product at a price above the average cost of production.

  Simulating operating systems scheduling

Simulate the long-term scheduler, the short-term scheduler and the I/O scheduler of the computer using the First-Come-First-Serve algorithm.

  Issues with trusted platform module

Research paper discussing the issues with Trusted Platform Module (TPM)

  Threads

Explain a complication that concurrent processing adds to an operating system.

  Design and programming

Use the semaphore methods to control the concurrency of the solution

  Virtual machines

Virtual machines supported by a host operating system

  Discuss an application that benefits barrier synchronization

Discuss an application that would benefit from the use of barrier synchronization

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