chap listsstacksand queues array-based list implementation there are two standard approaches to implementing liststhe array-based listand the linked list this section discusses the array-based approach the linked list is presented in section time and space efficiency comparisons for the two are discussed in section figure shows the array-based list implementationnamed alist alist inherits from abstract class list and so must implement all of the member functions of list class alist' private portion contains the data members for the array-based list these include listarraythe array which holds the list elements because listarray must be allocated at some fixed sizethe size of the array must be known when the list object is created note that an optional parameter is declared for the alist constructor with this parameterthe user can indicate the maximum number of elements permitted in the list if no parameter is giventhen it takes the value defaultsizewhich is assumed to be suitably defined constant value because each list can have differently sized arrayeach list must remember its maximum permitted size data member maxsize serves this purpose at any given time the list actually holds some number of elements that can be less than the maximum allowed by the array this value is stored in listsize data member curr stores the current position because listarraymaxsizelistsizeand curr are all declared to be privatethey may only be accessed by methods of class alist class alist stores the list elements in contiguous array positions array positions correspond to list positions in other wordsthe element at position in the list is stored at array cell the head of the list is always at position this makes random access to any element in the list quite easy given some position in the listthe value of the element in that position can be accessed directly thusaccess to any element using the movetopos method followed by the getvalue method takes th( time because the array-based list implementation is defined to store list elements in contiguous cells of the arraythe insertappendand remove methods must maintain this property inserting or removing elements at the tail of the list is easyand the append operation takes th( time howeverif we wish to insert an element at the head of the listall elements currently in the list must shift one position toward the tail to make roomas illustrated by figure this process takes th(ntime if there are elements already in the list if we wish to insert at position within list of elementsthen elements must shift toward the tail removing an element from the head of the list is similar in that all remaining