accordingly. The function should return the removed element (12 in the previous example). If the list...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
accordingly. The function should return the removed element (12 in the previous example). If the list is empty, throw an exception. g. (5 pts) Write removeMin function that does not accept any parameter and removes the last element from the list. For instance, if the elements are [12, 9, 7, 5, 5, 3], the list elements will be [12, 9, 7, 5, 5] after calling removeMin function. You should only decrease the size (mySize) by one in this function. The function should return the removed element (3 in the previous example). If the list is empty, throw an exception. h. (5 pts) Write a function named display to print the elements in the list separated by a comma. E.g., [13,11,8,9,12]. Note that you should not print all array content, you should print the elements in the list. For instance, when you create an integer list with capacity 100, myArray will contain 100 zeros, but you should not display them. Therefore, you should iterate your loop from 0 to mySize-1. The function should return nothing. i. (5 pts) Write a function named at that accepts an integer parameter index and returns the element at the given index. If there is no element at that index, throw an exception. An example driver class (MyListDriver.cpp) and its output are given below. #include #include "MyList.h" using namespace std; int main() { } MyList a(3); MyList b(-10); cout < < "Size of a: < < a.getSize() < < endl; 11 cout < < "Capacity of a: < < a.getCapacity() < < endl; cout < < "Size of b: " < < b.getSize() < < endl; cout < < "Capacity of b: " < < b.getCapacity () < < endl; a.add(9); a.display(); a.add (2); a.display(); a.add(4); a.display(); a.add (3); a.display(); a.add(5); a.display(); a.add (1); a.display(); a.add(4); a.display(); a.add(10); a.display(); W 11 cout < < "a.getMin(): < < a.getMin() < < endl; cout < < "a.getMax(): < < a.getMax() < < < endl; cout < < "a.at(1): < < a.at(1) < < endl; cout < < "a.removeMin(): < < a.removeMin() < accordingly. The function should return the removed element (12 in the previous example). If the list is empty, throw an exception. g. (5 pts) Write removeMin function that does not accept any parameter and removes the last element from the list. For instance, if the elements are [12, 9, 7, 5, 5, 3], the list elements will be [12, 9, 7, 5, 5] after calling removeMin function. You should only decrease the size (mySize) by one in this function. The function should return the removed element (3 in the previous example). If the list is empty, throw an exception. h. (5 pts) Write a function named display to print the elements in the list separated by a comma. E.g., [13,11,8,9,12]. Note that you should not print all array content, you should print the elements in the list. For instance, when you create an integer list with capacity 100, myArray will contain 100 zeros, but you should not display them. Therefore, you should iterate your loop from 0 to mySize-1. The function should return nothing. i. (5 pts) Write a function named at that accepts an integer parameter index and returns the element at the given index. If there is no element at that index, throw an exception. An example driver class (MyListDriver.cpp) and its output are given below. #include #include "MyList.h" using namespace std; int main() { } MyList a(3); MyList b(-10); cout < < "Size of a: < < a.getSize() < < endl; 11 cout < < "Capacity of a: < < a.getCapacity() < < endl; cout < < "Size of b: " < < b.getSize() < < endl; cout < < "Capacity of b: " < < b.getCapacity () < < endl; a.add(9); a.display(); a.add (2); a.display(); a.add(4); a.display(); a.add (3); a.display(); a.add(5); a.display(); a.add (1); a.display(); a.add(4); a.display(); a.add(10); a.display(); W 11 cout < < "a.getMin(): < < a.getMin() < < endl; cout < < "a.getMax(): < < a.getMax() < < < endl; cout < < "a.at(1): < < a.at(1) < < endl; cout < < "a.removeMin(): < < a.removeMin() <
Expert Answer:
Answer rating: 100% (QA)
template typename T T MyList T removeMin if mySize 0 throw stdruntimeerrorList is empt... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Fitzpatrick Novelties, an edgy producer of sportswear, has been experiencing a period of tremendous growth.Fitzpatrick does not currently pay any dividends, preferring instead to reinvest all...
-
A US corporation borrows Swiss francs for 1 year at 8%. For the next year, the Swiss franc is anticipated to fall by 6% against the dollar. What is the loan's effective interest rate?* A US company...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
.How dependent do you think the success of zero-based budgeting would be on the types of attribution models used? How might you increase the odds of success in this budgeting approach? .Advertising,...
-
Suppose nature were entirely different so that an infinite number of photons would be needed to make up even the tiniest amount of radiant energy, the wavelength of material particles was zero, light...
-
The interest rate paid by the European Central Bank (ECB) on excess reserves declined below zero in 2014 (and remained there as of 2019). What was the rationale behind this move to a negative deposit...
-
James is mixing soil for a raised garden, in which he plans to grow a variety of vegetables. For the soil to be suitable, he determines that \(\frac{2}{5}\) of the soil can be topsoil, but...
-
The budget director of Gold Medal Athletic Co., with the assistance of the controller, treasurer, production manager, and sales manager, has gathered the following data for use in developing the...
-
pls provide as wers and steps The Regal Cycle Company manufactures three types of bicycles-a dirt bike, a mountain bike, and a racing bike. Data on sales and expenses for the past quarter follow:...
-
Read the case XYZ Company: An Integrated Capital Budgeting Instructional Case and answer the following question: Should the replacement asset be purchased? That is, does it make economic (financial)...
-
Make a presentation about Web Site Security: Automating customized attacks
-
Suppose you are short 21 futures contracts of Silver (contract size = 5000 oz.) The futures price is 21.05 per ounce. The initial margin is:$9,900 per contract, the maintenance margin is $9,000 per...
-
What do you know about the monetary policy of our country(India)? According to you what are steps the central bank has taken till now to control and activate the economy in the current pandemic?
-
The stockholders' equity accounts of Monty Corp. on January 1, 2025, were as follows. Preferred Stock (7%, $100 par noncumulative, 11,500 shares authorized) $690,000 Common Stock ($4 stated value,...
-
Discuss what credit risk means for a commercial bank and how its addresses and manages it. Give an example of credit risk which a commercial bank faces.
-
Explain how Private Equity and Venture capital would perform in market upturns and market downturns.
-
Barbara, who is single, is an architect and operates her business as a sole proprietorship. Her net earnings from self-employment are $318,000. Assume that she has no other income. Calculate...
-
One study found that the elderly who do not have children dissave at about the same rate as the elderly who do have children. What might this finding imply about the reason the elderly do not dissave...
-
Design and write a complete test program to test if the MyLinkedList class in Listing 24.6 meets all requirements. Listing 1 public class MyLinkedList extends MyAbstractlist { private Node head,...
-
Write a method with the following header to format the integer with the specified width. public static String format(int number, int width) The method returns a string for the number with one or more...
-
Write a program that displays the following table: a 1 2 3 4 aA2 1 16 aA3 1 8 27 64
-
The trial balance of Queen and Square Ltd revealed a difference in the books. In order that the error(s) could be located it was decided to prepare purchases and sales ledger control accounts. From...
-
The following extracts have been taken from the subsidiary books of the business owned by D Jenkinson for the month of April 19X0. It should be noted that the balances in the accounts of D Jenkinsons...
-
R Stubbs is a trader who sells all of his goods at 25% above cost. His books give the following information at 31 December 19X9: Show your answer in the form of a trading account. Stock 1 January...
Study smarter with the SolutionInn App