Introduction

Published on
Scene 1 (0s)

Introduction. Array: An ordered collection of values with two distinguishing characters : Ordered and fixed length Homogeneous. Every value in the array must be of the same type.

Scene 2 (11s)

Array. The individual values in an array are called elements . The number of elements is called the length of the array Each element is identified by its position number in the array, which is called index . In C/C++/Java, the index numbers begin with 0..

Scene 3 (27s)

Array declaration. An array is characterized by Element type Length type Array_Name [ Length ] Ex: int student [30 ] An array named student of length 30.

Scene 4 (38s)

Arrays. n element array c : c[ 0 ] , c[ 1 ] … c[ n - 1 ] Array elements are like normal variables c[ 0 ] = 3; cout << c[ 0 ]; Performing operations in subscript. If x = 3 , c[ 5 – 2 ] == c[ 3 ] == c[ x ].

Scene 5 (52s)

Arrays. c[6]. -45. 6. 0. 72. 1543. -89. 0. 62. -3.

Scene 6 (1m 10s)

Selecting elements. Identifying an element array[ index ] Index can be an expression Cycling through array elements for ( int i = 0; i < array.length ; i ++).

Scene 7 (1m 21s)

Any component of the array can be inspected or updated by using its index. This is an efficient operation O(1) = constant time.

Scene 8 (1m 31s)

Examples Using Arrays. Initializers int n[ 5 ] =; If not enough initializers , rightmost elements become 0 If too many initializers , a syntax error is generated int n[ 5 ] = Sets all the elements to 0 If size omitted, the initializers determine it int n[] =; 5 initializers , therefore n is a 5 element array.

Scene 9 (1m 50s)

Basic Operations. Following are the basic operations supported by an array . Traverse − print all the array elements one by one. Insertion − Adds an element at the given index. Deletion − Deletes an element at the given index. Search − Searches an element using the given index or by the value. Update − Updates an element at the given index..

Scene 10 (2m 8s)

Algorithm For Insertion In Array. value insertion array.

Scene 11 (2m 27s)

Deletion in Array. If an element to be deleted ith location then all elements from the (i+1) th location we have to be shifted one step towards left . So (i+1) th element is copied to ith location and (i+2) th to (i+1) th location and so on.