Applications of Array
Applications of Array
1. Visit the first element of array and compare its value with required
value.
2. If the value of array matches with the desired value, the search is
complete.
3. If the value of array does not match , move to next element an repeat
same process.
Binary Search:
Binary Search Binary search is a quicker method of searching for value in the
array. Binary search is very quick but it can only search an sorted array. It cannot
be applied on an unsorted array.
1. It locates the middle element of array and compare with desired number.
2. If they are equal, search is successful and the index of middle element is
returned.
3. If they are not equal, it reduces the search to half of the array.
4. If the search number is less than the middle element, it searches the first half of
array.
Otherwise it searches the second half of the array. The process continues until the
required number is found or loop completes without successful search.
Sorting Arrays:
Sorting Arrays Sorting is a process of arranging the value of array in a
particular order. An array can be sorted in two order.
Step 1
After Step 1
After Step 2
Selection Sort: