Implement functions whose prototypes are shown

Assignment Help C/C++ Programming
Reference no: EM131213442

This program involves using STL lists.

For this program you will implement three functions whose prototypes are given below:

list<int>::iterator mxIter(list<int>::iterator first,
list<int>::iterator last);

void selectSort(list<int>& aList);

void writeList(const list<int>& alist);

What you need to do:

You are going to use a static array declared using { 12, 1, 6, 8, 5, 9, 22, 9, 13, 17 } to initialize an STL list, as shown in the slides.

Then you will implement a selection sort (selectSort). A selection sort involves sweeping over the list and finding the maximum element of the list (by calling MxIter) that has not already been sorted, creating a new element at the beginning of the list, setting its value to be the same as the maximum element's value, and then deleting the maximum element (using erase).

Unsorted list: 12 1 6 8 5 9 22 9 13 17
Sorted list: 1 5 6 8 9 9 12 13 17 22

Verified Expert

Brief description of the solution In the following code, we are performing selection sort using the following steps- - Find the maximum element in the list - Insert the element in the beginning - Check if the first element is max, if yes, move the first iterator ahead - Perform the above in a loop for the size of the list - Display the sorted list on the screen.1) Ease of usage of the data structure std::list In the following code, we can see that using 'std::list type makes it very easy for us to perform selection sort. It has readily available functions for inserting and erasing an element, which is a very necessary step performed during sorting.

Reference no: EM131213442

Questions Cloud

Create a flowchart that will contain two modules : Create a flowchart that will contain two modules, one to prompt the user to input the sales amount, and the other to calculate the amount of sales tax on that sales amount.
What is the profit for each dollar used initially : How would you engage in arbitrage to profit from these three rates? What is the profit for each dollar used initially?
Juveniles in criminal court : Given the concerns raised about juveniles being tried in criminal court, should this practice continue? Why or why not? As appropriate, cite the online course, the textbook, and other credible, scholarly sources to substantiate the points you are m..
What are the effects of each of given exchange rate : The spot exchange rate between the dollar and the Swiss franc is a floating, or flexible, rate. - What are the effects of each of the given on this exchange rate?
Implement functions whose prototypes are shown : Implement three functions whose prototypes are given below - element of the list (by calling MxIter) that has not already been sorted, creating a new element at the beginning of the list, setting its value to be the same as the maximum element's va..
Discuss stable versus unstable ones : A sorting algorithm is stable if elements with equal keys are left in the same order as they occur in the input. Look at the sorting algorithms presented in this chapter. Discuss stable versus unstable ones.
What is the most successful child-rearing style : Define public policy and discuss how Americans fare on key measures of childhood health and well-being and policies for the elderly. Then explain how both affluence and poverty can negatively affect development.
What intervention is necessary by the monetary authorities : What intervention is necessary by the monetary authorities to defend the fixed rate if the change shifts the intersection of private supply and demand outside the band?
Trade-offs between system scalability : Explain the trade-offs between system scalability and system transparency you may encounter when designing a large-scale system.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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