本文整理汇总了Python中LinkedList.LinkedList.print_list方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.print_list方法的具体用法?Python LinkedList.print_list怎么用?Python LinkedList.print_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList.LinkedList
的用法示例。
在下文中一共展示了LinkedList.print_list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from LinkedList import LinkedList [as 别名]
# 或者: from LinkedList.LinkedList import print_list [as 别名]
def test():
lst = LinkedList()
lst.push(7)
lst.push(6)
lst.push(5)
lst.push(4)
lst.push(3)
lst.push(2)
lst.push(1)
lst.print_list()
swapNodes(lst.head, 4, 3)
lst.print_list()
示例2: LinkedList
# 需要导入模块: from LinkedList import LinkedList [as 别名]
# 或者: from LinkedList.LinkedList import print_list [as 别名]
slow = circular_list.head
# Since fast is k nodes from the start of the cycle as well,
# moving both pointers one node at a time would cause them to
# meet at the beginning of the cycle
while fast != slow:
fast = fast.next
slow = slow.next
return fast
if __name__ == "__main__":
list_vals = ["E", "D", "C", "B", "A"]
circular_list = LinkedList()
for val in list_vals:
circular_list.add_node(val)
ptr = circular_list.head
while ptr.next is not None:
ptr = ptr.next
circular_list.print_list()
ptr.next = circular_list.head.next.next
cycle_start = find_loop_start(circular_list)
print cycle_start.data