State and explain advantages and disadvantages of arrays
Answers
Advantages of arrays are as follows.
1)The array sets an advantage only for the non sparse polynomial.
2)The array sets an advantage of storing data easily and also retrieving them.
Disadvantages of array are as follows.
1)The array size needs to be allocated ahead of time.
2)For sparse ploynomials ,there is a requirement of huge array size.
3)The is a waste of runtime and also space and rather gets complicated.
Answer:
advantages
i- gives a concise code as declaration allocation of space and initialisation can be done in a single line.
ii- Java arrays are dynamic unlike other languages like C, C + +.
iii- it is possible to directly access any element provided the index is known. Thus making manipulation easy.
disadvantages
i- arrange allows you to store elements of only one data type that is only homegenous data can be stored thus data of heterogeneous data type cannot be stored which is often required by a programmer.
ii- Arrays all always required quantity free memory location to be allocated for storing elements but they may be situations when the available memory is discrete in nature and therefore array can't be used to efficiently use the memory.
iii- careful design is required to make sure that large list of data can be stored.