By JAVA programming language
public void expand(Object a) {
// assume element has enough capacity
for (int i = size - 1; i >= 0; i--) {
element[4 * i + 3] = a;
element[4 * i + 2] = a;
element[4 * i + 1] = a;
element[4 * i] = element[i];
}
size = 4 * size;
}
element is a one-dimensional array that stores elements of the type Object. The data
member size is such that the list elements are in positions 0 through size-1 of the array.
(a)If the list element[0:2] = [a, b, c], whose size is 3, write the result and the size of the array element after executing
expand(new Integer(d)).
Assume that the array element has enough capacity for expansion.
where a, b, c, d are generated as follow:
Number |
Based on your student ID number, formed by its |
a |
1 st and 2nd digits |
b |
2 nd and 3rd digits |
c |
3 rd and 4th digits |
d |
4 th and 5th digits |
For example, the student ID is 19563755A.
Values of a to d are: 19, 95, 56, 63
Get Answers For Free
Most questions answered within 1 hours.