SlideShare a Scribd company logo
1 of 3
Download to read offline
I need help with the 2nd //TODO comment and the other comments I'll post at the end. I keep
exceeding my memory when I write something for it
public static ArrayList doArrayListRemoveFromEnd(int numItems) {
System.out.print("doArrayListRemoveFromEnd: ");
ArrayList list = new ArrayList<>();
// TODO Write code that adds integers 0 through (numitems - 1)
// to list, inside a loop.
for(int i=0; i<=numItems-1; i++){
list.add(i);
}
long startTime = getTimestamp();
// TODO Write code that removes the last element from list,
// repeatedly until the list is empty.
int last = list.size();
long endTime = getTimestamp();
long totalTime = endTime - startTime;
System.out.println(totalTime);
return list;
}
// TODO Write code that removes the greatest element from set,
// repeatedly until the set is empty.
// TODO Write code that removes the first element from list,
// repeatedly until the list is empty.
// TODO Write code that gets the element at the last index from list.
// TODO Write code that checks if integer (numItems - 1)
// is a member of set.
Solution
public static ArrayList doArrayListRemoveFromEnd(int numItems) {
System.out.print("doArrayListRemoveFromEnd: ");
ArrayList list = new ArrayList<>();
// TODO Write code that adds integers 0 through (numitems - 1)
// to list, inside a loop.
for(int i=0; i<=numItems-1; i++){
list.add(i);
}
long startTime = getTimestamp();
// TODO Write code that removes the last element from list,
// repeatedly until the list is empty.
for(int i=0; i<=numItems-1; i++){
int last=list.size()-1;
list.remove(last);
}
long endTime = getTimestamp();
long totalTime = endTime - startTime;
System.out.println(totalTime);
return list;
}
// TODO Write code that removes the greatest element from set,
// repeatedly until the set is empty.
for(int i=0; i<=numItems-1; i++){
int pos = 0;
int max=list.get(0);
for (int i = 1; i < list.size(); i++) {
if(list.get(i) > max) {
max=list.get(i);
pos=i;
}
}
list.remove(pos);
}
// TODO Write code that removes the first element from list,
// repeatedly until the list is empty.
for(int i=0; i<=numItems-1; i++){
list.remove();
}
// TODO Write code that gets the element at the last index from list.
int element=list.get(list.size()-1);
// TODO Write code that checks if integer (numItems - 1)
// is a member of set.
for(int i=0; i<=numItems-1; i++){
{
if(item==list.get(i))
{
return true;
}
}
return false;

More Related Content

Similar to I need help with the 2nd TODO comment and the other comments Ill.pdf

I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
RAJATCHUGH12
 
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdfPart 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
mohammadirfan136964
 
Write a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdfWrite a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdf
arri2009av
 
Javathis is my current code i need help to implement public void s.pdf
Javathis is my current code i need help to implement public void s.pdfJavathis is my current code i need help to implement public void s.pdf
Javathis is my current code i need help to implement public void s.pdf
eyelineoptics
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
feelinggift
 
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfC++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
callawaycorb73779
 
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxlab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
DIPESH30
 
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfHelp please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
arorastores
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
JUSTSTYLISH3B2MOHALI
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdf
annaelctronics
 
Merge Sort java with a few details, please include comments if possi.pdf
Merge Sort java with a few details, please include comments if possi.pdfMerge Sort java with a few details, please include comments if possi.pdf
Merge Sort java with a few details, please include comments if possi.pdf
feelinggifts
 
In C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfIn C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdf
flashfashioncasualwe
 
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfPROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
climatecontrolsv
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
forladies
 
Using the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdfUsing the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdf
mallik3000
 

Similar to I need help with the 2nd TODO comment and the other comments Ill.pdf (20)

I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
 
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdfPart 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
 
Write a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdfWrite a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdf
 
Javathis is my current code i need help to implement public void s.pdf
Javathis is my current code i need help to implement public void s.pdfJavathis is my current code i need help to implement public void s.pdf
Javathis is my current code i need help to implement public void s.pdf
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 
Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docx
 
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfC++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
 
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxlab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
 
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfHelp please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
 
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdf
 
DS UNIT4_OTHER LIST STRUCTURES.docx
DS UNIT4_OTHER LIST STRUCTURES.docxDS UNIT4_OTHER LIST STRUCTURES.docx
DS UNIT4_OTHER LIST STRUCTURES.docx
 
Merge Sort java with a few details, please include comments if possi.pdf
Merge Sort java with a few details, please include comments if possi.pdfMerge Sort java with a few details, please include comments if possi.pdf
Merge Sort java with a few details, please include comments if possi.pdf
 
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
 
In C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfIn C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdf
 
Write a program that will test a name) method no sorting routine from.docx
 Write a program that will test a name) method no sorting routine from.docx Write a program that will test a name) method no sorting routine from.docx
Write a program that will test a name) method no sorting routine from.docx
 
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfPROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
 
Using the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdfUsing the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdf
 

More from Eye2eyeopticians10

Radiation heat transfer is caused byA) transfer of momentum exchan.pdf
Radiation heat transfer is caused byA) transfer of momentum exchan.pdfRadiation heat transfer is caused byA) transfer of momentum exchan.pdf
Radiation heat transfer is caused byA) transfer of momentum exchan.pdf
Eye2eyeopticians10
 
If francis Bacon were alive today what would he consider to be an ob.pdf
If francis Bacon were alive today what would he consider to be an ob.pdfIf francis Bacon were alive today what would he consider to be an ob.pdf
If francis Bacon were alive today what would he consider to be an ob.pdf
Eye2eyeopticians10
 
Label the major bones of the skeleton(a) anterior view b) posterior .pdf
Label the major bones of the skeleton(a) anterior view b) posterior .pdfLabel the major bones of the skeleton(a) anterior view b) posterior .pdf
Label the major bones of the skeleton(a) anterior view b) posterior .pdf
Eye2eyeopticians10
 
Why would you not expect water to move easily through a membrane Ho.pdf
Why would you not expect water to move easily through a membrane Ho.pdfWhy would you not expect water to move easily through a membrane Ho.pdf
Why would you not expect water to move easily through a membrane Ho.pdf
Eye2eyeopticians10
 
How many total bits are required for a direct-mapped cache with 2048 .pdf
How many total bits are required for a direct-mapped cache with 2048 .pdfHow many total bits are required for a direct-mapped cache with 2048 .pdf
How many total bits are required for a direct-mapped cache with 2048 .pdf
Eye2eyeopticians10
 
Which of the following is the most appropriate way to determine how .pdf
Which of the following is the most appropriate way to determine how .pdfWhich of the following is the most appropriate way to determine how .pdf
Which of the following is the most appropriate way to determine how .pdf
Eye2eyeopticians10
 
This figure displays five small hypothetical proteins. The a-helix se.pdf
This figure displays five small hypothetical proteins. The a-helix se.pdfThis figure displays five small hypothetical proteins. The a-helix se.pdf
This figure displays five small hypothetical proteins. The a-helix se.pdf
Eye2eyeopticians10
 
Solve the following initial value problem using Laplace transform.pdf
Solve the following initial value problem using Laplace  transform.pdfSolve the following initial value problem using Laplace  transform.pdf
Solve the following initial value problem using Laplace transform.pdf
Eye2eyeopticians10
 

More from Eye2eyeopticians10 (20)

Shown is a picture of com kernels that Barbara McClintock used to ded.pdf
Shown is a picture of com kernels that Barbara McClintock used to ded.pdfShown is a picture of com kernels that Barbara McClintock used to ded.pdf
Shown is a picture of com kernels that Barbara McClintock used to ded.pdf
 
Researchers recently presented results of a cohort study on prenatal.pdf
Researchers recently presented results of a cohort study on prenatal.pdfResearchers recently presented results of a cohort study on prenatal.pdf
Researchers recently presented results of a cohort study on prenatal.pdf
 
Radiation heat transfer is caused byA) transfer of momentum exchan.pdf
Radiation heat transfer is caused byA) transfer of momentum exchan.pdfRadiation heat transfer is caused byA) transfer of momentum exchan.pdf
Radiation heat transfer is caused byA) transfer of momentum exchan.pdf
 
If francis Bacon were alive today what would he consider to be an ob.pdf
If francis Bacon were alive today what would he consider to be an ob.pdfIf francis Bacon were alive today what would he consider to be an ob.pdf
If francis Bacon were alive today what would he consider to be an ob.pdf
 
I know that one of the main differences between the rough and smooth.pdf
I know that one of the main differences between the rough and smooth.pdfI know that one of the main differences between the rough and smooth.pdf
I know that one of the main differences between the rough and smooth.pdf
 
Label the major bones of the skeleton(a) anterior view b) posterior .pdf
Label the major bones of the skeleton(a) anterior view b) posterior .pdfLabel the major bones of the skeleton(a) anterior view b) posterior .pdf
Label the major bones of the skeleton(a) anterior view b) posterior .pdf
 
Iversen Company has provided the following information Price per unit.pdf
Iversen Company has provided the following information Price per unit.pdfIversen Company has provided the following information Price per unit.pdf
Iversen Company has provided the following information Price per unit.pdf
 
Write a method rarest that accepts a map whose keys are strings and w.pdf
Write a method rarest that accepts a map whose keys are strings and w.pdfWrite a method rarest that accepts a map whose keys are strings and w.pdf
Write a method rarest that accepts a map whose keys are strings and w.pdf
 
Would you please help me to solve this problem Name the plane repres.pdf
Would you please help me to solve this problem Name the plane repres.pdfWould you please help me to solve this problem Name the plane repres.pdf
Would you please help me to solve this problem Name the plane repres.pdf
 
Why is it easier to classify protists by methods of nutrition and mo.pdf
Why is it easier to classify protists by methods of nutrition and mo.pdfWhy is it easier to classify protists by methods of nutrition and mo.pdf
Why is it easier to classify protists by methods of nutrition and mo.pdf
 
Why would you not expect water to move easily through a membrane Ho.pdf
Why would you not expect water to move easily through a membrane Ho.pdfWhy would you not expect water to move easily through a membrane Ho.pdf
Why would you not expect water to move easily through a membrane Ho.pdf
 
Which OSI layer is concerned with reliable end-to-end delivery of da.pdf
Which OSI layer is concerned with reliable end-to-end delivery of da.pdfWhich OSI layer is concerned with reliable end-to-end delivery of da.pdf
Which OSI layer is concerned with reliable end-to-end delivery of da.pdf
 
How many total bits are required for a direct-mapped cache with 2048 .pdf
How many total bits are required for a direct-mapped cache with 2048 .pdfHow many total bits are required for a direct-mapped cache with 2048 .pdf
How many total bits are required for a direct-mapped cache with 2048 .pdf
 
Which of the following statements is (are) trueI The budget is .pdf
Which of the following statements is (are) trueI  The budget is .pdfWhich of the following statements is (are) trueI  The budget is .pdf
Which of the following statements is (are) trueI The budget is .pdf
 
Which of the following is the most appropriate way to determine how .pdf
Which of the following is the most appropriate way to determine how .pdfWhich of the following is the most appropriate way to determine how .pdf
Which of the following is the most appropriate way to determine how .pdf
 
Which of the following is a rational number A. pi B. 1.425 C. squ.pdf
Which of the following is a rational number  A. pi  B. 1.425  C. squ.pdfWhich of the following is a rational number  A. pi  B. 1.425  C. squ.pdf
Which of the following is a rational number A. pi B. 1.425 C. squ.pdf
 
Where is a thyme corpuscle found specifically sinus capsule medulla .pdf
Where is a thyme corpuscle found specifically sinus capsule medulla .pdfWhere is a thyme corpuscle found specifically sinus capsule medulla .pdf
Where is a thyme corpuscle found specifically sinus capsule medulla .pdf
 
what are the 3 mechanisms by which RTKs can activate signaling enzym.pdf
what are the 3 mechanisms by which RTKs can activate signaling enzym.pdfwhat are the 3 mechanisms by which RTKs can activate signaling enzym.pdf
what are the 3 mechanisms by which RTKs can activate signaling enzym.pdf
 
This figure displays five small hypothetical proteins. The a-helix se.pdf
This figure displays five small hypothetical proteins. The a-helix se.pdfThis figure displays five small hypothetical proteins. The a-helix se.pdf
This figure displays five small hypothetical proteins. The a-helix se.pdf
 
Solve the following initial value problem using Laplace transform.pdf
Solve the following initial value problem using Laplace  transform.pdfSolve the following initial value problem using Laplace  transform.pdf
Solve the following initial value problem using Laplace transform.pdf
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 

Recently uploaded (20)

24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 

I need help with the 2nd TODO comment and the other comments Ill.pdf

  • 1. I need help with the 2nd //TODO comment and the other comments I'll post at the end. I keep exceeding my memory when I write something for it public static ArrayList doArrayListRemoveFromEnd(int numItems) { System.out.print("doArrayListRemoveFromEnd: "); ArrayList list = new ArrayList<>(); // TODO Write code that adds integers 0 through (numitems - 1) // to list, inside a loop. for(int i=0; i<=numItems-1; i++){ list.add(i); } long startTime = getTimestamp(); // TODO Write code that removes the last element from list, // repeatedly until the list is empty. int last = list.size(); long endTime = getTimestamp(); long totalTime = endTime - startTime; System.out.println(totalTime); return list; } // TODO Write code that removes the greatest element from set, // repeatedly until the set is empty. // TODO Write code that removes the first element from list, // repeatedly until the list is empty. // TODO Write code that gets the element at the last index from list. // TODO Write code that checks if integer (numItems - 1) // is a member of set. Solution public static ArrayList doArrayListRemoveFromEnd(int numItems) { System.out.print("doArrayListRemoveFromEnd: ");
  • 2. ArrayList list = new ArrayList<>(); // TODO Write code that adds integers 0 through (numitems - 1) // to list, inside a loop. for(int i=0; i<=numItems-1; i++){ list.add(i); } long startTime = getTimestamp(); // TODO Write code that removes the last element from list, // repeatedly until the list is empty. for(int i=0; i<=numItems-1; i++){ int last=list.size()-1; list.remove(last); } long endTime = getTimestamp(); long totalTime = endTime - startTime; System.out.println(totalTime); return list; } // TODO Write code that removes the greatest element from set, // repeatedly until the set is empty. for(int i=0; i<=numItems-1; i++){ int pos = 0; int max=list.get(0); for (int i = 1; i < list.size(); i++) { if(list.get(i) > max) { max=list.get(i); pos=i; } } list.remove(pos); } // TODO Write code that removes the first element from list, // repeatedly until the list is empty.
  • 3. for(int i=0; i<=numItems-1; i++){ list.remove(); } // TODO Write code that gets the element at the last index from list. int element=list.get(list.size()-1); // TODO Write code that checks if integer (numItems - 1) // is a member of set. for(int i=0; i<=numItems-1; i++){ { if(item==list.get(i)) { return true; } } return false;