本文整理汇总了Python中linkedlist.LinkedList.printList方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.printList方法的具体用法?Python LinkedList.printList怎么用?Python LinkedList.printList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linkedlist.LinkedList
的用法示例。
在下文中一共展示了LinkedList.printList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import printList [as 别名]
def main():
#Create list of names
listOfNames = { "Tom", "Harry","Susan","Ethan","Willy","Shaina"}
#Create linkedlist object
testinglist = LinkedList()
#Test insertion method
for name in listOfNames:
testinglist.insert(name)
#Test size of list
print testinglist.size()
#Test print list
testinglist.printList()
#Test Deletion of head node
testinglist.delete("Tom")
#Test Deletion method:
testinglist.delete("Susan")
testinglist.printList()
#Test search list
testinglist.search("Willy")
示例2: isPalindrome
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import printList [as 别名]
f = isPalindrome(right.next)
if f is False:
return False
global left
flag= (left.data == right.data)
left = left.next
return flag
llist1 = LinkedList()
llist1.head = Node(2)
llist1.insert(4)
llist1.insert(7)
llist1.insert(7)
llist1.insert(4)
llist1.insert(2)
llist1.printList()
left = llist1.head
print(isPalindrome(llist1.head) )
示例3: LinkedList
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import printList [as 别名]
return myList
llist1 = LinkedList()
llist1.head = Node(2)
llist1.insert(4)
llist1.insert(7)
llist1.insert(8)
llist1.insert(12)
llist1.insert(20)
llist2 = LinkedList()
llist2.head = Node(1)
llist2.insert(14)
llist2.insert(27)
llist2.insert(38)
print("Befor Merge Sort")
llist1.printList()
print("....")
llist2.printList()
print("....")
Finallist = LinkedList()
Finallist = merge_n_reverse(llist1,llist2)
Finallist.printList()
#Beautiful - Gok