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. The reason bubble sort algorithm is inefficient is that it continues execution even after an array is sorted by performing unnecessary comparisons. Therefore, the number of comp

Algo rithm to Insert a Node p at the End of a Linked List is explained below Step1:   [check for space] If new1= NULL output "OVERFLOW" And exit Step2:   [Allocate fr

Difference between array and abstract data types Arrays aren't abstract data types since their arrangement in the physical memory of a computer is an essential feature of their

Which sorting algorithms does not have a worst case running time of  O (n 2 ) ? Merge sort

Almost Complete Binary Tree :-A binary tree of depth d is an almost whole binary tree if: 1.Any node and at level less than d-1 has two children. 2. for any node and in the tree wi

Program gives the program segment by using arrays for the insertion of an element to a queue into the multiqueue. Program: Program segment for the insertion of any element to t

Question 1 Explain the use of algorithms in computing Question 2 Explain time complexity and space complexity of an algorithm Question 3 Explain how you can analyz

Explain Backtracking The  principal idea is to construct solutions single component  at a time  and evaluate such  partially constructed candidates as follows. If a partiall

Ask question #Minima binary search tree is used to locate the number 43 which of the following probe sequences are possible and which are not? explainum 100 words accepted#

Speed cameras read the time a vehicle passes a point (A) on road and then reads time it passes a second point (B) on the same road (points A and B are 100 metres apart). Speed of t