Create a Dynamic Array container with this user interface G
Create a \"Dynamic Array\" container with this user interface:
// Gets the current number of entries in container
int getCurrentSize()
// Returns the current capacity of the container
int capacity()
// Checks whether the container is empty.
boolean isEmpty()
// Adds a new entry to the container
boolean insert(newEntry)
// Removes an entry from the container and moves all entries above anEntry down one
boolean remove(anEntry)
// Get index value
int getValue(index)
// Removes all entries from the container
void clear()
// Resize a container by doubling current capacity
int resize()
* Implement dynamic resizing using this algorithm:
1. Starting with a dynamic size of 10, if the number of elements exceed this number:
a. Reallocate the container size to double the current size
b. Move the contents of the current container to the newly sized container
c. Delete the previously sized container.
Resize C++
Data* ptemp = new Data[capacity*2 ];
for (int i=0; i<size; i++)
ptemp[i] = _mdata[i];
delete [] _mdata;
_mdata = ptemp;
capacity *= 2;
Resize Java
data = Arrays.copyOf(data, capacity*2);
capacity = capacity * 2;
2. Repeat from step 1a. as necessary.
3. Note the data file called \"Words.CSV\" can be downloaded from https://www.dropbox.com/s/jwi5x6zc4f18o6e/Words.csv?dl=0
4. Read the data file and store the words in the dynamic array.
Solution
Solution:
Program to Create a \"Dynamic Array\" container
class Resize
{
public:
int getCurrent size() {}
size(const size &other);
size &operator=(const size &other);
private:
QString size;
};
int capacity()
{
if(listName != null && listName.size() != 0)
};
public class Size {
static int []increaseSizeOfArray(int []arr){
int []brr=new int[(arr.length*2)];
for (int i = 0; i < arr.length; i++) {
brr[i]=arr[i];
}
return brr;
URL website = new URL(\"https://www.dropbox.com/s/jwi5x6zc4f18o6e/Words.csv?dl=0\");
ReadableByteChannel rbc = Channels.newChannel(dropbox.openStream());
FileOutputStream fos = new FileOutputStream(\"Words.CSV\");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
}
public static void main(String[] args) {
int []arr=new int[5];
for (int i = 0; i < 11; i++) {
if (i<arr.length) {
arr[i]=i+100;
}
else {
arr=increaseSizeOfArray(arr);
arr[i]=i+100;
}
}
for (int i = 0; i < arr.length; i++) {
System.out.println(\"arr=\"+arr[i]);
}
}
}

