Arrays, Data Structure & Algorithms

This unit discussed about data structure called Arrays. The easiest form of array is a one-dimensional array which may be described as a finite ordered set of homogeneous elements that is stored in contiguous memory locations. For instance, an array might contain all integers or all characters or any data type, but might not contain a mix of data types.

The common form for declaring a single dimensional array is following:

data_type array_name[expression];

where data_type represents data type of the array. That is, char, integer, float etc. array_name is the name of expression and array which denoted the number of elements in the array.

For instance, assume the following C declaration:

int  a[100];

This declares an array of 100 integers.

The amount of storage needed to hold an array is related to its type and size directly. For a single dimension array, the overall size in bytes needed for the array is computed as illustrated below.

Memory needed (in bytes) = size of (data type) X length of array

The primary array index value is referred to as its lower bound & in C this is always 0 and the maximum index value is called as its upper bound. In the array the number of elements, called its range is given by upper bound-lower bound.

In the arrays we store values during program execution. Now Let us see the process of initializing an array while declaring it.

int a[4] = {34,60,93,2};

int b[] = {2,3,4,5};

float c[] = {-4,6,81,- 60};

We come to the following facts from these instance:

(i) If at the time of declaration the array is initialized, then the dimension of the array is optional.

(ii) Till the elements of array are not given any particular values, they have garbage values.

Posted Date: 4/4/2013 6:23:49 AM | Location : United States







Related Discussions:- Arrays, Assignment Help, Ask Question on Arrays, Get Answer, Expert's Help, Arrays Discussions

Write discussion on Arrays
Your posts are moderated
Related Questions
Q. Explain the insertion sort with a proper algorithm. What is the complication of insertion sort in the worst case?

How do you find the complexity of an algorithm?  Complexity of an algorithm is the measure of analysis of algorithm. Analyzing an algorithm means predicting the resources that

What is a height balanced tree? Height Balanced Tree (AVL Tree) An AVL tree is a binary search tree in which the height of the left and right subtree of the root vary by at most

Open addressing The easiest way to resolve a collision is to start with the hash address and do a sequential search by the table for an empty location.

Ans. An algorithm for the quick sort is as follows: void quicksort ( int a[ ], int lower, int upper ) { int i ; if ( upper > lower ) { i = split ( a, lower, up

Define Hashing. Store the following values in a hash table of table size 11 using division method: 25, 42, 96, 101, 102, 162, and 197. In case of collision, use other hash functio

Write an algorithm for compound interest.

Step 1: Choose a vertex in the graph and make it the source vertex & mark it visited. Step 2: Determine a vertex which is adjacent to the source vertex and begun a new search if

Q. Assume that we have separated n elements in to m sorted lists. Explain how to generate a single sorted list of all n elements in time O (n log m )?

Implement multiple stacks in a single dimensional array. Write algorithms for various stack operations for them.