Answer to Question #239340 in C++ for nigel

Question #239340

An arrayList is one of the most important data structures used in many applications. Define and show the implementation of the functions of an arrayList


1
Expert's answer
2021-09-20T00:11:39-0400


Functions of ArrayLists:
ArrayList();
~ArrayList();
void add(int n);
int size();
int deleteLast();








Some declarations for implementations of the above functions:
int data;
int item_andex;
ArrayList doubleCapacity(int* x, int y)
ArrayList halfCapacity(int* x, int y)
int *arr_List;


Implementations of the functions of ArrayList:
	
ArrayList()
{
int data = 0;
int item_andex=0;
int *arr_List= new int [data];
}


//Insertion function of ArrayList
add(int item){
arr_List[item_andex]=item;
data++;
item_andex++;


if(data==item_andex)
{
arr_List=doubleCapacity(arr_List, data);
}
}


//Deleting function of ArrayList


int deleteLast()
{
int count=0;
if(arrayList!=0)
{
count=arr_List[size];
arr_List[size]=NULL;
if(items<item_andex*2)
{
arr_List=halfCapacity(arr_List, item_andex);
}




}
else
{
cout << "Array is empty\n";
}


return count;
}
//ArrayList Size() function
int size()
{
int count=0;
for(int x=0;x<arr.length;x++)
{
if(arr[x]!=NULL)
count++;
}


return count;




}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS