Question: A1B1 # A1B1.py, for IDSA A1 # Do NOT modify the given part, unless specified # TO BE COMPLETED by Student # FINISHED by: ,

 A1B1 # A1B1.py, for IDSA A1 # Do NOT modify thegiven part, unless specified # TO BE COMPLETED by Student # FINISHEDby: , # Remark: Position index of elements starts from 1 classAList: # defining a class of FIXEDSIZE-Array-List def __init__(self, inSize=3): # constructor,default size = 3 self.pList = [None]*inSize # new a Python List A1B1 to hold data self.last = 0 # The position of the lastelement self.capacity = inSize # The current capacity of the list ######################

# A1B1.py, for IDSA A1 # Do NOT modify the given part, unless specified # TO BE COMPLETED by Student # FINISHED by: ,  # Remark: Position index of elements starts from 1 class AList: # defining a class of FIXEDSIZE-Array-List def __init__(self, inSize=3): # constructor, default size = 3 self.pList = [None]*inSize # new a Python List to hold data self.last = 0 # The position of the last element self.capacity = inSize # The current capacity of the list ###################### STUDNET's WORK ###################### # simple comment HERE def insertL(self, elt, pos): # Insert element, pos start from 1 pass # TO BE DONE BY STUDENT # simple comment HERE def appendL(self, elt): pass # TO BE DONE BY STUDENT # simple comment HERE def searchFirstL(self, elt): pass # TO BE DONE BY STUDENT # simple comment HERE def clearL(self): pass # TO BE DONE BY STUDENT #################### END of STUDNET's WORK ###################### def isEmptyL(self): # Check if the list is empty or not return self.sizeL()==0 def isFullL(self): # Check if the list is full or not return self.sizeL()==self.capacity def sizeL(self): # Return size of List (number of elements) return self.last def displayL(self): print(f">>> AList Display(Head/Left), size/last,", f"capacity:") for i in range(self.sizeL()): # show data values in the list print(f" > {self.pList[i]}", end='') print() def getL(self, pos): # Get & Return element, pos start from 1, # O(1) if self.sizeL()==0: # case of empty list, return None return None elif (posself.last): # case of out of range, return None return None else: return(self.pList[pos-1]) # O(1) pos-1, map to list index def removeL(self, pos): # Remove & Return element, pos start from 1, # O(n) if self.sizeL()==0: # case of empty list, return None return None elif (posself.last): # case of out of range, return None return None else: i = pos-1 removeElt = self.pList[i] while i 
# MA1B1.py, for basic running and testing. # * DO NOT modify this given test file, except the STUDENT INFO part. # Main Testing Program from A1B1 import AList def main(): print("=== A1B1, Fixed-Sized ArrayList, by   === ") myL = AList(5) print(f"--- 0. new AL  isFullL()?:{myL.isFullL()}, isEmptyL()?:{myL.isEmptyL()}") myL.displayL() print(f"--- 1. insertL -R?") myL.insertL('A', 1); myL.insertL('B', 2); myL.insertL('C', 3); myL.insertL('P', 4); myL.insertL('Q', 3); myL.insertL('R', 2); myL.displayL() myL.removeL(4); myL.removeL(4); print(" --- 2. appendL: -H? ") myL.appendL('Q'); myL.appendL('A'); myL.appendL('H'); myL.displayL() print(f" ------ 3.  searchFirstL('Q'), pos:{myL.searchFirstL('Q')}") print(f" --- 3. removeL(myL.searchFirstL('A')), elt:{myL.removeL(myL.searchFirstL('A'))}") myL.displayL() print(f"------  searchFirstL('Q'), pos:{myL.searchFirstL('Q')}") print(f"------  searchFirstL('H'), pos:{myL.searchFirstL('H')}") print(f"------  searchFirstL('QA'), pos:{myL.searchFirstL('QA')}") print(" === Program ends === ") main() Describe in your own words the process of inserting a new element P into position 2 (i.e, elt=P and pos=2) of the following fixed-size array-list (No more than 100 words). Describe the programs response if we try to insert another new element into position 3 of the above list after inserting element P (No more than 100 words). 

ORD UP! GRE ... Develop a Fixed-Size Array-List, with the given Python file A1B1 .py. Students have learnt how the list is implemented with dynamic array (variable-length array) in our course. In this part, students are required to implement a Fixed-Size version of Array-List: - We are not enlarging the list if it is full for adding more elements. Al ist.nv) with imnlemented methods helow: Complete this Fixed-Size Array-List with the Extra Operations below (methods of the class): At least one line of simple comment for each extra operation required Sample console display output of executing the main testing program MA1B1.PY 0. new ALCHECK isFullL()?:False, isEmptyL()?: True -- 1. insertL ABQCPR ? - Failed INSERT AList Display(Head/Left), size/last 5, capacity 5 : >A>B>Q>C>P 2. appendL: ABQ,QAH ? > AList Display(Head/Left), size/last 5, capacity 5 : >A>B>Q>Q>A 3. removel(myl.searchFirstl('A')), elt:A >B>Q>Q>A searchFirstL(' Q '), pos: 2 searchFirstL(' H '), pos:-1 searchFirstL('QA'), pos:-1 === Program ends === N. A1B1.py, for IDSA A1 \# DO NOT modify the given part, unless specified \# TO BE COMPleted by student. \# FIMISHED by: estudent NAMEs, estudent IDs 9H Remank: Position Index of elements starts from 1 class AList: \# defining a class of FIXEOSI2E-Array-List def -init (self, insize =3):# constructor, default size =3. self.plist =[ None] ] insize # nem a Python List to hold data self.last = \# The position of the last element self.capacity = insize \# The current capacity of the list def Insertl(setf, elt, pos): \#f Insert element, pos start from 1 - pass \# TO BE DONE BY STUOENT if 5 Imple comment. HERE det appendl(aelt, elt): pass \# TO BE DONE BY STUOENT. I simple: comment HERE def seapchFirstl(self, elt): pass \# TO BE DONE BY STUDENT F simple comment HERE def clearl(self): PASS \# TO BE DONE BY STUDENT def isemptyL(self): \#Check if the list is empty or not return setf.sizel ()=0 def isfullu(gelt): \# Eneck if the list is full on not return self,sizel ()= self, capacity def sizel(self): I Return size of List (number of elements) cetunn self. Last def displayl (self): print(f") AList Display (Head/Left), size/last { self, Last >, , , focapacityc\{self, capacity }:" ). for i in range(self. sizel ()) : F F show data values in the list print (fn> fself.pList [i]}, ende ) print() def getL(self, pos): \# Get \& Return element, pos start from 1, \# 0(1) If self. sizel ()==0 : \# case of eapty Zist, return None return None elif (pos

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!