Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lista = [None]
- lDown = 0
- lUp = 0
- def linearProbing(x):
- global lDown
- global lUp
- if fullList():
- return "The list is full"
- l = x % len(lista)
- if lista[l] != None and lDown <= lUp:
- linearProbing1(x)
- lDown += 1
- else:
- linearProbing2(x)
- lUp += 1
- print lDown
- print lUp
- def createList(size):
- global lista
- lista = [None] * size
- def linearProbing1(x):
- l = x % len(lista)
- state = 0
- while state != 1:
- if lista[l] == None:
- lista[l] = x
- state = 1
- elif l == len(lista)-1:
- l = 0
- else:
- l += 1
- print lista
- def linearProbing2(x):
- l = x % len(lista)
- state = 0
- while state != 1:
- if lista[l] == None:
- lista[l] = x
- state = 1
- elif l == 0:
- l = len(lista)-1
- else:
- l -= 1
- print lista
- def fullList():
- for i in range(0, len(lista)):
- if lista[i] == None:
- return False
- return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement