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

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.



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

1 Expert Approved Answer
Step: 1 Unlock

In some places Node is mentioned but in the problem statement I did not found ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!