# Exercise 2 Solved

25.00 \$

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . ` zip` solution files instantly, after Payment

## Description

Exercise 2

• Modify the List class (fileÂ list.hÂ so that it has two more functions, which will allow inserts and removes from anywhere in the linked list. Your functions should be called:insertMiddle
• removeMiddle
```Your functions should have all the same features as the givenÂ insertÂ andÂ removeÂ functions, except that yours each have one extra parameter. The second parameter on each of your functions should be of typeÂ int, representing theÂ positionÂ at which to insert (or delete). Sample calls for a list of integers:  L.insertMiddle(345, 5);	// attempts to insert the value 345
//  as the 5th item in the list

L.removeMiddle(x, 10);	// attempts to delete the 10th item in the
//  list and captures its value into x.
```

ForÂ insertMiddle, if the position number is larger than the number of items in the list, just insert the item at theÂ back. If it’s too small (i.e. 0 or less), insert at theÂ front. ForÂ removeMiddle, return false if the position is invalid (without removing anything).I’ve modified the menu program of Figure 21.5 so that it adds in two more menu options for testing these features. You can use it to test your class: