Question: 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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/07/62d518b42af89_Screenshot20210318172902.png)

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.
Step by Step Solution
3.52 Rating (165 Votes )
There are 3 Steps involved in it
In some places Node is mentioned but in the problem statement I did not found ... View full answer
Get step-by-step solutions from verified subject matter experts
