测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A22244. 对如下定义的循环单链表,横线处填写( )。class Node: def __init__(self, data): self.data = data self.next = None def create_list(value): head = Node(value) head.next = head return head def insert_tail(head, value): p = …

单选题 困难

题目描述

对如下定义的循环单链表,横线处填写(    )。

class Node:
    def __init__(self, data):
        self.data = data
        self.next = None

def create_list(value):
    head = Node(value)
    head.next = head
    return head

def insert_tail(head, value):
    p = head.next
    while p.next != head:
        p = p.next
    node = Node(value)
    p.next = node
    node.next = head

def print_list(head):
   _________________
    while True:
        print(p.data, end=" ")
        p = p.next
        if p == head:
            break
    print()

选项(单选)

上一题 下一题