Categories
Code

Why is it useful to store multiple pieces of information?

Looking for some help? We have it all. Great price and impressive quality

For This or a Similar Paper Click To Order

Arrays are commonly used to store data items. Arrays can be managed in ways that fill, iterate over, add to, and delete items from the array.
Respond to the following in a minimum of 175 words:
Why is it useful to store multiple pieces of information?
Provide a code example that supports your comments.
Intial Post 175 words
Also respond in 75 words
Arrays are really useful for taking multiple inputs in and having a way to organize and store the data. After arrays receive the data, the code can be set up to pull in either left to right, or right to left, or specifically choose what block to take from. Arrays are created with a specific size at the start of the code, arrays can not be extended or shortened during execution (at least in Java), however in Java array Lists can be extended and shortened due to the differing nature of the code. Arrays are often connected to file-based inputs, where the code reads from a selected file to get the data for the code to execute. A while loop can be used till each array spot has been assigned requesting an input each time, or increment up based on a desired amount.
When I think of arrays, I think of spreadsheets, which with multiple arrays you can assign code as though it where a spreadsheet. An example of an array in code I know of is a project I had in a prior class before I enrolled in University of Phoenix and changed major; The code used 2 separate arrays and iterated between them. The project was designed to take from a pre-setup file with earnings for each month in the company, and with that information we had to assign each months earnings into an array, and then calculate each value for taxable income each month, and store those values in a second array. We then took each value stored, got the minimums and maximums and exported all the data to a new file.
Response 2/ 75 words
An array requires memory space only for the values, the start address and its length.
In an array, values are near each other in memory. They can be accessed easily from CPU to cache. This brings to a conclusion that iteration over an array is much faster than any other iteration.
When it come to check if an index is valid or not in an array, it has its specified indexes and hence optimal to use. It can be directly traversed with the index position.
Memory can be allocated dynamically in an array. This advantage of an array helps to save the memory of the system. It also helps when the pre-defined array has insufficient memory. At runtime, memory can be allocated manually during run time. Also, when memory allocation is not dynamic, it stored the data in contiguous memory locations. The amount of storage required depends on the data type or size.
C function to Search an element in an array:-
int findElement(int array[], int size, int keyToBeSearched)
{
int i;
// Finding & returning the position of the element
for (i = 0; i < size; i++)
if (array[i] == keyToBeSearched)
return i;
return – 1;
}

Looking for some help? We have it all. Great price and impressive quality

For This or a Similar Paper Click To Order

Leave a Reply