SlideShare a Scribd company logo
1 of 4
Download to read offline
For easy Ctrl C+Ctrl V, Below is the same code that is described above.
import java.util.Iterator;
/**
* Write a description of class MyArrayList here.
*
* @author (your name)
* @version (a version number or a date)
*/
// Do not modify the given code.
@SuppressWarnings("unchecked") // Given
public class MyArrayList<T> {
private T[] data; // Given
private int size; // Given
/*
Implement. You must provide a comment block!
*/
public MyArrayList(int inCapacity) {
}
/*
Implement. You must provide a comment block!
*/
public boolean isEmpty() { }
/*
Implement. You must provide a comment block!
*/
public boolean add(T obj) {
// This method appends obj toward the back of data
// Always return true
}
/*
Implement. You must provide a comment block!
Implement this method so that a sequence of add operations
executes as efficiently as possible.
*/
private void grow() { }
/*
Implement. You must provide a comment block!
*/
public boolean remove(Object obj) {
// Return true if obj was removed from data
// and false otherwise.
}
/*
The rest of the code is given.
I will use it for testing purposes.
Do not modify!
*/
// Given. Do not provide a comment block!
public String toString() {
if (size == 0)
return "[ ]";
String retStr = "[ ";
for (int i = 0; i < size - 1; i++)
retStr += data[i] + ", ";
retStr += data[size - 1] + " ]";
return retStr;
}
// Given. Do not provide a comment block!
public boolean equals(Object obj) {
if (obj instanceof MyArrayList) {
MyArrayList<T> rhs = (MyArrayList<T>)obj;
if (size != rhs.size)
return false;
for (int i = 0; i < size; i++)
if (!rhs.contains(data[i]))
return false;
return true;
}
return false;
}
// Given. Do not provide a comment block!
private int find(Object obj) {
for (int i = 0; i < size; i++)
if (data[i].equals(obj))
return i;
return -1;
}
// Given. Do not provide a comment block!
public boolean contains(Object obj) {
return find(obj) >= 0;
}
// Given. Do not provide a comment block!
public void addAll(MyArrayList<T> inList) {
for (int i = 0; i < inList.size; i++)
add(inList.data[i]);
}
// Given. Do not provide a comment block!
private class MyArrayListIterator implements Iterator<T> {
private int index = 0;
// Given. Do not provide a comment block!
public void remove() { } // No implementation
// Given. Do not provide a comment block!
public T next() {
T temp = data[index];
index++;
return temp;
}
// Given. Do not provide a comment block!
public boolean hasNext() {
return index < size;
}
}
// Given. Do not provide a comment block!
public Iterator<T> iterator() {
return new MyArrayListIterator();
}
}
troduction: In this lab, you will get some practice implementing certain methods of expandable,
generic MyArrayList data structure and doing an amortized analysis of one the methods thereof.
Basically, in addition to the parameterized constructor, you have implement the operations of
isEmpty, add, grow and remove. Then, you will do a very mple amortized analysis, using empirical
methods, to derive the worst-case running time add when executed in a sequence of several add
operations. ote that there is a lot of "extra" code that is given. Don't modify any of the given code. I
ll need this for testing purposes. etting started: 1. Create a new project in NetBeans called Lab5.
Make sure you uncheck Create Main Class in the New Java Application window. 2. Within the
default package of your Lab5 project, create a new Java class called MyArrayList and use the
following code to get started (the following code is also available for download on Canvas as
MyArrayList. java): import java. util. Iterator; // Given / * Write a description of class MyArrayList
here. * * Qauthor (your name) * @version (a version number or a date) */ // Do not modify the
given code. @SuppressWarnings("unchecked") // Given public class MyArrayList { private T[]
data; // Given private int size; // Given /* Implement. You must provide a comment block! */ public
MyArrayList(int inCapacity) { }/* Implement. You must provide a comment block! */ public boolean
isEmpty() {} /* Implement. You must provide a comment block! */ public boolean add(T obj) { //
This method appends obj toward the back of data // Always return true Implement. You must
provide a comment block! Implement this method so that a sequence of add operations executes
as efficiently as possible. */ private void grow() {} /* Implement. You must provide a comment
block! */ public boolean remove(Object obj) { // Return true if obj was removed from data // and
otherwise. / The rest of the code is given. I will use it for testing purposes. Do not modify! /Follow
the instructions in the Requirements section to see exactly what you have to do for this lab.
Requirements: Ensure that your lab satisfies the following technical requirements: 1. For the first
part, fill in the missing details in the MyArrayList class, as indicated by the comments. It is your
responsibility to ensure that the formatting guidelines are followed. For example, make sure you
have a consistent indentation scheme. The only exception is that you do not have to provide
comment blocks for certain methods. Do not modify any of the given code. 2. In the comment
block for add, give the best possible big- O of the worst-case running time for executing a single
add operations. Briefly justify your answer. 3. Also in the comment block for add, give the best
possible big- O of the total worst-case running time of executing a sequence of N add operations.
Hint: take your previous answer and multiply it by N. Briefly justify your answer. 4. Depending on
what you put for the previous two parts, your answer for the previous step might be a bit too
"pessimistic". In other words, even though the worst-caserunning time of a single add is O(??),
such worst-case behavior does not happen all the time. So, for this final part, compute the worst-
case running time of a single call to add, assumed to be executed during a sequence of N calls to
add. Use empirical methods to derive your answer. For example, compute the total amount of time
it takes to call add N times, and then divide by N and see what you get. Do this for several
increasing values of N and try to spot a pattern. Or, you can count the the number of simple
operations executed across a sequence N add operations and then divide the total by N. In the
comment block for add, give the best possible big- O of the worst-case running time per call to
add, assuming each call to add is one call in a sequence of N calls. 5. Finally, in the comment
block for add, clearly and concisely justify the answer you gave in the previous part. Are you
surprised by your findings in the previous part?

More Related Content

Similar to For easy Ctrl C+Ctrl V Below is the same code that is descr.pdf

How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfHow do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
mail931892
 
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfHow do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
mail931892
 
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxConsider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
maxinesmith73660
 
Everything needs to be according to the instructions- thank you! SUPPO.pdf
Everything needs to be according to the instructions- thank you! SUPPO.pdfEverything needs to be according to the instructions- thank you! SUPPO.pdf
Everything needs to be according to the instructions- thank you! SUPPO.pdf
firstchoiceajmer
 

Similar to For easy Ctrl C+Ctrl V Below is the same code that is descr.pdf (20)

Stack Implementation
Stack ImplementationStack Implementation
Stack Implementation
 
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfHow do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
J Unit
J UnitJ Unit
J Unit
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
3 j unit
3 j unit3 j unit
3 j unit
 
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfHow do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
 
Confitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good TestsConfitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good Tests
 
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMock
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
CORE JAVA
CORE JAVACORE JAVA
CORE JAVA
 
GeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsGeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good Tests
 
CORE JAVA
CORE JAVACORE JAVA
CORE JAVA
 
03-inheritance.ppt
03-inheritance.ppt03-inheritance.ppt
03-inheritance.ppt
 
Java New Programming Features
Java New Programming FeaturesJava New Programming Features
Java New Programming Features
 
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxConsider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Everything needs to be according to the instructions- thank you! SUPPO.pdf
Everything needs to be according to the instructions- thank you! SUPPO.pdfEverything needs to be according to the instructions- thank you! SUPPO.pdf
Everything needs to be according to the instructions- thank you! SUPPO.pdf
 
U3 JAVA.pptx
U3 JAVA.pptxU3 JAVA.pptx
U3 JAVA.pptx
 

More from rchopra4

For effect of temperature on microbial growth exercise 28 w.pdf
For effect of temperature on microbial growth exercise 28 w.pdfFor effect of temperature on microbial growth exercise 28 w.pdf
For effect of temperature on microbial growth exercise 28 w.pdf
rchopra4
 
For Eosin Methylene Blue Agar what results would you be loo.pdf
For Eosin Methylene Blue Agar what results would you be loo.pdfFor Eosin Methylene Blue Agar what results would you be loo.pdf
For Eosin Methylene Blue Agar what results would you be loo.pdf
rchopra4
 

More from rchopra4 (20)

For effect of temperature on microbial growth exercise 28 w.pdf
For effect of temperature on microbial growth exercise 28 w.pdfFor effect of temperature on microbial growth exercise 28 w.pdf
For effect of temperature on microbial growth exercise 28 w.pdf
 
For Eosin Methylene Blue Agar what results would you be loo.pdf
For Eosin Methylene Blue Agar what results would you be loo.pdfFor Eosin Methylene Blue Agar what results would you be loo.pdf
For Eosin Methylene Blue Agar what results would you be loo.pdf
 
For each of the languages L a b below use the pumping l.pdf
For each of the languages L  a b below use the pumping l.pdfFor each of the languages L  a b below use the pumping l.pdf
For each of the languages L a b below use the pumping l.pdf
 
For each of the following scenarios state whether the situa.pdf
For each of the following scenarios state whether the situa.pdfFor each of the following scenarios state whether the situa.pdf
For each of the following scenarios state whether the situa.pdf
 
For each of the below items be sure to write your code in S.pdf
For each of the below items be sure to write your code in S.pdfFor each of the below items be sure to write your code in S.pdf
For each of the below items be sure to write your code in S.pdf
 
For customer service providers information learned about be.pdf
For customer service providers information learned about be.pdfFor customer service providers information learned about be.pdf
For customer service providers information learned about be.pdf
 
For Apple Inc AAPL Caterpillar CAT Consolidated Edis.pdf
For Apple Inc AAPL Caterpillar CAT Consolidated Edis.pdfFor Apple Inc AAPL Caterpillar CAT Consolidated Edis.pdf
For Apple Inc AAPL Caterpillar CAT Consolidated Edis.pdf
 
For bacteria the primary issue with UV light exposure is th.pdf
For bacteria the primary issue with UV light exposure is th.pdfFor bacteria the primary issue with UV light exposure is th.pdf
For bacteria the primary issue with UV light exposure is th.pdf
 
For any of the questions below do not do math If there ar.pdf
For any of the questions below do not do math  If there ar.pdfFor any of the questions below do not do math  If there ar.pdf
For any of the questions below do not do math If there ar.pdf
 
For a test of H0p050 the z test statistic equals 251 U.pdf
For a test of H0p050 the z test statistic equals 251 U.pdfFor a test of H0p050 the z test statistic equals 251 U.pdf
For a test of H0p050 the z test statistic equals 251 U.pdf
 
For a review session in preparation for an animal diversity .pdf
For a review session in preparation for an animal diversity .pdfFor a review session in preparation for an animal diversity .pdf
For a review session in preparation for an animal diversity .pdf
 
For a random variable XVX was calculated to be 1 Is the.pdf
For a random variable XVX was calculated to be 1  Is the.pdfFor a random variable XVX was calculated to be 1  Is the.pdf
For a random variable XVX was calculated to be 1 Is the.pdf
 
For 37 years Janet saved 250 at the beginning of every mon.pdf
For 37 years Janet saved 250 at the beginning of every mon.pdfFor 37 years Janet saved 250 at the beginning of every mon.pdf
For 37 years Janet saved 250 at the beginning of every mon.pdf
 
For 21 years Janet saved 850 at the beginning of every mon.pdf
For 21 years Janet saved 850 at the beginning of every mon.pdfFor 21 years Janet saved 850 at the beginning of every mon.pdf
For 21 years Janet saved 850 at the beginning of every mon.pdf
 
For 39 years Janet saved 450 at the beginning of every mon.pdf
For 39 years Janet saved 450 at the beginning of every mon.pdfFor 39 years Janet saved 450 at the beginning of every mon.pdf
For 39 years Janet saved 450 at the beginning of every mon.pdf
 
Following is the pea plant characteristics and the location .pdf
Following is the pea plant characteristics and the location .pdfFollowing is the pea plant characteristics and the location .pdf
Following is the pea plant characteristics and the location .pdf
 
For 20Y2 McDade Company reported a decline in not income A.pdf
For 20Y2 McDade Company reported a decline in not income A.pdfFor 20Y2 McDade Company reported a decline in not income A.pdf
For 20Y2 McDade Company reported a decline in not income A.pdf
 
For 27 years Janet saved 900 at the beginning of every mon.pdf
For 27 years Janet saved 900 at the beginning of every mon.pdfFor 27 years Janet saved 900 at the beginning of every mon.pdf
For 27 years Janet saved 900 at the beginning of every mon.pdf
 
For 14 years Janet saved 800 at the beginning of every mon.pdf
For 14 years Janet saved 800 at the beginning of every mon.pdfFor 14 years Janet saved 800 at the beginning of every mon.pdf
For 14 years Janet saved 800 at the beginning of every mon.pdf
 
For 100 births P exactly 57 girls 00301 and P57 or mor.pdf
For 100 births P exactly 57 girls 00301 and P57 or mor.pdfFor 100 births P exactly 57 girls 00301 and P57 or mor.pdf
For 100 births P exactly 57 girls 00301 and P57 or mor.pdf
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 

For easy Ctrl C+Ctrl V Below is the same code that is descr.pdf

  • 1. For easy Ctrl C+Ctrl V, Below is the same code that is described above. import java.util.Iterator; /** * Write a description of class MyArrayList here. * * @author (your name) * @version (a version number or a date) */ // Do not modify the given code. @SuppressWarnings("unchecked") // Given public class MyArrayList<T> { private T[] data; // Given private int size; // Given /* Implement. You must provide a comment block! */ public MyArrayList(int inCapacity) { } /* Implement. You must provide a comment block! */ public boolean isEmpty() { } /* Implement. You must provide a comment block! */ public boolean add(T obj) { // This method appends obj toward the back of data // Always return true } /* Implement. You must provide a comment block! Implement this method so that a sequence of add operations executes as efficiently as possible. */ private void grow() { } /* Implement. You must provide a comment block! */ public boolean remove(Object obj) { // Return true if obj was removed from data // and false otherwise. }
  • 2. /* The rest of the code is given. I will use it for testing purposes. Do not modify! */ // Given. Do not provide a comment block! public String toString() { if (size == 0) return "[ ]"; String retStr = "[ "; for (int i = 0; i < size - 1; i++) retStr += data[i] + ", "; retStr += data[size - 1] + " ]"; return retStr; } // Given. Do not provide a comment block! public boolean equals(Object obj) { if (obj instanceof MyArrayList) { MyArrayList<T> rhs = (MyArrayList<T>)obj; if (size != rhs.size) return false; for (int i = 0; i < size; i++) if (!rhs.contains(data[i])) return false; return true; } return false; } // Given. Do not provide a comment block! private int find(Object obj) { for (int i = 0; i < size; i++) if (data[i].equals(obj)) return i; return -1; } // Given. Do not provide a comment block! public boolean contains(Object obj) { return find(obj) >= 0; } // Given. Do not provide a comment block! public void addAll(MyArrayList<T> inList) { for (int i = 0; i < inList.size; i++)
  • 3. add(inList.data[i]); } // Given. Do not provide a comment block! private class MyArrayListIterator implements Iterator<T> { private int index = 0; // Given. Do not provide a comment block! public void remove() { } // No implementation // Given. Do not provide a comment block! public T next() { T temp = data[index]; index++; return temp; } // Given. Do not provide a comment block! public boolean hasNext() { return index < size; } } // Given. Do not provide a comment block! public Iterator<T> iterator() { return new MyArrayListIterator(); } } troduction: In this lab, you will get some practice implementing certain methods of expandable, generic MyArrayList data structure and doing an amortized analysis of one the methods thereof. Basically, in addition to the parameterized constructor, you have implement the operations of isEmpty, add, grow and remove. Then, you will do a very mple amortized analysis, using empirical methods, to derive the worst-case running time add when executed in a sequence of several add operations. ote that there is a lot of "extra" code that is given. Don't modify any of the given code. I ll need this for testing purposes. etting started: 1. Create a new project in NetBeans called Lab5. Make sure you uncheck Create Main Class in the New Java Application window. 2. Within the default package of your Lab5 project, create a new Java class called MyArrayList and use the following code to get started (the following code is also available for download on Canvas as MyArrayList. java): import java. util. Iterator; // Given / * Write a description of class MyArrayList here. * * Qauthor (your name) * @version (a version number or a date) */ // Do not modify the given code. @SuppressWarnings("unchecked") // Given public class MyArrayList { private T[] data; // Given private int size; // Given /* Implement. You must provide a comment block! */ public MyArrayList(int inCapacity) { }/* Implement. You must provide a comment block! */ public boolean isEmpty() {} /* Implement. You must provide a comment block! */ public boolean add(T obj) { // This method appends obj toward the back of data // Always return true Implement. You must provide a comment block! Implement this method so that a sequence of add operations executes
  • 4. as efficiently as possible. */ private void grow() {} /* Implement. You must provide a comment block! */ public boolean remove(Object obj) { // Return true if obj was removed from data // and otherwise. / The rest of the code is given. I will use it for testing purposes. Do not modify! /Follow the instructions in the Requirements section to see exactly what you have to do for this lab. Requirements: Ensure that your lab satisfies the following technical requirements: 1. For the first part, fill in the missing details in the MyArrayList class, as indicated by the comments. It is your responsibility to ensure that the formatting guidelines are followed. For example, make sure you have a consistent indentation scheme. The only exception is that you do not have to provide comment blocks for certain methods. Do not modify any of the given code. 2. In the comment block for add, give the best possible big- O of the worst-case running time for executing a single add operations. Briefly justify your answer. 3. Also in the comment block for add, give the best possible big- O of the total worst-case running time of executing a sequence of N add operations. Hint: take your previous answer and multiply it by N. Briefly justify your answer. 4. Depending on what you put for the previous two parts, your answer for the previous step might be a bit too "pessimistic". In other words, even though the worst-caserunning time of a single add is O(??), such worst-case behavior does not happen all the time. So, for this final part, compute the worst- case running time of a single call to add, assumed to be executed during a sequence of N calls to add. Use empirical methods to derive your answer. For example, compute the total amount of time it takes to call add N times, and then divide by N and see what you get. Do this for several increasing values of N and try to spot a pattern. Or, you can count the the number of simple operations executed across a sequence N add operations and then divide the total by N. In the comment block for add, give the best possible big- O of the worst-case running time per call to add, assuming each call to add is one call in a sequence of N calls. 5. Finally, in the comment block for add, clearly and concisely justify the answer you gave in the previous part. Are you surprised by your findings in the previous part?