Array
Array
Array - An Array is a collection of variables (elements) of the same type that are referenced by a
common name. It is a set of contiguous block of memory locations having a single name and data
type. Each individual memory location contained in the array is referred to as its element.
Array can be of 2 types, Single-Dimensional & Double-Dimensional array.
Array element An Array is a set of contiguous block of memory locations having a single name
and data type. Each of these individual memory locations is called array element. Each element
of an array can be referred by the array name with the subscript (index no.) enclosed in square
brackets representing the position of the element in the array. The array subscript always starts
with zero.
Binary Search – Binary Search is a searching technique that works on sorted array and uses
the divide and conquer method to search an item in the array. It repeatedly divides the
array into two pieces and focuses on the piece that could contain the target value. [Here the
item to be searched is compared with the middle element of the array. If the match found,
search is finished. If search-item is lesser than middle element (in ascending array), it
performs binary search in the first half of the array, otherwise performs binary search in
the latter half of the array.]
Bubble Sort - This sort method is based on comparing and exchanging pairs of adjacent
elements, until all the elements in an array are sorted. Assuming that the array elements are
arranged vertically, the largest item bubbles up to the top of an array (for ascending order). The
algorithm begins by comparing the bottom-most element with its adjacent element and an
exchange of two elements takes place only then if bottom element is higher than the adjacent
element. After one pass (one round of scanning through the set of elements) leaving the last
element, the remaining elements are scanned to find the next highest element. This continues till
the array is sorted.
Selection Sort - In this sorting technique, from all the elements of the array it searches the
smallest element (for ascending order) and that element is exchanged with the first element of
the array. Next, the second smallest element is searched from in the rest of the elements and
exchanged with the second element of the array and so on.