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,...
-
List the symmetry elements of the following molecules and name the point groups to which they belong: (a) Staggered CH3CH3, (b) Chair and boat cyclohexane, (c) B, H6, (d) [Co (en) 3J3+, where en is...
-
Given IDSS = 12mA and |Vp| = 6V, Sketch a probable distribution of the characteristic curves for the JFET (similar to Fig. 6.11).
-
As shown in V9.25 and Fig. P9.105, a spoiler (i.e., an upside-down airfoil) is mounted above the rear wheels of a race car to produce negative lift (i.e., downforce), thereby improving tractive...
-
Ed Arnold started a personal financial planning business when he accepted $120,000 cash as advance payment for managing the financial assets of a large estate. Arnold agreed to manage the estate for...
-
A nursing team is having a routine meeting. One of the nurses, Stephen, is at the end of a 12-hour shift, and another nurse, Tanya, is just beginning hers. Tanya is a senior nurse in the unit with...
-
British-based SuperGroup, owner of Superdry and its carefully banded product lines, is taking actions to deal with recent performance problems. These problems manifested themselves in various ways,...
-
You manage a $1,000,000 portfolio for Corner Bank & Trust. Your portfolio analysts tells you that the Expected Return on your portfolio of assets is 6% and the standard deviation is 15%, What is the...
-
To further explore and understand the going green terminology in the supply chain, define and discuss what green supply chain means, why green supply chain is vital, and why organizations should take...
-
Racial diversity in the workforce is only one avenue of diversity. Please describe other avenues of diversity and how they may enrich the workplace. What extra value might those other forms of...
-
Question 2 A 20ft load of Frozen Fish, valued at $100,000, was sold to an American seafood importer on FOB basis. The shipment was to be transported from the supplier in China, to the buyer located...
-
List and briefly describe the components of a financial planning model.
-
If the distance from a constant power source is increased by a factor of 5, by what factor does the intensity change?
-
A train moving with certain speed crosses a person moving at 4 km/hr and another person moving at 6 km/hr in 12 sec and 14 sec respectively. Find the speed of train (if both persons are moving in the...
-
7. FALSE DILEMMA 8. GANDWAGON Definition: Fallacy example: How to revise argument: Definition: Fallacy example: How to revise argument:
-
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
-
Polyethylene bottles are used to contain fluids as various as milk and engine oil. A typical polyethylene bottle weighs about 30 grams and has a wall thickness of about \(0.8 \mathrm{~mm}\). The...
-
This exercise and the next require the use of the CES Edu-Pack Materials Selection software. a. Use CES to select a joining process to meet the following requirements. b. Use CES to select a joining...
-
This exercise, like the last, requires the use of the CES Edu-Pack Materials Selection software. a. Use CES to select a surface-treatment process to meet the following requirements. b. Use CES to...
Study smarter with the SolutionInn App