SlideShare a Scribd company logo
1 of 1
Download to read offline
Can you help me by answering this?
The following function defined in class MyArraylist is used to A. add a new element at the given
index in the array B. delete the element at the given index in the array C. move the element at the
given index in the array to the end (i.e. index size -1) D. move the element at the given index in
the array to the beginning (i.e. index 0 ) The class MyLinkedList is implemented using the class
Node defined as below: In the MySingleLinkedList class, a function is implemented as below,
which is to: public void function ( E item) f tmp.next = new Node (item, null); } } A. add a new
node at the beginning of the list B. add a new Node to the end of the list C. remove the head node
of the list D. remove the tail head of the list Consider the following code segment ArrayList <
String > list = new ArrayList < String > ( ) ; list.add ("P"); list. add ("Q"); list. add ("R") ; list.set
(2, "s"); list.add (2, "T") ; list. add ("u"); System.out.println(list); What is printed as a result of
executing the code segment? A. [ P , Q , R , s , T ] B. [ P , Q , s , T , u ] C. [ P , Q , T , s , u ] D. [
P , T , Q , s , u ] The following function defined in Class MySingleLinkedList is to: public void
function() { if(head == null) throw new NoSuchElementException(); head = head . next; } A.
remove the head node of the list B. remove the tail of the node C. remove all the nodes in the list
D. add a node at the beginning Identify the Big-O complexity of each of the following program
segments in terms of N , the number of items in list. ============ Program A
:============== for (int i = 0 ; i < N ; i + = 2 ) { list [ i ] = 0 ; } ========== Program B
:=============== int sum = 0 ; for (int i = 1 ; i < N ; i = 2 ) { sum + = list [ i ] ; } ========
Program C : ============ for ( int i = 1 ; i < N ; i + + ) { for (int j = N ; j > 0 ; j ) { list [ i ] =
l i s t [ i ] + j ; } } The following function defined in class MyArraylist is used to: % size - the
number of elements in the arraylist % theData - the Array to store the data elements public void
function(E anEntry) { if (size == capacity) { reallocate(); } theData[size] = anEntry; } size++;
A. add a element before the first element (i.e. index 0) in the array B. add a element after the last
element in the array C. add a element in the middle of the array (not the first or the last) D.
remove the first element (i.e. the index 0 ) in the array Please identify the time complexity of
operations: add (int index) and remove (int index) of ArrayList and LinkedList, respectively

More Related Content

Similar to Can you help me by answering this- The following function defined in c.pdf

Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
ankit11134
 
I only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdfI only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdf
arpitcomputronics
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringDS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and Engineering
RAJASEKHARV8
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
rushabhshah600
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
vishalateen
 
In this homework- you will write a program modify program you wrote in.pdf
In this homework- you will write a program modify program you wrote in.pdfIn this homework- you will write a program modify program you wrote in.pdf
In this homework- you will write a program modify program you wrote in.pdf
EvanpZjSandersony
 

Similar to Can you help me by answering this- The following function defined in c.pdf (20)

Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
 
Ch03_stacks_and_queues.ppt
Ch03_stacks_and_queues.pptCh03_stacks_and_queues.ppt
Ch03_stacks_and_queues.ppt
 
I only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdfI only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdf
 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notes
 
List
ListList
List
 
ARRAY in python and c with examples .pptx
ARRAY  in python and c with examples .pptxARRAY  in python and c with examples .pptx
ARRAY in python and c with examples .pptx
 
Array data structure
Array data structureArray data structure
Array data structure
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringDS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and Engineering
 
The Ring programming language version 1.5.2 book - Part 21 of 181
The Ring programming language version 1.5.2 book - Part 21 of 181The Ring programming language version 1.5.2 book - Part 21 of 181
The Ring programming language version 1.5.2 book - Part 21 of 181
 
Array data structure
Array data structureArray data structure
Array data structure
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
Data structure
Data  structureData  structure
Data structure
 
Array linked list.ppt
Array  linked list.pptArray  linked list.ppt
Array linked list.ppt
 
Please add-modify the following to the original code using C# 1- Delet.docx
Please add-modify the following to the original code using C# 1- Delet.docxPlease add-modify the following to the original code using C# 1- Delet.docx
Please add-modify the following to the original code using C# 1- Delet.docx
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
 
In this homework- you will write a program modify program you wrote in.pdf
In this homework- you will write a program modify program you wrote in.pdfIn this homework- you will write a program modify program you wrote in.pdf
In this homework- you will write a program modify program you wrote in.pdf
 
6_Array.pptx
6_Array.pptx6_Array.pptx
6_Array.pptx
 
GE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_NotesGE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_Notes
 
lec4.ppt
lec4.pptlec4.ppt
lec4.ppt
 

More from SeanIC4Jamesn

Case exercise Dance-a-Boogie Dance-a-Boogie ( DaB) was set up ten year.pdf
Case exercise Dance-a-Boogie Dance-a-Boogie ( DaB) was set up ten year.pdfCase exercise Dance-a-Boogie Dance-a-Boogie ( DaB) was set up ten year.pdf
Case exercise Dance-a-Boogie Dance-a-Boogie ( DaB) was set up ten year.pdf
SeanIC4Jamesn
 
Case exercise Dance-a-Boogie Dance-a-Boogie (DaB) was set up ten years.pdf
Case exercise Dance-a-Boogie Dance-a-Boogie (DaB) was set up ten years.pdfCase exercise Dance-a-Boogie Dance-a-Boogie (DaB) was set up ten years.pdf
Case exercise Dance-a-Boogie Dance-a-Boogie (DaB) was set up ten years.pdf
SeanIC4Jamesn
 
Certain endospore forming bacteria persist naturally in soil- where su.pdf
Certain endospore forming bacteria persist naturally in soil- where su.pdfCertain endospore forming bacteria persist naturally in soil- where su.pdf
Certain endospore forming bacteria persist naturally in soil- where su.pdf
SeanIC4Jamesn
 

More from SeanIC4Jamesn (20)

Compute the T Accounts 4 Points Use the Space provided on the next two.pdf
Compute the T Accounts 4 Points Use the Space provided on the next two.pdfCompute the T Accounts 4 Points Use the Space provided on the next two.pdf
Compute the T Accounts 4 Points Use the Space provided on the next two.pdf
 
Compute the missing amounts for the following table- Ii- (Click the ic.pdf
Compute the missing amounts for the following table- Ii- (Click the ic.pdfCompute the missing amounts for the following table- Ii- (Click the ic.pdf
Compute the missing amounts for the following table- Ii- (Click the ic.pdf
 
Conan the Barbarian has been fighting battles for decades- Whenever he.pdf
Conan the Barbarian has been fighting battles for decades- Whenever he.pdfConan the Barbarian has been fighting battles for decades- Whenever he.pdf
Conan the Barbarian has been fighting battles for decades- Whenever he.pdf
 
Compute the missing amounts in the separate (partial) income statement.pdf
Compute the missing amounts in the separate (partial) income statement.pdfCompute the missing amounts in the separate (partial) income statement.pdf
Compute the missing amounts in the separate (partial) income statement.pdf
 
Complete the income statement for the year 2020- Complete the balance.pdf
Complete the income statement for the year 2020- Complete the balance.pdfComplete the income statement for the year 2020- Complete the balance.pdf
Complete the income statement for the year 2020- Complete the balance.pdf
 
Class diagram- Part A- Consider the following description of a Police.pdf
Class diagram- Part A- Consider the following description of a Police.pdfClass diagram- Part A- Consider the following description of a Police.pdf
Class diagram- Part A- Consider the following description of a Police.pdf
 
Compare dispersal by spores vs- seeds- Which disperses better- Which g.pdf
Compare dispersal by spores vs- seeds- Which disperses better- Which g.pdfCompare dispersal by spores vs- seeds- Which disperses better- Which g.pdf
Compare dispersal by spores vs- seeds- Which disperses better- Which g.pdf
 
Compared to a pH9 solution- water- has a higher pH contains more H+ co.pdf
Compared to a pH9 solution- water- has a higher pH contains more H+ co.pdfCompared to a pH9 solution- water- has a higher pH contains more H+ co.pdf
Compared to a pH9 solution- water- has a higher pH contains more H+ co.pdf
 
CASE STUDY- John- a successful entrepreneur- runs a clothing store in.pdf
CASE STUDY- John- a successful entrepreneur- runs a clothing store in.pdfCASE STUDY- John- a successful entrepreneur- runs a clothing store in.pdf
CASE STUDY- John- a successful entrepreneur- runs a clothing store in.pdf
 
Case Study 1- Jane and Ken have a -blended family- of four children- n.pdf
Case Study 1- Jane and Ken have a -blended family- of four children- n.pdfCase Study 1- Jane and Ken have a -blended family- of four children- n.pdf
Case Study 1- Jane and Ken have a -blended family- of four children- n.pdf
 
Canadian Bacon Inc- financial statements are presented in the table be (2).pdf
Canadian Bacon Inc- financial statements are presented in the table be (2).pdfCanadian Bacon Inc- financial statements are presented in the table be (2).pdf
Canadian Bacon Inc- financial statements are presented in the table be (2).pdf
 
Case - 1 Name - Khokon Age - 35 Educational Qualification - Class 3 P.pdf
Case - 1  Name - Khokon Age - 35 Educational Qualification - Class 3 P.pdfCase - 1  Name - Khokon Age - 35 Educational Qualification - Class 3 P.pdf
Case - 1 Name - Khokon Age - 35 Educational Qualification - Class 3 P.pdf
 
Case exercise Dance-a-Boogie Dance-a-Boogie ( DaB) was set up ten year.pdf
Case exercise Dance-a-Boogie Dance-a-Boogie ( DaB) was set up ten year.pdfCase exercise Dance-a-Boogie Dance-a-Boogie ( DaB) was set up ten year.pdf
Case exercise Dance-a-Boogie Dance-a-Boogie ( DaB) was set up ten year.pdf
 
Carbohydrate Fermentation and Biochemical Tests In the lab we will be.pdf
Carbohydrate Fermentation and Biochemical Tests In the lab we will be.pdfCarbohydrate Fermentation and Biochemical Tests In the lab we will be.pdf
Carbohydrate Fermentation and Biochemical Tests In the lab we will be.pdf
 
Carson is a marketing manager in a cosmetics company- He decides who g.pdf
Carson is a marketing manager in a cosmetics company- He decides who g.pdfCarson is a marketing manager in a cosmetics company- He decides who g.pdf
Carson is a marketing manager in a cosmetics company- He decides who g.pdf
 
can possess cell surface receptors on target cells make use of G-prote.pdf
can possess cell surface receptors on target cells make use of G-prote.pdfcan possess cell surface receptors on target cells make use of G-prote.pdf
can possess cell surface receptors on target cells make use of G-prote.pdf
 
Case exercise Dance-a-Boogie Dance-a-Boogie (DaB) was set up ten years.pdf
Case exercise Dance-a-Boogie Dance-a-Boogie (DaB) was set up ten years.pdfCase exercise Dance-a-Boogie Dance-a-Boogie (DaB) was set up ten years.pdf
Case exercise Dance-a-Boogie Dance-a-Boogie (DaB) was set up ten years.pdf
 
Central Furniture Ltd- is a large table and chair manufacturer- Variou.pdf
Central Furniture Ltd- is a large table and chair manufacturer- Variou.pdfCentral Furniture Ltd- is a large table and chair manufacturer- Variou.pdf
Central Furniture Ltd- is a large table and chair manufacturer- Variou.pdf
 
Certain endospore forming bacteria persist naturally in soil- where su.pdf
Certain endospore forming bacteria persist naturally in soil- where su.pdfCertain endospore forming bacteria persist naturally in soil- where su.pdf
Certain endospore forming bacteria persist naturally in soil- where su.pdf
 
Claims on a group of policies of a certain type arise as a Poisson pro.pdf
Claims on a group of policies of a certain type arise as a Poisson pro.pdfClaims on a group of policies of a certain type arise as a Poisson pro.pdf
Claims on a group of policies of a certain type arise as a Poisson pro.pdf
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
17thcssbs2
 
Neurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeNeurulation and the formation of the neural tube
Neurulation and the formation of the neural tube
SaadHumayun7
 

Recently uploaded (20)

UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdfTelling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
Neurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeNeurulation and the formation of the neural tube
Neurulation and the formation of the neural tube
 
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
factors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptxfactors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptx
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 

Can you help me by answering this- The following function defined in c.pdf

  • 1. Can you help me by answering this? The following function defined in class MyArraylist is used to A. add a new element at the given index in the array B. delete the element at the given index in the array C. move the element at the given index in the array to the end (i.e. index size -1) D. move the element at the given index in the array to the beginning (i.e. index 0 ) The class MyLinkedList is implemented using the class Node defined as below: In the MySingleLinkedList class, a function is implemented as below, which is to: public void function ( E item) f tmp.next = new Node (item, null); } } A. add a new node at the beginning of the list B. add a new Node to the end of the list C. remove the head node of the list D. remove the tail head of the list Consider the following code segment ArrayList < String > list = new ArrayList < String > ( ) ; list.add ("P"); list. add ("Q"); list. add ("R") ; list.set (2, "s"); list.add (2, "T") ; list. add ("u"); System.out.println(list); What is printed as a result of executing the code segment? A. [ P , Q , R , s , T ] B. [ P , Q , s , T , u ] C. [ P , Q , T , s , u ] D. [ P , T , Q , s , u ] The following function defined in Class MySingleLinkedList is to: public void function() { if(head == null) throw new NoSuchElementException(); head = head . next; } A. remove the head node of the list B. remove the tail of the node C. remove all the nodes in the list D. add a node at the beginning Identify the Big-O complexity of each of the following program segments in terms of N , the number of items in list. ============ Program A :============== for (int i = 0 ; i < N ; i + = 2 ) { list [ i ] = 0 ; } ========== Program B :=============== int sum = 0 ; for (int i = 1 ; i < N ; i = 2 ) { sum + = list [ i ] ; } ======== Program C : ============ for ( int i = 1 ; i < N ; i + + ) { for (int j = N ; j > 0 ; j ) { list [ i ] = l i s t [ i ] + j ; } } The following function defined in class MyArraylist is used to: % size - the number of elements in the arraylist % theData - the Array to store the data elements public void function(E anEntry) { if (size == capacity) { reallocate(); } theData[size] = anEntry; } size++; A. add a element before the first element (i.e. index 0) in the array B. add a element after the last element in the array C. add a element in the middle of the array (not the first or the last) D. remove the first element (i.e. the index 0 ) in the array Please identify the time complexity of operations: add (int index) and remove (int index) of ArrayList and LinkedList, respectively