Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Array List in C (25 points) Your task is to write an ArrayList like data structure in C. This is like an array, but it

image text in transcribed
Array List in C (25 points) Your task is to write an ArrayList like data structure in C. This is like an array, but it will automatically resize itself if it runs out of space. . The ArrayList should allow data (ints) to be added to its last used index by calling the putAL function, and the data at a particular index should be returned by the getAL function. The data should be stored in "data", an int array on the heap . The initial size of the ArrayList is 10 when createAL is called, and the array size should double when it runs out of room. . You may not modify the struct definition, initializer or print functions. You must write the getAL and putAL functions which retrieve or append an item to the list. Your code should use memory wisely and should print errors when necessary. You will primarily be graded on your code logic, but using correct C syntax is also expected. struct ArrayList f int *data; / store data here int count; // number of entries added so far int size; / size of data array struct ArrayList* createAL) ArrayList alist malloc(sizeof (struct ArrayList)) alist->count = 0; alist->size 10; alist->data malloc(alist->size*sizeof (int)); return alist; void printAL (struct ArrayList alist) int i; for(i-o ; i count ; i, i++){ alist->data[i]); %d ", // Return the value at index" from the list int getAL (struct ArrayList *alist, int index) // Add "newInt" to the end of the list void putAL (struct ArrayList *alist, int newInt)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions

Question

=+3. Draw the submodels of an integrated business model!

Answered: 1 week ago