#Programmer: Sriram Pemmaraju
#Date: 2-19-2009
#Shows how linear search works on a randomly generated list

import random

#Generates and returns a list of size n, filled with random integers
#in the range 1 through m
def generate1(n, m):
  collection = []
  for i in range(1, n+1):
    collection = collection + [random.randint(1, m)]
  return collection

#Does exactly the same thing as generate1, but uses a slightly different
#way of filling the list
def generate2(n, m):
  collection = []
  for i in range(1, n+1):
    collection.append(random.randint(1, m))
  return collection

#Does a linear search for an integer x in an size n list containing 
#randomly generated numbers in the range 1 through m. 
def search(x, n, m):
  collection = generate1(n, m)
  found = 0	#Meant to be a boolean, but True and False don't
		#work in my version of JES
  
  #Main loop that linearly scans the list looking for x
  for i in range(0, n):
    if(x == collection[i]):
      found = 1

  if(found):
      printNow("Found")
  else:
    printNow("Not Found")
