0% found this document useful (0 votes)
50 views1 page

Linear Search Algorithm

The document describes two algorithms: a linear search algorithm that searches an array for a target value and prints whether it is found, and a bubble sort algorithm that sorts an array in-place by repeatedly comparing adjacent elements and swapping them if out of order over multiple passes of the array.

Uploaded by

Aamir2686
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views1 page

Linear Search Algorithm

The document describes two algorithms: a linear search algorithm that searches an array for a target value and prints whether it is found, and a bubble sort algorithm that sorts an array in-place by repeatedly comparing adjacent elements and swapping them if out of order over multiple passes of the array.

Uploaded by

Aamir2686
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Linear Search Algorithm

DECLARE INTEGER i, srch = 72 DECLARE INTEGER x [] = [ 20, 15, 12, 30, -5, 72, 456 ] FOR i = 0 TO LENGTH (x) - 1 IF x [i] IS srch THEN PRINT "Found ", srch END END IF NEXT i PRINT "Did not find ", srch END

Bubble Sort Algorithm


DECLARE INTEGER i, pass DECLARE INTEGER x [] = [ 20, 15, 12, 30, -5, 72, 456 ] FOR pass = 0 TO LENGTH (x) - 2 FOR i = 0 TO LENGTH (x) - pass - 2 IF x [i] > x [i + 1] THEN SWAP x [i], x [i + 1] END IF NEXT i NEXT pass END

You might also like