Arrays, Data Structure & Algorithms

Assignment Help:

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.


Related Discussions:- Arrays

Best case, for i=1 to n if a[i}>7 for j=2 to n a[j]=a{j}+j for n=2 to n a...

for i=1 to n if a[i}>7 for j=2 to n a[j]=a{j}+j for n=2 to n a[k]=a[j]+i else if a[1]>4 && a[1] for 2 to a[1] a[j]= a{j]+5 else for 2to n a[j]=a[j]+i ..

Binary search tree bst, Describe Binary Search Tree (BST)? Make a BST for t...

Describe Binary Search Tree (BST)? Make a BST for the given sequence of numbers. 45, 36, 76, 23, 89, 115, 98, 39, 41, 56, 69, 48 Traverse the obtained tree in Preorder, Inord

Number of operations possible on ordered lists and arrays, Q. Enumerate num...

Q. Enumerate number of operations possible on ordered lists and arrays.  Write procedures to insert and delete an element in to array.

Depth first traversal, A depth-first traversal of a tree visits a nodefirst...

A depth-first traversal of a tree visits a nodefirst and then recursively visits the subtrees of that node. Similarly, depth-first traversal of a graph visits a vertex and then rec

Indexed sequential file organisation, When there is requirement to access r...

When there is requirement to access records sequentially by some key value and also to access records directly by the similar key value, the collection of records may be organized

Give example of assertion and abstract data type, Give example of assertion...

Give example of assertion and abstract data type For illustration, consider Natural ADT whose carrier set is the set of non-negative integers and whose operations are the usual

Algorithm for dfs, Step 1: Choose a vertex in the graph and make it the sou...

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

Acyclic graphs, Acyclic Graphs In a directed graph a path is said to fo...

Acyclic Graphs In a directed graph a path is said to form a cycle is there exists a path (A,B,C,.....P) such that A = P. A graph is called acyclic graph if there is no cycle in

What are the structures used in file-system implementation, What are the st...

What are the structures used in file-system implementation? Several on-disk and in-memory structures are used to execute a file system a. On-disk structure include P

Bst created in pre- order, Q. Make a BST for the given sequence of numbe...

Q. Make a BST for the given sequence of numbers. 45,32,90,34,68,72,15,24,30,66,11,50,10 Traverse the BST formed in  Pre- order, Inorder and Postorder.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd