Task 2: (Basic operations) 20 marks 1. Constructors:(3) a. MyList () Pre-condition: None. Post-condition: This is...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Task 2: (Basic operations) 20 marks 1. Constructors:(3) a. MyList () Pre-condition: None. Post-condition: This is the default constructor of MyList class. This constructor creates an empty list. b. MyList (int[] a) or Myst(a) Pre-condition: Array cannot be empty. Post-condition: This is the default constructor of MyList class. This constructor creates a list from an array. c. MyList (MyList a) or MyList(a) Pre-condition: List cannot be empty. Post-condition: This is the default constructor of MyList class. This constructor creates a list from another list. 2. void showList () or def showList(self) (2) Precondition: None. Postcondition: Outputs the keys of the elements of the order list. If the list is empty, outputs "Empty list". 3. boolean isEmpty () or def isEmpty(self) (1) Pre-condition: None. Post-condition: Returns true if a list is empty. Otherwise, returns false. 4. void clear () or def clear(self) (1) Pre-condition: The list is not empty. Post-condition: Removes all the elements from a list. 5. void insert (Node newElement) or def insert(self, newElement) (3) Pre-condition: None. Post-condition: This method inserts newElement at the tail of the list. If an element with the same key as newElement already exists in the list, then it concludes the key already exists and does not insert the key. 6. void insert (int newElement, int index) or def insert(self, newElement, index) (4) Pre-condition: The list is not empty. Post-condition: This method inserts newElement at the given index of the list. If an element with the same key as newElement value already exists in the list, then it concludes the key already exists and does not insert the key. [You must also check the validity of the index]. 7. Node remove (int deleteKey) or def remove(self, deletekey) (4) Pre-condition: List is not empty. Post-condition: Removes the element from a list that contains the deletekey and returns the deleted key value. Task 2: (Basic operations) 20 marks 1. Constructors:(3) a. MyList () Pre-condition: None. Post-condition: This is the default constructor of MyList class. This constructor creates an empty list. b. MyList (int[] a) or Myst(a) Pre-condition: Array cannot be empty. Post-condition: This is the default constructor of MyList class. This constructor creates a list from an array. c. MyList (MyList a) or MyList(a) Pre-condition: List cannot be empty. Post-condition: This is the default constructor of MyList class. This constructor creates a list from another list. 2. void showList () or def showList(self) (2) Precondition: None. Postcondition: Outputs the keys of the elements of the order list. If the list is empty, outputs "Empty list". 3. boolean isEmpty () or def isEmpty(self) (1) Pre-condition: None. Post-condition: Returns true if a list is empty. Otherwise, returns false. 4. void clear () or def clear(self) (1) Pre-condition: The list is not empty. Post-condition: Removes all the elements from a list. 5. void insert (Node newElement) or def insert(self, newElement) (3) Pre-condition: None. Post-condition: This method inserts newElement at the tail of the list. If an element with the same key as newElement already exists in the list, then it concludes the key already exists and does not insert the key. 6. void insert (int newElement, int index) or def insert(self, newElement, index) (4) Pre-condition: The list is not empty. Post-condition: This method inserts newElement at the given index of the list. If an element with the same key as newElement value already exists in the list, then it concludes the key already exists and does not insert the key. [You must also check the validity of the index]. 7. Node remove (int deleteKey) or def remove(self, deletekey) (4) Pre-condition: List is not empty. Post-condition: Removes the element from a list that contains the deletekey and returns the deleted key value.
Expert Answer:
Answer rating: 100% (QA)
In some places Node is mentioned but in the problem statement I did not found ... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these algorithms questions
-
1. Constructors:(3) a. MyList () Pre-condition: None. Post-condition: This is the default constructor of MyList class. This constructor creates an empty list.
-
Write a method beyondLastEntry(position) for the class OneWayNo-RepeatsList, as given in Listing 7.9, that returns true when position is beyond the last entry on the list. Listing 7.9 /** An object...
-
Revise the class OneWayNoRepeatsList, as given in Listing 7.9, so that it allocates an extra element in the array entry and ignores entry[0], as suggested earlier near the end of the section entitled...
-
Suppose a city finds that its express highways into the city are congested and it is considering two remedies: (1) imposing a congestion charge on all users of its expressways during the peak periods...
-
a. Conduct additional research, and discuss whether pox parties represent a safe method of developing immunity to varicella zoster virus. b. Provide evidence in support of or refuting the following...
-
Thirty new employees were grouped into 15 pairs of similar intelligence and experience and were then instructed in data processing by an old method (A) applied to one (randomly selected) person of...
-
As a kid, Haley Rosen played all the sports but quickly fell in love with soccer. She played soccer through her school years and was skilled at the game. When it was time for college, Stanford...
-
Mason Advertising Agency was founded in January 2008. Presented below are adjusted and unadjusted trial balances as of December 31, 2012. Instructions(a) Journalize the annual adjusting entries that...
-
Part A A string that is 9.6 m long is tied between two posts and plucked. The string produces a wave that has a frequency of 320 Hz and travels with a speed of 192 m/s. How many full wavelengths of...
-
A welding torch is remotely controlled to achieve high accuracy while operating in changing and hazardous environments [21]. A model of the welding arm position control is shown in Figure DP7.4, with...
-
Consider a risky asset with the following string of rates of returns in the previous 5 years. 5 years ago it returned -10%, 4 years ago -20%, 3 years ago 30%, 2 years ago 0%, and 1 year ago 5%. In...
-
An object is placed 11 cm in front of a concave mirror whose focal length is 24 cm. The object is 2.9 cm tall. Please answer the following questions without doing any calculations. Remember to...
-
Prepare an income statement and balance sheet as of December 3 1 , 2 0 1 8 , for the Choi. Co . , from the following information: ( 1 0 points ) : Accounts receivable $ 1 2 0 , 0 0 0 Machinery and...
-
According to Noble INC's balance sheet as of Dec. 2021, the company has $724,000 in Current Assets and $686,000 in Current Liabilities. The company's quick ratio is 0.8. Calculate the company's...
-
A 12.0 kg bucket is lowered vertically by a rope in which there is 180 N of tension at a given instant. Part A Determine the magnitude of the acceleration of the bucket. Express your answer to two...
-
1 Balance of Payment in Taiwan This question helps you understand how to calculate balance of payment (BOP). In this question, domestic country is Taiwan and foreign country is USA. I assume the...
-
Pink, Inc issued 100,000 common shares & 10,000 preferred shares with a $1 cumulative dividend and dividends in arrears for 2019. On December 20, 2020, cash dividends were declared for $300,000 to be...
-
For the following arrangements, discuss whether they are 'in substance' lease transactions, and thus fall under the ambit of IAS 17.
-
What does the Java code Scanner keyboard = new Scanner(System.in); keyboard.useDelimiter("y"); System.out.println("Enter a string."); String a = keyboard.next(); String b = keyboard.next();...
-
Rewrite the Dog class given in Listing 5.1 by utilizing the information and encapsulation principles described in Section 5.2. The new version should include accessor and mutator methods. Also define...
-
Find the documentation for the class Graphics Context in the JavaFX Class Library. (See Exercise 12.) Learn how to use the method strokeRect. Then write statements that can be used in a JavaFx...
-
Identify the sources and discuss the consequences of bank runs, bank panics, and financial crises.
-
Explain why and how the government intervenes in the financial system, and the problems the government safety net creates.
-
In the absence of limits on the behavior of large intermediaries, how might the perception of institutions being too-big-to-fail lead to increased concentration in the banking industry?
Study smarter with the SolutionInn App