本文整理匯總了Python中LinkedList.LinkedList.tranverse方法的典型用法代碼示例。如果您正苦於以下問題:Python LinkedList.tranverse方法的具體用法?Python LinkedList.tranverse怎麽用?Python LinkedList.tranverse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類LinkedList.LinkedList
的用法示例。
在下文中一共展示了LinkedList.tranverse方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: solution
# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import tranverse [as 別名]
def solution():
print "2-2 return k-th to last, pls enter linked list value with space to split."
raw_values = raw_input("values >> ")
values = [float(i) for i in raw_values.strip().split()]
k = int(raw_input("k >> "))
l1 = LinkedList(values)
l1.tranverse()
KthToLast_recu(l1.head, k)
示例2: solution
# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import tranverse [as 別名]
def solution():
print "2-1 Remove dups. Pls enter linked list values, split by single space."
raw_values = raw_input("values >> ")
values = [float(val) for val in raw_values.strip().split()]
l1 = LinkedList(values)
l1.tranverse()
removeDups(l1.head)
l1.tranverse()
示例3: solution
# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import tranverse [as 別名]
def solution():
print "2-5 sum lists."
l1 = LinkedList([8,6,4,2])
l2 = LinkedList([4,5,7,9,2,4,6,8])
l1.tranverse()
l2.tranverse()
l3 = sumLists(l1.head, l2.head)
l3.tranverse()
示例4: solution
# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import tranverse [as 別名]
def solution():
print "2-4 Partition."
raw_values = raw_input("values >> ")
if raw_values.strip() == "":
values = [3,5,8,5,10,2,1]
else:
values = [float(i) for i in raw_values.strip().split()]
l1 = LinkedList(values)
l1.tranverse()
val = float(raw_input("select a value >> "))
partition(l1.head, val)
l1.tranverse()
示例5: solution
# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import tranverse [as 別名]
def solution():
print "2-3 delete middle node, pls enter linked list values. Enter for default"
raw_values = raw_input("values >> ")
if raw_values.strip() == "":
values = [1,2,3,4,5,6,7,8,9,10]
else:
values = [float(i) for i in raw_values.strip().split()]
l1 = LinkedList(values)
l1.tranverse()
print "Please enter 1 < c < 10 as the middle node number:"
c = int(raw_input("c >> "))
c_node = l1.returnKthNode(c)
deleteMiddleNode(c_node)
l1.tranverse()