Intro To Data Structures and Algorithm
Intro To Data Structures and Algorithm
Algorithm
Alexis L. Fante
Instructor
Array
• ARRAY is a data structure consisting of components of the same
type. It is a series of memory locations that can store value of the
same type.[1]
• declared to contain data of a specific data type
• components (memory locations) can be accessed by directly
referring to the index of a specific location
• used to store and process a set of values of the same data type
forming a logical group
Static Initialization
• For nos. 1 & 2 both are initialized with six array locations for an
array named codes.
s a m p l e \0
5 14 23 7 19 6 90
s a m p l e
• Like any other data, array elements or the array itself can be used
as function arguments, either in a user defined function (UDF) or
system defined function.
Findlow(grades[1],grades[5] / 2);
Findmax(grades);
Searching
• Linear Search
- also known as Sequential Search
- every item in the list is being compared with the search token, the
value that is to be search, until the search token is found or unfound
- is similar with looking for a term or meaning of a word in a
dictionary, looking for a name in a list of students, or searching for a
topic in a book index
- Advantage:
1. The algorithm is simple
2. The list need not be sorted in a particular order
Algorithm for Linear Search