Data Structure Chapter 2 Linear Table Question Answer

1. Multiple-choice questions
1. A linear table stored in sequence with a table length of n. When the probability of inserting or deleting an element at any position is equal, the average number of moving elements required to insert an element is (E), delete an element The number of elements that need to be moved is (A)
A. (n-1)/2 B .n C.n+1 Dn-1
E. n/2 F.(n+1)/2 G.(n- 2)/2
2. A linear table is a finite sequence with n (C).
A. Table elements B. Characters C. Data elements D. Data items
E. Information
3. "The logical order of the linear table is always consistent with the storage order." This conclusion is (C).
A. Correct B. Wrong C. Not necessarily, it is related to the specific structure
4. When the linear table adopts the chain storage structure, it requires the address of the available storage unit in the memory (D).
A. Must be continuous. B. Part of the address must be continuous.
C. Must be discontinuous. D. Continuous or discontinuous.
5. The condition for determining that the singly linked list of the leading node is empty is (B).
A.head= =NULL B.head->next= =NULL
C.head->next=head D.head!=NULL
6. The condition for judging that the head of a singly linked list without a head node is empty is (A).
A.head= =NULL B.head->next= =NULL
C.head->next=head D.head!=NULL
7. The end node P of the head of the non-empty cyclic singly linked list satisfies (C).
Ap->next= =NULL Bp= =NULL
Cp->next= =head Dp= =head
8. The time complexity of inserting a new node into an ordered singly linked list with n nodes and still ordering is (
B).
AO(1) BO(n) CO(n2) DO(log2n)
9. In a singly linked list, if the successor node of the node pointed by p is deleted, (A) is executed.
Ap->next=p->next->next;
Bp=p->next;p->next=p->next->next;
Cp->next=p->next;
Dp=p->next- >next;
10. In a singly linked list, if the node pointed by s is inserted after the node pointed by p, then execute (B)
As->next=p;p->next=s;
Bs->next= p->next; p->next=s;
Cs->next=p->next;p=s;
Dp->next=s;s->next=p;
11. In a singly linked list, it is known that q is the predecessor node of p. If a node s is inserted between q and p, then execute (
C).
As->next=p->next; p->next=s;
Bp->next=s->next; s->next=p;
Cq->next=s; s->next=p;
Dp- >next=s;s->next=q;


int data; //Data field
struct linknode *llink; //Pointer field to the predecessor node
struct linknode *rlink; //Pointer field to draw the successor point
} bnode
now treats a new node pointed to by q as non-empty The predecessor node of the node pointed to by p in the doubly linked list is inserted into the double-linked list, and the sentence segment that can correctly complete this requirement is (D).
A. q->rlink=p;
q->llink=p->llink;
p->llink=q;
p->llink->rlink=q;
B. p->llink=q;
q->rlink= p;
p->llink->rlink=q;
q->llink=p->llink;
C. q->llimk=p->rlink;
q->rlink=p;
p->link->rlink=q ;
p->llink=q;
D. None of the above is correct.
13. For example, the node structure of the question, such as the operation sequence of inserting the node s after the node p of this non-empty circular doubly linked list is (D)
A. p->rlink=s;s->llink=p;
p->rlink->llink=s;s->rlink=p->rlink;
B. p->rlink=s;p->rlink->llink =s;
s->llink=p;
C. s->llink=p;s->rlink=p->rlink;
p->rlink=s;p->rlink->llink=s;
D. s->llink=p;s->rlink= p->rlink;
p->rlink->llink=s;p->rlink=s;
14. On a singly linked list with a length of n (n>1), there are two pointers at the head and tail, execute ( B) The operation has nothing to do with the length of the linked list.
A. Delete the first element in the
singly linked list B. Delete the last element
in the singly linked list C. Insert a new element before the first element of
the singly linked list D. Insert a new element after the last element of the singly linked list
2. Fill in the blanks Question
1. In the linear structure, the first node _ has no predecessor node, and each of the remaining nodes has and only one predecessor node.
2. To insert or delete an element in the sequence table, you need to move __(n/2) ___ elements on average, and the number of elements moved is related to the location of the __element.
3. Knowing that L is a singly-linked list without a header node, try to select an appropriate sequence of sentences from the answers provided below, and implement them separately:
(1) The sequence of sentences inserted into the S node at the header of the table is ___⑥③__.
(2) The sequence of sentences inserted into the S node at the end of the table is __②⑨①⑦__.
①P->next=S; ②P=L; ③L=S;
④P->next=S->next; ⑤S->next=P->next;
⑥S->next=L; ⑦S->next=NULL;
⑧while (P->next!=Q) P=P->next;
⑨while(P->next!=NULL) P=P->next;
4. Knowing that L is a non-empty singly linked list with a header node, try to select a suitable sequence of sentences from the answers provided below.
(1) The sequence of sentences to delete the head node is __⑧⑦②⑩_.
(2) The sentence sequence to delete the tail node is _⑧⑥④②⑩___.
① P=P->next;
② P->next=P->next->next;
③ while(P!=NULL) P=P->next
④ while(Q->next!=NULL) {P= Q; Q=Q->next;}
⑤ while(P->next!=Q) P=P->next;
⑥ Q=P;
⑦ Q=P->next;
⑧ P=L;
⑨ L=L ->next; ⑩free(Q);
5. Knowing that L is a non-empty singly linked list with a header node, and P node is neither a head node nor a tail node, try the answer provided below Choose the appropriate sequence of sentences.
(1) The sentence sequence to delete the immediate successor node of P node is _⑥①⑨___.
(2) The sentence sequence to delete the immediate predecessor node of the P node is _⑤⑦④⑥①⑨_.
① P->next=P->next->next;
② P=P->next->next;
③ while(P->next!=Q) P=P->next;
④ while(P->next ->next=Q) P=P->next;
⑤ Q=P;

⑦ P=L;
⑧ L=L->next;
⑨ free(Q);
6. If the node number is known, when the search probability of each node is equal, look up a node from the singly linked list of n nodes On average, it is necessary to visit __n/2__ nodes, to find a node from the double-linked list of n nodes, and to visit __n/4__ nodes on average.
7. For a problem singly linked list with n nodes, the time complexity of inserting a new node after the node pointed to by p is known is __O(1)__; after the node whose value range is a given value The time complexity of inserting a new node is __O(n)__.
8. The singly linked list is the linked storage representation of the _linear list _.
9. The function of setting the head node in the singly linked list is to insert or delete the first element without special processing __.
10. In a singly linked list, except for the head node, the storage location of any node is indicated by the pointer field _ of its direct predecessor node.
11. In the non-empty two-way circular linked list, the process of inserting the node p before the node q is as follows:
p->prior=q->prior; q->prior->next=p;
p->next=q ;_Q->prior=p___;
12. In a doubly linked list, each node has two pointer fields, one points to the predecessor node ____, and the other points to the successor node ___.
13. The physical location of logically adjacent elements in the sequence table must be adjacent to each other. The physical positions of logically adjacent elements in a singly linked list are not necessarily adjacent to each other.

Guess you like

Origin blog.csdn.net/qq_43663263/article/details/105904969