pta Chapter 2

The head pointer is a pointer to the first node in the linked list, and all operations on the singly linked list need to start from the head pointer. The first node in the linked list can be the head node or the first node.
The first node is the node that stores the first data element in the linked list.
The head node is a node attached before the first node. The node does not store data elements, and its pointer field points to the first node. The function of the
head node is to facilitate the operation of the linked list. Ensure that each element in the linked list has a predecessor. If there is no head node, the method of inserting an element at the head of the table is different from inserting an element in other places of the table. Since the starting node has no direct predecessor, inserting a node into the table header requires that the successor pointer of the node point to the original table header, and set the newly inserted node as the table header. When inserting a node elsewhere, it must be connected not only with the immediate successor, but also with the immediate predecessor. The same is true for delete operations. After setting the head node, the table head element also has a direct predecessor, which is the head node. In this way, there is no special case of inserting or deleting the starting node during insert and delete operations. Only an extra node is needed to greatly simplify the code and no longer need to detect special cases. Reducing the amount of testing saves time, so time performance is also improved.

1. For a linear list of length N stored sequentially, the time complexity of accessing nodes and adding nodes corresponds to O(1) and O(N) respectively.

2. If the most commonly used operation of a linear table is to access any element of a specified sequence number and perform insertion and deletion operations at the end, the use of sequential table storage saves the most time.
√, add and delete at the end
3. In a singly linked list with N nodes, the time complexity of accessing nodes and adding nodes corresponds to O(1) and O(N) respectively.
×, it is correct in the array, but this is a single necklace list, you cannot directly access the element through the subscript, and cannot perform binary search
. 4. Organize and store the N data in a singly linked list in ascending order. If binary search is used, the average time complexity of the search is O(logN)
×
5. For a linear table of length N stored sequentially, the time complexity of deleting the first element and inserting the last element corresponds to O( 1) and O(N).
×
6. If a linked list is used to represent a linear list, the addresses of the elements in the list must be continuous.
X

1. If the linear table adopts the chain storage structure, the address of the available storage unit in the memory is required

    A.必须是连续的
    B.连续或不连续都可以
    C.部分地址必须是连续的
    D.一定是不连续的

B

2. The most commonly used operation in a linear table is to insert an element after the last element and delete the first element. What storage method is used to save the most computing time?
(2 minutes)

       A.单链表
       B.仅有尾指针的单循环链表
       C.仅有头指针的单循环链表
       D.双链表

A
3. If the most common operation of a table is to insert a node or delete the last node after the last node. Which storage method will save the most computing time?
(2 minutes)

      A.单链表
       B.双链表
        C.单循环链表
        D.带头结点的双循环链表

Guess you like

Origin blog.csdn.net/weixin_46064382/article/details/109270164