0% found this document useful (0 votes)
24 views

Sequential Searching

1. The document describes performing a sequential search algorithm on an unsorted array to find a target value. 2. It simulates searching for the value 15 in an array of size 10 containing unsorted integers. 3. The sequential search examines each element in the array in order until it finds the target value 15 at index position 3.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Sequential Searching

1. The document describes performing a sequential search algorithm on an unsorted array to find a target value. 2. It simulates searching for the value 15 in an array of size 10 containing unsorted integers. 3. The sequential search examines each element in the array in order until it finds the target value 15 at index position 3.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

REYES, JENNALYN T.

BSCS-IT 2nd YR. BLK. 3

PROF. MARIANNE ROSE P. YU

SEQUENTIAL SEARCHING
ALGORITHM: 1. Input A (array), size (size of the array), target (value to be searched). 2. Initialize i to 0. 3. If i is equal to size go to step 5, otherwise proceed to step 4. 4. If (A[i] == target), return i. Otherwise go to step 3. 5. STOP

SIMULATION: UNSORTED ARRAY

INDICES 9 0 7 1 3 2 15 3 17 4 11 5 5 6 19 7 13 8 1 9

Target

= 15

Size of Array = 10

9 0

7 1

3 2

15 3

17 4

11 5

5 6

19 7

13 8

1 9

Description At the beginning, the entire array is unsorted and user-defined. Now, we try to search the value 15 from the array.

9 0

7 1

3 2

15 3

17 4

11 5

5 6

19 7

13 8

1 9

Description To perform the linear search on unsorted array, it is done by examining the elements in the array starting from the first position. Since 9 is not our search value, we continue our search.

9 0

7 1

3 2

15 3

17 4

11 5

5 6

19 7

13 8

1 9

Description Continue our checking on every element of the array until either we found our search value or all the elements in the array have been examined. Since 7 is not equal to our target, continue the searching.

9 0

7 1

3 2

15 3

17 4

11 5

5 6

19 7

13 8

1 9

Description: Since 3 is not the same with our target, continue our search.

9 0

7 1

3 2

15 3

17 4

15 5

5 6

19 7

13 8

1 9

Description: We have found our search value 15, which is at the index position [3].

You might also like