more topic chapters

Linear Search

Psuedocode

//ARRAY ALREADY DECLARED AND STORED
Found←False
INPUT SearchValue
INDEX←0
REPEAT
 INDEX←INDEX+1
 IF ARRAYLIST[INDEX]=SearchValue
          THEN
		     FOUND←TRUE
 END IF
UNTIL (INDEX=(LENGTH(ARRAYLIST))) OR FOUND=TRUE	
IF FOUND=TRUE
   THEN
     OUTPUT "THE VALUE IS AT ", INDEX
END IF
//LENGTH FUNCTION COULD BE USED IF THE MAX BOUNDARY OF ARRAY IS NOT KNOWN	 

Only the location of the first occuring match is found...This code is fully explained here

Python Algorithm

The code is in python for this algorithm

The code is free for anyone to copy and use...The copied code must have the same code and indentation as above

Try it yourself




Download Py