Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
build list
  • Loading branch information
Jack-Lee-Hiter committed Jul 1, 2016
1 parent 74ffd86 commit e42c321
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 40 deletions.
134 changes: 95 additions & 39 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions Lists.py
@@ -0,0 +1,79 @@
class Node:
def __init__(self, initdata):
self.data = initdata
self.next = None

def getData(self):
return self.data

def getNext(self):
return self.next

def setData(self, newdata):
self.next = newdata

def setNext(self, nextNode):
self.next = nextNode


temp = Node(93)
temp.setData(10)
print(temp.getNext())

# 定义一个无序链表
class UnorderedList:
def __init__(self):
self.head = None

def isEmpty(self):
return self.head == None

def add(self, item):
temp = Node(item)
temp.setNext(self.head)
self.head = temp

def size(self):
current = self.head
count = 0
while current != None:
count += 1
current = current.getNext()
return count

def search(self, item):
current = self.head
found = False
while current != None and not found:
if current.getData() == item:
found = True
else:
current = current.getNext()
return found

def remove(self, item):
current = self.head
previous = None
found = False
while not found:
if current.getData() == item:
found = True
else:
previous = current
current = current.getNext()

if previous == None:
self.head = current.getNext()
else:
previous.setNext(current.getNext())

myList = UnorderedList()
myList.add(31)
myList.add(77)
myList.add(17)
myList.add(93)
myList.add(26)
myList.add(54)
print(myList.search(17))
myList.remove(54)
print(myList.search(54))
2 changes: 1 addition & 1 deletion SVM/SVM.py
@@ -1,5 +1,5 @@
from numpy import *

# 代码来自机器实战
def loadDataSet(fileName):
dataMat = []; labelMat = []
fr = open(fileName)
Expand Down

0 comments on commit e42c321

Please sign in to comment.