Stack in C + +, stack rule: a,b,c,d,e

Source: Internet
Author: User

Questions:

Stack to the top of the stack once the element ABCD in the Fifth Element e into the stack before the stack elements can be out of the stack, then the stack sequence may be _____a d___________.

A. abced

B. Dbcea

C. Cdabe

D. Dcbea

Analysis:

1. Assuming that the stack sequence is from small to large rehearsal (that is, a<b<c<d<e), there is no "size" in the stack sequence, because the "large number" after the stack, "medium" in the stack is on the "decimal", so can only be out of the "median" and then out "decimal"
2. It is wrong to include the following sequence in the stack sequence: CAB,DAB,DAC,EAB,EAC,EAD,EBC,EBD, including adding other numbers in the middle of these sequences is the wrong sequence, such as CADB,CAEB (larger size).

For a. Answer: A into the stack, immediately out of the stack, b into the stack, immediately out of the stack, c into the stack, immediately out of the stack, d into the stack, e into the stack, e out of the stack, d out of the stack

For D. Answer: A into the stack, b into the stack, c into the stack, d into the stack, d out of the stack, c out of the stack, b out of the stack, e into the stack, e out of the stack, a out of the stack

Other answers are not possible, contrary to the above "big" "small", "medium" principle

Stack in C + +, stack rule: a,b,c,d,e

Related Article

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.