Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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;

}

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9203117

Have any Question?


Related Questions in Computer Engineering

Question in relational algebra is the set difference

Question : In relational algebra: is the set difference commutative or not and Why? What is the difference between multivalued and composite attribute? Explain with Example.

The chancellor of a university has commissioned a team to

The Chancellor of a university has commissioned a team to collect data on students' GPAs (M = 3.0; SD = 0.5) and the amount of time they spend bar hopping every week (measured in minutes: M = 720; SD = 240). They find a ...

Question suppose we have a disk with capacity 98304 gb if

Question : Suppose we have a disk with capacity 98.304 GB, if number of platters 16, an average of 300 sectors per track and 20,000 tracks per surface. Then calculate the number of bytes per sector.

Question will services follow the trend of manufacturing in

Question : Will services follow the trend of manufacturing in being outsourced and offshored from industrial countries to developing countries? Are all services at risk of being offshored? The response must be typed, sin ...

What are the minimum and maximum values in decimal if an

What are the minimum and maximum values (in decimal) if an 8-bit binary number is given unsigned and two's complement formats?

Question suppose users share a 2 mbps link also suppose

Question : Suppose users share a 2 Mbps link. Also suppose each user transmits continuously at 1 Mbps when transmitting, but each user transmits only 20 percent of the time. When a circuit switching is used, how many use ...

Question read the following topic then explain where a

Question: Read the following topic then explain Where a datagram can be fragmented? Where the fragmented datagram can be reassembled? Fragmentation of Datagram Packets used by the IP are called datagrams. For a networks ...

What is the difference between hardware and softwarewhat is

What is the difference between hardware and software? What is the difference between software and data? How is application software different from an operating system?

Social networking sites such as myspace and facebook pose

Social networking sites such as MySpace and Facebook pose interesting new questions for privacy protection. Describe how privacy may be threatened by the use of these sites. Are these problems significant? How should pri ...

Describe 2 variables a government will look at to predict

Describe 2 variables a government will look at to predict where the economy will be in the next six months.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As