Reference no: EM131213416
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).
Note that you need to keep track of the beginning of the unsorted part of the list. This is straightforward unless the beginning of the unsorted part of list needs to change due the the erasing of the node currently at the beginning of the unsorted part of the list, i.e. you don't need to change this iterator unless it is "pointing" at an element of the list that will be deleted.
The creation of a new node at the front of the list and deletio of a node in the unsorted part of the list occurs n times, where n is the size of the list. Note that in the nth iteration, the smallest element in the original list is moved to the beginning of the sorted list. When the sorting is completed, the list will contain, from left to right, minimum element to maximum element.
The function mxIter is called to find the maximum element in the unsorted part of the list. It returns an iterator that "points" to the maximum element.
The writeList function is used to print out the initial contents of the list and the final contents of the list. The output of the program should be:
Unsorted list: 12 1 6 8 5 9 22 9 13 17
Sorted list: 1 5 6 8 9 9 12 13 17 22
Management characteristics or job characteristic
: Dissertation on "To determine whether it is management characteristics, or job characteristic, that have the greatest influence on engagement in a Liberian insurance company"
|
Networking models used for communications
: Assuming you resolved the beginning of this chapter's modeling activity, how would you compare the following steps taken to design a communications system to the networking models used for communications?
|
Design a voltage divider to provide the approximate
: The number of resistors, their values, and their wattage ratings must be specified. A schematic showing the circuit arrangement and resistor placement must be provided.
|
Determining the binary strings of length
: Prove that for every positive integer n, there exists a set S of binary strings of length n that contains 2n-1strings no two of which differ in only one position. (There are multiple ways to prove this, not all of which involve induction. You need ..
|
Implement a selection sort
: Implement three functions whose prototypes are given - 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.
|
Identify and describe a current issue in american government
: Identify and describe a current issue (this could be a controversy or just an issue of importance) in American Government. Explain in 1-2 pages how one of the modern philosophers we've studied would respond to that issue.
|
What do we know about the mitzvah of giving charity
: What is the source for the Mitzvah of Giving Charity in Jewish Tradition? Based on this week's lecture, what do we know about the Mitzvah of Giving Charity? How do we know?
|
What is the capital balance of the remaining three partners
: Assume that the partners share profits and losses 4:3:2:1, respectively. Pnda retires and is paid $305,000 based on the terms of the original partnership agreement. If the bonus method is used, what is the capital balance of the remaining three partn..
|
Rectangular array of numerical values
: A matrix is a rectangular array of numerical values. You can add or multiply two matrices to form a third matrix. You can multiply a matrix by a scalar, and you can transpose a matrix.
|