Data Structure Chapter 3 Stack and Queue Question Answer

First, the choice
1. The two storage structures usually used in the stack structure are ( A ).
A. Sequential storage structure and linked list storage structure B. Hash mode and index mode
C. Linked list storage structure and array D. Linear linked list structure and nonlinear storage structure2
. In the stack operation, the input sequence is (A, B, C, D), and the impossible output sequence is ( D ).
A. (A, B, C, D) B. (D, C, B, A)
C. (A, C, D, B) D. (C, A, B, D)
3. Assuming that the stack ST is represented by a sequential storage structure, the condition for the stack ST to be empty is ( B ).
A. ST.top-ST.base<>0    B. ST.top-ST.base= =0
C. ST.top-ST.base<>n D. ST.top-ST.base= =n
4. When inserting an s node into a link whose top pointer is HS, execute ( C ).
A. HS->next=s; B. s->next=HS->next; HS->next=s;
C. s->next=HS;HS=s; D. s->next=HS; HS=HS->next;
5. Delete a node from a link with HS on the top of the stack, and save the value of the deleted node with x, then execute ( C ).
A. x=HS; HS=HS->next; B. HS=HS->next; x=HS->data;
C. x=HS->data; HS=HS->next; D. s->next=HS; HS=HS->next;
6. A singly linked list without a leading node is used to store the queue, and its head pointer points to the head node, and the tail pointer points to the end node of the queue, when the dequeue operation is performed ( D ).
A. Only modify the team head pointer B. Only modify the tail pointer
C. Both the head and tail pointers of the team must be modified . Both the head and tail pointers of the team may need to be modified
. The common ground of stack and queue ( C ).
A. All are first in, last out All are first in, first out
C. Only allow insertion and deletion of elements at the endpoints D. Nothing in common
8. The entry sequence of a queue is 1, 2, 3, 4, and the output sequence of the queue is ( B ).
A. 4, 3, 2, 1 B. 1, 2, 3, 4 C. 1, 4, 3, 2 D. 3, 2, 4, 1
9. The circular queue SQ uses the array space SQ.base[0,n-1] to store its element values. Knowing that its head and tail pointers are front and rear respectively, the condition for determining that the circular queue Q is empty is ( C ).
A. Q.rear-Q.front= =n B. Q.rear-Q.front-1= =n
C. Q.front= =Q.rear D. Q.front= =Q.rear+1
10. The circular queue SQ uses the array space SQ.base[0,n-1] to store its element values. Knowing that its head and tail pointers are front and rear respectively, the condition for judging that the circular queue Q is full is ( C ).
A. Q.front= =Q.rear B. Q.front!=Q.rear
C. Q.front= =(Q.rear+1)%n D. Q.front!=(Q.rear+1)%n
11. If a circular queue is implemented on an array of size 6, and the current values ​​of rear and front are 0 and 3 respectively, when one element is deleted from the queue and two more elements are added, the values ​​of rear and front are respectively ( A ).
A. 1 and 5 B. 2 and 4
C. 4 and 2 D. 5 and 1
12. The head of the chain queue represented by the singly linked list is at the position ( A ) of the linked list .
A. Chain head B. Chain tail C.
13. In the chain . The condition for determining that a chain queue Q (the maximum number of elements is n) is empty is ( A ).
A. Q.front= =Q.rear B. Q.front!=Q.rear
C. Q.front= =(Q.rear+1)%n D. Q.front!=(Q.rear+1)%n
14. In the chain queue Q, the instructions to be executed in order to insert the node pointed to by s is ( C ).
A. Q.front->next=s;f=s; B. Q.rear->next=s; Q.rear=s;
C. s->next=Q.rear;Q.rear=s; D. s->next=Q.front;Q.front=s;
15. In a chain queue Q, the instruction to be executed to delete a node is ( C ).
A. Q.rear=Q.front->next; B. Q.rear->next=Q.rear->next->next;
C. Q.front->next=Q.front->next->next; D. Q.front=Q.rear->next;

two. Fill in the blank questions
1. ___ characteristics of the stack is advanced after ___, __ characteristics of the queue is FIFO ____.
2. Linear table, stacks and queues are __ linear ____ configuration, the linear table __ any ____ positions inserting and removing elements; ___ only stack for stack ___ position inserting and removing elements; ___ only queue for the tail___ Insert and delete elements at the head of the_____.
3. If there is a program as follows, the output of this program (the stack element type SelemType is char) is _stack______.
void main()
{stack s;
char x,y;
initstack (s);
x='c';y='k';
push(s,x);push(s,'a');push(s, y);
pop(s,x);push(s,'t');push(s,x);
pop(s,x);push(s,'s');
while(!stackempty(s)) {pop(s,y);printf(y);}
printf(x);
}
4. In the chain stack whose top pointer is HS, the condition for judging that the stack is empty is ___HS==NULL___.
5. Pushing elements into the stack and the operation is to first _save the elements _____, and then _ move the pointer on the top of the stack _ _ _ _ _ _.
6. When the stack is unstacked, the operation is to move the pointer on the top of the stack first _ _ _ _ _, and then _ take out the element _ _ _ _ _ _ .
7. And represents a queue length of n, if only the first pointer is provided, the time complexity and dequeuing enqueued circulating chain are ____ 1 __ __ and n- ____; if only provided a tail pointer is dequeued and enqueued time The complexity is __1____ and ___1___.
8. When deleting an element from the circular queue, the operation is to take out the element first, and then move the tail pointer of the queue___.
9. In a circular queue, the head of the team pointer points to the previous _____ of the element at the head of the team ___.
10. In a circular queue with n units, when the queue is full, there are a total of ___n-1___ elements.
11. In the HQ chain queue, it is determined that there is only one node and the condition is HQ.front=HQ.rear_____.
12. Suppose that the initial states of stack S and queue Q are empty, elements a, b, c, d, e, and f pass through stack S in turn, and an element enters queue Q after being popped out of the stack. If the order of these 6 elements out of the queue is b , D, c, f, e, a, the capacity of stack S should be at least ___3___.
13. As a program, the output of this program (where the element queue QSelemType type of char) is ___ char ___.
void main()
{char x='e';y='c';
enqueue(q,'h'); enqueue(q,'r'); enqueue(q,y);
dequeue(q,x); enqueue(q,x);
dequeue(q,x); enqueue(q,'a')
while(!queueempty(q))
{dequeue(q,y);printf(y);}
Printf(x);
}

Guess you like

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