SlideShare a Scribd company logo
1 of 2
C++ program
Revising the Array-Based List ADT
Given the data structure
typedef char *Element;
struct List {
Element *data;
int count;
int capacity;
};
Modify the following insertTail operations, instead of returning false when the array is full, the
function should attempt to double the capacity of the list and the old array list is copied into the
new array list, and then insert new element. Given the following implementation to modify:
bool insertTail(List* l, Element e) {
if (fullList(l)) {
return false;
} else {
l->data[l->count] = e;
l->count++;
return true;
}
}
Solution
Creating tempElement array.. and copy old elements. Then replace old array with new temp
Array. And also we need to update capacity of list.
bool insertTail(List* l, Element e) {
if (fullList(l)) {
// temp list declared with double size
int tempCount = l->count;
Element * temp = new Element[2*tempCount];
// copying old list to new list
for(int i=0; i<tempCount; i++){
temp[i] = list->data[i];
}
//now referencing old array with new array
l->data = temp;
l->capacity = 2*tempCount;
}
// no else condition.. it will continue to insert
l->data[l->count] = e;
l->count++;
return true;
}

More Related Content

Similar to C++ program Revising the Array-Based List ADT Given the data structure.docx

Write ItemList.h and ItemList.cItemList is used to store a list .pdf
Write ItemList.h and ItemList.cItemList is used to store a list .pdfWrite ItemList.h and ItemList.cItemList is used to store a list .pdf
Write ItemList.h and ItemList.cItemList is used to store a list .pdfsales223546
 
template-typename T- class Array { public- ---------------------------.pdf
template-typename T- class Array { public- ---------------------------.pdftemplate-typename T- class Array { public- ---------------------------.pdf
template-typename T- class Array { public- ---------------------------.pdfashokadyes
 
Number 1 I have completed and number 6 is just uploading I .pdf
Number 1 I have completed and number 6 is just uploading I .pdfNumber 1 I have completed and number 6 is just uploading I .pdf
Number 1 I have completed and number 6 is just uploading I .pdfadvancethchnologies
 
For this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdfFor this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdffashiongallery1
 
Prompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdfPrompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdfalsofshionchennai
 
you will implement some sorting algorithms for arrays and linked lis.pdf
you will implement some sorting algorithms for arrays and linked lis.pdfyou will implement some sorting algorithms for arrays and linked lis.pdf
you will implement some sorting algorithms for arrays and linked lis.pdfclearvisioneyecareno
 
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docxLab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docxrennaknapp
 
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.docxDIPESH30
 
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdfImplement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdfrishabjain5053
 
C++ CodeConsider the LinkedList class and the Node class that we s.pdf
C++ CodeConsider the LinkedList class and the Node class that we s.pdfC++ CodeConsider the LinkedList class and the Node class that we s.pdf
C++ CodeConsider the LinkedList class and the Node class that we s.pdfarmyshoes
 
Write a function called countElements that counts the number of times.pdf
Write a function called countElements that counts the number of times.pdfWrite a function called countElements that counts the number of times.pdf
Write a function called countElements that counts the number of times.pdffeetshoemart
 
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.pdfannaelctronics
 
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 .pdfarpitcomputronics
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdfaathiauto
 
Assignment 6 as a reference public class ArrExample pr.pdf
Assignment 6 as a reference   public class ArrExample    pr.pdfAssignment 6 as a reference   public class ArrExample    pr.pdf
Assignment 6 as a reference public class ArrExample pr.pdfkksrivastava1
 
import java.util.; public class IteratorDemo {public static voi.pdf
import java.util.; public class IteratorDemo {public static voi.pdfimport java.util.; public class IteratorDemo {public static voi.pdf
import java.util.; public class IteratorDemo {public static voi.pdfanilgoelslg
 
Implement a function called getElements() that takes in two lists. T.pdf
Implement a function called getElements() that takes in two lists. T.pdfImplement a function called getElements() that takes in two lists. T.pdf
Implement a function called getElements() that takes in two lists. T.pdfarracollection
 

Similar to C++ program Revising the Array-Based List ADT Given the data structure.docx (20)

Write ItemList.h and ItemList.cItemList is used to store a list .pdf
Write ItemList.h and ItemList.cItemList is used to store a list .pdfWrite ItemList.h and ItemList.cItemList is used to store a list .pdf
Write ItemList.h and ItemList.cItemList is used to store a list .pdf
 
template-typename T- class Array { public- ---------------------------.pdf
template-typename T- class Array { public- ---------------------------.pdftemplate-typename T- class Array { public- ---------------------------.pdf
template-typename T- class Array { public- ---------------------------.pdf
 
Number 1 I have completed and number 6 is just uploading I .pdf
Number 1 I have completed and number 6 is just uploading I .pdfNumber 1 I have completed and number 6 is just uploading I .pdf
Number 1 I have completed and number 6 is just uploading I .pdf
 
For this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdfFor this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdf
 
Prompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdfPrompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdf
 
03-Lists.ppt
03-Lists.ppt03-Lists.ppt
03-Lists.ppt
 
you will implement some sorting algorithms for arrays and linked lis.pdf
you will implement some sorting algorithms for arrays and linked lis.pdfyou will implement some sorting algorithms for arrays and linked lis.pdf
you will implement some sorting algorithms for arrays and linked lis.pdf
 
dynamicList.ppt
dynamicList.pptdynamicList.ppt
dynamicList.ppt
 
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docxLab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
 
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
 
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdfImplement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
 
C++ CodeConsider the LinkedList class and the Node class that we s.pdf
C++ CodeConsider the LinkedList class and the Node class that we s.pdfC++ CodeConsider the LinkedList class and the Node class that we s.pdf
C++ CodeConsider the LinkedList class and the Node class that we s.pdf
 
Write a function called countElements that counts the number of times.pdf
Write a function called countElements that counts the number of times.pdfWrite a function called countElements that counts the number of times.pdf
Write a function called countElements that counts the number of times.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
 
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
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdf
 
Assignment 6 as a reference public class ArrExample pr.pdf
Assignment 6 as a reference   public class ArrExample    pr.pdfAssignment 6 as a reference   public class ArrExample    pr.pdf
Assignment 6 as a reference public class ArrExample pr.pdf
 
import java.util.; public class IteratorDemo {public static voi.pdf
import java.util.; public class IteratorDemo {public static voi.pdfimport java.util.; public class IteratorDemo {public static voi.pdf
import java.util.; public class IteratorDemo {public static voi.pdf
 
Stacks queues
Stacks queuesStacks queues
Stacks queues
 
Implement a function called getElements() that takes in two lists. T.pdf
Implement a function called getElements() that takes in two lists. T.pdfImplement a function called getElements() that takes in two lists. T.pdf
Implement a function called getElements() that takes in two lists. T.pdf
 

More from marions12

C++ help!! Im not familiar with how to save- read file so that the pro.docx
C++ help!! Im not familiar with how to save- read file so that the pro.docxC++ help!! Im not familiar with how to save- read file so that the pro.docx
C++ help!! Im not familiar with how to save- read file so that the pro.docxmarions12
 
c++ computer architecture and memory What is fragmentation- Briefly ex.docx
c++ computer architecture and memory What is fragmentation- Briefly ex.docxc++ computer architecture and memory What is fragmentation- Briefly ex.docx
c++ computer architecture and memory What is fragmentation- Briefly ex.docxmarions12
 
C# There are two schools of thought on the use of implicitly typed var.docx
C# There are two schools of thought on the use of implicitly typed var.docxC# There are two schools of thought on the use of implicitly typed var.docx
C# There are two schools of thought on the use of implicitly typed var.docxmarions12
 
Brief introduction of the WorldComSolutionWorldCom was started by Bill.docx
Brief introduction of the WorldComSolutionWorldCom was started by Bill.docxBrief introduction of the WorldComSolutionWorldCom was started by Bill.docx
Brief introduction of the WorldComSolutionWorldCom was started by Bill.docxmarions12
 
Brief Exercise 5-5 Crane Corporation has the following accounts includ.docx
Brief Exercise 5-5 Crane Corporation has the following accounts includ.docxBrief Exercise 5-5 Crane Corporation has the following accounts includ.docx
Brief Exercise 5-5 Crane Corporation has the following accounts includ.docxmarions12
 
Briefly describe some of the similarities and differences between U-S-.docx
Briefly describe some of the similarities and differences between U-S-.docxBriefly describe some of the similarities and differences between U-S-.docx
Briefly describe some of the similarities and differences between U-S-.docxmarions12
 
Briefly describe what the query evaluation engine performs inside a DB.docx
Briefly describe what the query evaluation engine performs inside a DB.docxBriefly describe what the query evaluation engine performs inside a DB.docx
Briefly describe what the query evaluation engine performs inside a DB.docxmarions12
 
Briefly explain the purposes of adjustments Briefly explain the purp.docx
Briefly explain the purposes of adjustments   Briefly explain the purp.docxBriefly explain the purposes of adjustments   Briefly explain the purp.docx
Briefly explain the purposes of adjustments Briefly explain the purp.docxmarions12
 
Budget Martin Corporation granted a nonqualified stock option to e.docx
Budget    Martin Corporation granted a nonqualified stock option to  e.docxBudget    Martin Corporation granted a nonqualified stock option to  e.docx
Budget Martin Corporation granted a nonqualified stock option to e.docxmarions12
 
Calculate fost of goods sold and ending inventory and analyze effect o (1).docx
Calculate fost of goods sold and ending inventory and analyze effect o (1).docxCalculate fost of goods sold and ending inventory and analyze effect o (1).docx
Calculate fost of goods sold and ending inventory and analyze effect o (1).docxmarions12
 
Calculate fost of goods sold and ending inventory and analyze effect o.docx
Calculate fost of goods sold and ending inventory and analyze effect o.docxCalculate fost of goods sold and ending inventory and analyze effect o.docx
Calculate fost of goods sold and ending inventory and analyze effect o.docxmarions12
 
Ca(OH)2 is insoluble- What is the total concentration of ions if 2M of.docx
Ca(OH)2 is insoluble- What is the total concentration of ions if 2M of.docxCa(OH)2 is insoluble- What is the total concentration of ions if 2M of.docx
Ca(OH)2 is insoluble- What is the total concentration of ions if 2M of.docxmarions12
 
c- Since BEEF hooks to Metasploit- is there any safe way to use the we.docx
c- Since BEEF hooks to Metasploit- is there any safe way to use the we.docxc- Since BEEF hooks to Metasploit- is there any safe way to use the we.docx
c- Since BEEF hooks to Metasploit- is there any safe way to use the we.docxmarions12
 
9- Fill in the following table with names or formulas- as appropriate-.docx
9- Fill in the following table with names or formulas- as appropriate-.docx9- Fill in the following table with names or formulas- as appropriate-.docx
9- Fill in the following table with names or formulas- as appropriate-.docxmarions12
 
9- A combination of sand- salt- and water is an example of a A) homoge.docx
9- A combination of sand- salt- and water is an example of a A) homoge.docx9- A combination of sand- salt- and water is an example of a A) homoge.docx
9- A combination of sand- salt- and water is an example of a A) homoge.docxmarions12
 
8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx
8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx
8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docxmarions12
 
870 The plates of a capacitor are not quite parallel- the distance bet.docx
870 The plates of a capacitor are not quite parallel- the distance bet.docx870 The plates of a capacitor are not quite parallel- the distance bet.docx
870 The plates of a capacitor are not quite parallel- the distance bet.docxmarions12
 
8- What are concurrency design patterns- Explain-Solution8) we have fi.docx
8- What are concurrency design patterns- Explain-Solution8) we have fi.docx8- What are concurrency design patterns- Explain-Solution8) we have fi.docx
8- What are concurrency design patterns- Explain-Solution8) we have fi.docxmarions12
 
8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx
8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx
8- Calculate the distance from the donor (D) to the acceptor (A) in th.docxmarions12
 
7- You want to create an SSIS package that copies data from a source t.docx
7- You want to create an SSIS package that copies data from a source t.docx7- You want to create an SSIS package that copies data from a source t.docx
7- You want to create an SSIS package that copies data from a source t.docxmarions12
 

More from marions12 (20)

C++ help!! Im not familiar with how to save- read file so that the pro.docx
C++ help!! Im not familiar with how to save- read file so that the pro.docxC++ help!! Im not familiar with how to save- read file so that the pro.docx
C++ help!! Im not familiar with how to save- read file so that the pro.docx
 
c++ computer architecture and memory What is fragmentation- Briefly ex.docx
c++ computer architecture and memory What is fragmentation- Briefly ex.docxc++ computer architecture and memory What is fragmentation- Briefly ex.docx
c++ computer architecture and memory What is fragmentation- Briefly ex.docx
 
C# There are two schools of thought on the use of implicitly typed var.docx
C# There are two schools of thought on the use of implicitly typed var.docxC# There are two schools of thought on the use of implicitly typed var.docx
C# There are two schools of thought on the use of implicitly typed var.docx
 
Brief introduction of the WorldComSolutionWorldCom was started by Bill.docx
Brief introduction of the WorldComSolutionWorldCom was started by Bill.docxBrief introduction of the WorldComSolutionWorldCom was started by Bill.docx
Brief introduction of the WorldComSolutionWorldCom was started by Bill.docx
 
Brief Exercise 5-5 Crane Corporation has the following accounts includ.docx
Brief Exercise 5-5 Crane Corporation has the following accounts includ.docxBrief Exercise 5-5 Crane Corporation has the following accounts includ.docx
Brief Exercise 5-5 Crane Corporation has the following accounts includ.docx
 
Briefly describe some of the similarities and differences between U-S-.docx
Briefly describe some of the similarities and differences between U-S-.docxBriefly describe some of the similarities and differences between U-S-.docx
Briefly describe some of the similarities and differences between U-S-.docx
 
Briefly describe what the query evaluation engine performs inside a DB.docx
Briefly describe what the query evaluation engine performs inside a DB.docxBriefly describe what the query evaluation engine performs inside a DB.docx
Briefly describe what the query evaluation engine performs inside a DB.docx
 
Briefly explain the purposes of adjustments Briefly explain the purp.docx
Briefly explain the purposes of adjustments   Briefly explain the purp.docxBriefly explain the purposes of adjustments   Briefly explain the purp.docx
Briefly explain the purposes of adjustments Briefly explain the purp.docx
 
Budget Martin Corporation granted a nonqualified stock option to e.docx
Budget    Martin Corporation granted a nonqualified stock option to  e.docxBudget    Martin Corporation granted a nonqualified stock option to  e.docx
Budget Martin Corporation granted a nonqualified stock option to e.docx
 
Calculate fost of goods sold and ending inventory and analyze effect o (1).docx
Calculate fost of goods sold and ending inventory and analyze effect o (1).docxCalculate fost of goods sold and ending inventory and analyze effect o (1).docx
Calculate fost of goods sold and ending inventory and analyze effect o (1).docx
 
Calculate fost of goods sold and ending inventory and analyze effect o.docx
Calculate fost of goods sold and ending inventory and analyze effect o.docxCalculate fost of goods sold and ending inventory and analyze effect o.docx
Calculate fost of goods sold and ending inventory and analyze effect o.docx
 
Ca(OH)2 is insoluble- What is the total concentration of ions if 2M of.docx
Ca(OH)2 is insoluble- What is the total concentration of ions if 2M of.docxCa(OH)2 is insoluble- What is the total concentration of ions if 2M of.docx
Ca(OH)2 is insoluble- What is the total concentration of ions if 2M of.docx
 
c- Since BEEF hooks to Metasploit- is there any safe way to use the we.docx
c- Since BEEF hooks to Metasploit- is there any safe way to use the we.docxc- Since BEEF hooks to Metasploit- is there any safe way to use the we.docx
c- Since BEEF hooks to Metasploit- is there any safe way to use the we.docx
 
9- Fill in the following table with names or formulas- as appropriate-.docx
9- Fill in the following table with names or formulas- as appropriate-.docx9- Fill in the following table with names or formulas- as appropriate-.docx
9- Fill in the following table with names or formulas- as appropriate-.docx
 
9- A combination of sand- salt- and water is an example of a A) homoge.docx
9- A combination of sand- salt- and water is an example of a A) homoge.docx9- A combination of sand- salt- and water is an example of a A) homoge.docx
9- A combination of sand- salt- and water is an example of a A) homoge.docx
 
8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx
8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx
8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx
 
870 The plates of a capacitor are not quite parallel- the distance bet.docx
870 The plates of a capacitor are not quite parallel- the distance bet.docx870 The plates of a capacitor are not quite parallel- the distance bet.docx
870 The plates of a capacitor are not quite parallel- the distance bet.docx
 
8- What are concurrency design patterns- Explain-Solution8) we have fi.docx
8- What are concurrency design patterns- Explain-Solution8) we have fi.docx8- What are concurrency design patterns- Explain-Solution8) we have fi.docx
8- What are concurrency design patterns- Explain-Solution8) we have fi.docx
 
8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx
8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx
8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx
 
7- You want to create an SSIS package that copies data from a source t.docx
7- You want to create an SSIS package that copies data from a source t.docx7- You want to create an SSIS package that copies data from a source t.docx
7- You want to create an SSIS package that copies data from a source t.docx
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

C++ program Revising the Array-Based List ADT Given the data structure.docx

  • 1. C++ program Revising the Array-Based List ADT Given the data structure typedef char *Element; struct List { Element *data; int count; int capacity; }; Modify the following insertTail operations, instead of returning false when the array is full, the function should attempt to double the capacity of the list and the old array list is copied into the new array list, and then insert new element. Given the following implementation to modify: bool insertTail(List* l, Element e) { if (fullList(l)) { return false; } else { l->data[l->count] = e; l->count++; return true; } } Solution Creating tempElement array.. and copy old elements. Then replace old array with new temp Array. And also we need to update capacity of list. bool insertTail(List* l, Element e) { if (fullList(l)) { // temp list declared with double size int tempCount = l->count;
  • 2. Element * temp = new Element[2*tempCount]; // copying old list to new list for(int i=0; i<tempCount; i++){ temp[i] = list->data[i]; } //now referencing old array with new array l->data = temp; l->capacity = 2*tempCount; } // no else condition.. it will continue to insert l->data[l->count] = e; l->count++; return true; }