In programming, a series of objects all of which are the same size and type. Each object in an array is called an array element. For example, you could have an array of integers or an array of characters or an array of anything that has a defined data type. The important characteristics of an array are:
Each element has the same data type (although they may have different values).
The entire array is stored contiguously in memory (i.e. there are no gaps between elements).
All array elements have same name but different index number that ranges from 0 to SIZE-1.
Searching an array
Linear search is a method for finding a particular value in a list, that consists of checking every one of its elements, one at a time and in sequence, until the desired one is found.
Binary Search finds the position of a specified input value within an ordered array(already sorted array). In each step, the algorithm compares the search key value with the key value of the middle element of the array. If the keys match, then a matching element has been found and its index, or position, is returned. Otherwise, if the search key is less than the middle element's key, then the algorithm repeats its action on the sub-array to the left of the middle element or, if the search key is greater, on the sub-array to the right. If the remaining array to be searched is empty, then the key cannot be found in the array and a special "not found" indication is returned.
--------------
Vinay Kumar Saini
Assistant Professor (I.T Department)
Maharaja Agrasen Institute of Technology (MAIT)
Sector-22, Rohini, Delhi-110086, IndiaEmail-Id : vinay.kr.saini@gmail.com
Connect with me
Visit My Blog: http://vinay-kumar-saini.blogspot.in/
No comments:
Post a Comment