Professional Documents
Culture Documents
LINEAR_SEARCH(A, N, VAL)
Description : Here A is an array having N elements. VAL is the value to be searched.
Step 1 : [INITIALIZE] SET POS = -1
Step 2 : [INITIALIZE] SET I = 1
Step 3 : Repeat Step 4 While I <= N
Step 4 : IF A[I] = VAL
SET POS = I
PRINT POS
Go to Step 6
[END OF IF]
SET I = I + 1
[END OF LOOP]
Step 5 : IF POS = –1
PRINT "VALUE IS NOT PRESENTIN THE ARRAY"
[END OF IF]
Step 6 : EXIT
searched. BEG denotes first element and END denotes last element in the array. MID
Else
[End of If]
Else
[End of If]
Step 7 : Exit
searched. LB denotes first element and UB denotes last element in the array. MID
PRINT POS
Go to Step 6
ELSE
[END OF IF]
[END OF LOOP]
Step 5 : IF POS = -1
[END OF IF]
Step 6 : EXIT
Bubble_Sort (A[], N)
[End of If]
Step 4 : Exit
BUBBLE_SORT(A, N)
Step 4 : EXIT
Insertion_Sort (A[], N)
Description : Here A is an unsorted array having N elements.
Step 3 : Set K = J - 1
Step 6 : Set K = K - 1
Step 8 : Exit
INSERTION_SORT (ARR, N)
Step 3 : SET J = K - 1
SET J = J - 1
[END OF INNER LOOP]
Step 6 : EXIT
Prof. Arpita R. Ojha Page 5
Data Structure ( Unit – 5 )
Selection_Sort (A[], N)
Description: Here A is an unsorted array having N elements.
[End of If]
[End of Step 3 For Loop]
Step 7 : Exit
SELECTION_SORT(ARR, N)
Set POS = J
[END OF IF]
Step 4 : EXIT
Prof. Arpita R. Ojha Page 6