An array is a collection of similar type of elements and is stored in sequential order. The following operations can be performed on 1D array.

- Traveling
- Inserting
- Deleting
- Searching
- Sorting.

All these operations are done on list of elements with the help of array indexes.

**1. Traveling**: It is nothing but visiting each array element and pint the data. The for loop and index values help to do this.

**2. Inserting**: To insert elements in a empty or in an incomplete array is easy process. The only thing is locate the insertion point, if necessary perform shifting of data to insert element.

**3. Deleting:** It is a straight forward method. Search the element you want to delete and set it as zero.

**4. Searching**: It is the process of finding required elements in the array. If the required element is found then search is said to be successful otherwise search is unsuccessful. There are two types of searching techniques are available.

**a) Linear search:** linear search works only on unsorted list. Each indexed value is compared with key ( item to be searched) value. If both are equal the search is successful otherwise unsuccessful.

**b) Binary search:** Binary search is a searching technique it works only on sorted data. It divides the list into three parts.

- The mid value; calculated as mid=(low+high)/2
- The elements which are less than the mod value are present on the left side of the mid.
- The elements which are greater than mid value are present in right side of the mid.

We divide the array and calculate the mid value, if required key value is greater than the mid value we move the right side of the mid. If the key value is less than the mid value we will move left side of the mid. If key is equal to mid value them we stop search and search is said to be successful.

**5. Sorting**: The process of arranging list of elements in ascending order or descending order is called search. There are two types of sorting techniques: internal sorting techniques and external sorting techniues

## 0 comments:

## Post a Comment

Note: only a member of this blog may post a comment.