Data Structure final review chapter II linear table

Source: Internet
Author: User

Chapter Two: Linear table 1. Basic characteristics of linear structure
A: a linear structure is an ordered (sequential) set of several data elements
There must be only one "first element" in the ① set;
There must be only one "last element" in the ② collection;
③ except for the first element, there are only precursors;
④ except the last element, there is a unique successor. 2. The sequential storage structure and the chained storage structure of the linear table are ___ respectively. D
A. Sequential access storage structure, sequential access storage structure
B. Sequential access storage structure, random access storage structure
C. Random access storage structure, random access storage structure
D. Random access storage structure, sequential access to the storage structure of the analysis: parsing:The address of the sequential storage structure is contiguous in memory so that random access can be achieved by computing the address .but the storage address of the chain storage structure is not necessarily continuous, only through the first node of the pointer sequential access;

3. A batch of data in sequential storage structure, the first element of the storage address is 200, and each element length is 2, then the storage address of the 5th element is (B)
A, B, 208
C, D, 220

Analytical:

The order of the linear table means that the data elements in the linear table are stored sequentially with a contiguous set of storage units, and the starting address of the linear table is called the base address of the linear table.

Method One:

Where all data elements are stored depends on where the first data element is stored
LOC (AI) = loc (A1) + (i-1) x length of each element
↑ Base Address

208 = 200 + (5-1) * *

Method Two:

The first element has a storage address of 200,

The second element has a storage address of 202,

The third element has a storage address of 204,

The fourth element storage address is 206,

The Fifth Element storage address is 208.

4. When looking for a node that has a value equal to X from a single linked list with n nodes, the average (D) node needs to be compared when the lookup succeeds.

A) n B) n/2 C) (n-1)/2 D) (n+1)/2
Analytical:

In a single-linked list of n nodes, the number of times that I need to compare the keywords is

So in the case of successful search, the average number of nodes to be compared is (1+2+...+n)/n= (n+1)/2

5. In a single linked list, the purpose of adding a head node is to (A).
A) The implementation of the convenient operation B) used to identify a single-linked list C) so that a single linked list has at least one node D) used to identify the location of the starting node

Analytical:

The head node identifies not only the position of the first node in the table, but also the structure of the single-linked list (including the head node).

As long as the table header is mastered, the entire list can be accessed, so the purpose of adding the head node is to facilitate the implementation of the operation.

6. How are struct members accessed?

A:1. Access to members in struct variables
For example: Lnode A;
A.data; A.next;
2. Access to members in the node referred to by the struct pointer
For example: Lnode *p; or linklist p;
p->data; p->next;

7. What is the difference between a single linked list with a lead node and a non-lead node in a single linked list l?
For:
lead node: l->next = NULL

No lead node: L = NULL

8.p->data = ai, then P->next->data =?
Answer: p->next->data = ai+1

9. The time complexity of inserting a new node in an ordered single-linked list with n nodes and still ordered is ()
A.O (1) b.o (n)
C.O (n*n) D.O (nlog2n)

Analytical:

This paper mainly examines the insertion operation and algorithm analysis on the ordered single-linked list. Any manipulation of the data structure does not alter its original structure characteristics.

Therefore, after inserting a new node in an ordered single-linked list, it remains orderly.
The key to the insert operation is to find the insertion position, and the time is also spent on finding the insertion position.

A single-linked list of n nodes, having, n+1 a position that may be inserted, that is, before the first node and after each node.

Before the first node is inserted, a comparison is required;

After the first node is inserted, it should be compared two times; ;

After the first n nodes are inserted, you need to find the secondary.

If the probability of inserting at each position is equal, i.e. pi=1/(n+1),

The average number of comparisons to find the insertion position on an ordered single-linked list is:

--------------------------

10. If the most common operation of a linear table is to access the elements of any given sequence number and insert and delete operations at the end of the table, use (A) storage is the most time-saving method.
A Order table B. Doubly linked list
C. Two-way loop linked list D for the lead node. Single Cycle linked list

Analytical:

The best way to "access any specified sequence number" is to implement "random access", which can take the order table.

And, since both the insert and delete operations are done at the end, there is no need to move the data elements a lot, and option A is the most appropriate.

11. The most common operation in a linear table is to insert an element after the last element and delete the first element, using the (D) storage method to save the most computational time.
A Single-linked list B. Single-loop linked list C with only the head pointer. Double-linked list D. Single-loop linked list with tail pointers only

12. If the most common operation in a linear table is to insert and delete elements before the last element, then __ d___ is the most time-saving operation.

A Single-linked list B. Single-loop linked list C with only the head pointer. Double-linked list D. Single-loop linked list with tail pointers only

Analytical:

The single-linked list, starting with the first table in the list, stores the nodes of the linear table sequentially in each of the table elements of the linked list. In addition to storing linear table node information, each table element of a list has a pointer to the component that stores its successor.

The circular linked list is a single-linked list, characterized by the pointer field of the last node in the table pointing to the head node, and the entire list forming a ring.
As a result, other nodes in the table can be found from any node in the table. in a circular list, the end condition at which the pointer begins to traverse is not whether the pointer to the node is empty, but whether it is equal to the head pointer. to simplify operations, the table header nodes are often added to the circular list. There are two pointer fields in the nodes of the doubly linked list, one pointing to the direct successor, the other pointing to the direct precursor, overcoming the disadvantage of single-linked list's unidirectional nature.

13. The most common operation to set up a list is to insert the node at the end and delete the tail node, then choose (D) The most time-saving.
A. Single-linked list B. Single-cycle linked list

C. Single-loop linked list with tail pointer d. Double-loop linked list with lead node

Analytical:

Problems arise in search efficiency

The most common operation of a list is to insert a node at the end and delete the tail node, and in the tail insert delete operation, all need to know his leading

and single linked list to find out that the most one element needs to traverse all the linked list
The doubly linked list can be traced directly to the preamble, the most common operation is to insert an element after the last element and delete the first element,

Deleting a head node requires a head pointer or just a->next domain to find out how fast it is.
There is a second condition to remove the last element with a tail pointer, which is the best way to find the tail element, and he's also a circular link, so his->next is the head node.

14. The list does not have the characteristic that (B)
A Insert, delete do not need to move element
B Random access to any element
C No need to estimate storage space beforehand
D The required space is proportional to the linear table length

Analytical:

The address of the sequential storage structure is contiguous in memory so that random access can be achieved by computing the address

Linked list is a chain storage structure, its storage address is not necessarily contiguous, only through the first node of the pointer sequential access, can not achieve random access to arbitrary elements.

15. The pointer in a static linked list represents (B).
A Memory address B. Array subscript
C The next element addresses D. Left and right child address

Analytical:

The so-called static linked list is no pointer, using subscript to imitate the function of the pointer

Data Structure final review chapter II linear table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.