Data structure notes 2 linear table

Data structure notes 2 linear table

Preface

Take notes on data structures.

Data structure notes 1 introduction

Mental framework

Type definition of linear table

Type definition of linear table

The sequential representation and realization of linear table

The sequential representation and realization of linear table

The chain representation and realization of linear table

The chain representation and realization of linear table

topic

Multiple choice

  1. In the following description of the linear table, what is wrong ()?

    A. Linear tables are stored sequentially and must occupy a continuous storage unit.

B. The linear table uses sequential storage to facilitate insertion and deletion operations.

C. The linear table adopts the link storage and does not need to occupy a continuous storage unit.

D. The linear table uses link storage to facilitate insertion and deletion operations.

  1. In a sequence table of length n, when inserting an element before the i-th (0<i<=n+1) element, it needs to move backward () elements.

    A. n-i B. n-i+1 C. n-i-1 D. i

  2. If the most commonly used operation of a linear table is to access any specified number of elements and insert and delete operations at the end, the use of () storage mode saves the most time.

A. Sequence table B. Double-linked list C. Double circular linked list with leading node D. Single circular linked list

  1. Assuming that the most commonly used operation of a linked list is to insert a node at the end and delete the end node, choose () to save time.

A. Single linked list B. Single circular linked list C. Single circular linked list with tail pointer D. Double circular linked list with head node

  1. The characteristic that the linked list does not have is ()

A. Insert and delete do not need to move elements B. Random access to any element

C. No need to estimate storage space in advance D. The required space is proportional to the linear length

  1. When the linear table (a1, a2,..., an) is stored in a linked manner, the time complexity of accessing the i-th position element is ()

O(i) B.O(1) C.O(n) D.O(i-1)

  1. If a linear table of length n adopts a sequential storage structure, the time complexity of the algorithm for inserting a new element at its i-th position is ()(1<=i<=n+1).

A. O (0) B. O (1) C. O (n) D. O (n2)

  1. In a single circular linked list (length n), it is known that the p pointer points to a non-empty node in the linked list. Now the time complexity of deleting the node pointed to by the p pointer in the linked list is ().

​ A. O( n) B. O( 1) C. O( n2) D. Not sure

  1. For linear tables stored sequentially, the time complexity of accessing nodes and adding and deleting nodes is ().

AO (n) O (n) B. O (n) O (1) C. O (1) O (n) D. O (1) O (1)

  1. The end node of the head of the non-empty circular linked list p↑ satisfies ()

A.p->next=head B.P->next=NULL

C.p=NULL D.p= head

  1. The condition that the circular linked list L with the leading node is empty is ().

​ A. L == NULL B. L->next ==NULL

​ C. L->next == L D. L->next == L->next

  1. Insert the node whose pointer is s after the node whose pointer is p in the singly linked list. The correct operation is: ()

A.p->next=s;s->next=p->next;

B.s->next=p->next;p->next=s;

C.p->next=s;p->next=s->next;

D.p->next=s->next;p->next=s;

  1. The node operation of inserting a pointer q before the node of the pointer p of the doubly linked list is ().

A. p->Llink=q;q->Rlink=p;p->Llink->Rlink=q;q->Llink=q;

B. p->Llink=q;p->Llink->Rlink=q;q->Rlink=p;q->Llink=p->Llink;

C. q-> Rlink = p; q-> Llink = p-> Llink; p-> Llink-> Rlink = q; p-> Llink = q;

D. q->Llink=p->Llink;q->Rlink=q;p->Llink=q;p->Llink=q;

3.B 4.B 5.A 6.D 7.B 8.C 9.C 10.A

11.C 12.A 13.C 14.B 15.C

True or False

() The advantage of the sequential storage method is that the storage density is large, and the insertion and deletion operations are efficient.

() The sequential storage method is too inefficient when inserting and deleting. In this respect, it is not as good as the chain storage method.

() The main disadvantage of sequential storage structure is that it is not conducive to insert or delete operations.

() Chain storage structure for any data structure must be better than sequential storage structure.

() The time to take the i-th element of the linear table is related to the size of i.

() Linear tables, stacks and queues are all linear structures.

() A linked list is a linear table with a chain storage structure. When inserting and deleting operations, it is more efficient in the linked list than in the sequential storage structure.

() Each element in the linear table has a unique predecessor and a unique successor.

() Circular linked list is not a linear list.

() The length of the linear table is the size of the storage space occupied by the linear table.

() In the linear table represented by the singly linked list, the time complexity of taking the i-th element of the linear table is O(1).

() The time complexity of deleting the first element node of the singly linked list with the leading node is O(1).

X X √ √

X X √ √ X X X X √

Short answer

Sequence table insertion

Merger of two singly linked lists

Delete the numbers greater than max and less than min in the singly linked list

Realize the in-place transposition of the sequence table

Thoughts

The test focus of linear tables is the characteristics of sequence tables and singly linked lists, as well as the addition, deletion, and modification of sequence tables and singly linked lists.

Update address: GitHub

For more content, please pay attention: CSDN , GitHub , Nuggets

Guess you like

Origin blog.csdn.net/weixin_42875245/article/details/109173385
Recommended