You are given the following class definition for an array-based List ADT: public abstract class List { protected int[] m_array; protected int m_index; 1 public List (int cap) ( 1 m_array = new int[cap]; m index - public abstract int sum(); // underlying array // index of the next open slot in Follow the steps below to create a concrete class EnhancedList with required instance variables and methods. 1. Make sure that the EnhancedList class inherits from List. 2. Declare two private instance variables: int m low and int m high which are used in one of the methods you are required to implement. 3. Create a constructor that takes two parameters int cap, int low, and int high. 4. The constructor should call the constructor of the super class and initialize the instance variable properly. 5. Create a void method rectify() that verifies if each element is with the range of [m_low, m_high]. If any element is smaller than =_low, change its value to m_low. Similarly, if any element is greater than m_high, change its value to m high. 6. Override the sum method so it computes and returns the sum of the elements on the list. Note: Don't forget to add the @Override keyword!
Types of Linked List
A sequence of data elements connected through links is called a linked list (LL). The elements of a linked list are nodes containing data and a reference to the next node in the list. In a linked list, the elements are stored in a non-contiguous manner and the linear order in maintained by means of a pointer associated with each node in the list which is used to point to the subsequent node in the list.
Linked List
When a set of items is organized sequentially, it is termed as list. Linked list is a list whose order is given by links from one item to the next. It contains a link to the structure containing the next item so we can say that it is a completely different way to represent a list. In linked list, each structure of the list is known as node and it consists of two fields (one for containing the item and other one is for containing the next item address).
![You are given the following class definition for an array-based List ADT:
public abstract class List
protected int[] m_array;
protected int m_index;
1
public List (int cap) (
m array new int[cap];
m index
1
public abstract int sum();
// underlying array
// index of the next open slot in
Follow the steps below to create a concrete class EnhancedList with required
instance variables and methods.
1. Make sure that the EnhancedList class inherits from List.
2. Declare two private instance variables: int m low and int n high which
are used in one of the methods you are required to implement.
3. Create a constructor that takes two parameters int cap, int low, and int
high.
4. The constructor should call the constructor of the super class and initialize the
instance variable properly.
5. Create a void method rectify() that verifies if each element is with the
range of [m low, m highl. If any element is smaller than - low, change its
value tom low. Similarly, if any element is greater than m high, change its
value to high.
6. Override the sum method so it computes and returns the sum of the elements
on the list. Note: Don't forget to add the goverride keyword.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F81b6da2a-e61d-472a-91fc-b3d7b7d9a7e0%2F5d4ba70b-cff8-4d95-aa30-62812fe213ca%2F3ovngl_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)