Wechat official account: Wanmao Society

I arrived at the interview site on time on a sandy-filled morning. After answering the smirk from the receptionist, I sat down in the conference room and waited for the interviewer to ravage me.

Not long after, a man with glasses opened the door and came in.

He came in and said to me, “You are **, aren’t you?”

I see this is the interviewer ah, dare not neglect, hurriedly got up and smiled: “Yes, today to interview.”

The interviewer then said, “Today the sandstorm was really bad. You still made it on time.” I said, “Yes.”

1. Cut to the chase

Let’s cut to the chase and start with some basic questions. What is the difference between a stack and a queue?

I smiled and said, “First of all, stacks and queues have something in common. They are both finite sequences of several elements with the same data properties, called linear lists.”

The queue

A queue is a linear list that limits the insertion of elements to one end of the table and the deletion of elements to the other.

In a queue, the end that allows insertions is called rear and the end that allows deletions is called front.

Queues follow the principle of First In First Out (FIFO).

The stack

A stack is a linear table that limits insert or delete operations to the end of the table.

In the stack, the bottom of the table has its special meaning, which is called the top of the stack, and correspondingly, the head of the table is called the bottom of the stack. An empty table with no elements is called an empty stack.

The stack follows the principle of Last In First Out (LIFO).

2. Shake alert

Seeing the interviewer’s satisfied smile, I couldn’t help shaking up a clever: “Just said more abstract, I have been using an example to understand, I don’t know here can say.”

The interviewer nodded and said, “Sure, go ahead.”

I asked the interviewer, “Do you know the mushroom has a nickname?”

The interviewer was very curious and asked: “Really don’t know, what nickname?” .

And I said, “The nickname for flammulina mushroom is See you tomorrow. Why the nickname? Because after eating flammulina mushroom, it is not easy to digest the next day’s xiang li has it. For example, yesterday you had flammulina mushroom for lunch and dragon fruit for dinner. Today’s xiangli has flammulina mushrooms first, and then the red ones. That’s what queues are all about: first in, first out.”

The interviewer clears his throat: “Ahem! Your example smells a bit strong.”

Without answering, I asked, “Do you know about hydroids?”

The interviewer said, “I don’t know, what is it?”

“Hydra,” I replied, “is a type of coelenterate that feeds chiefly on fish and worms but also on beef scraps. The point is that it has a mouth and no chrysanthemums, and its shit comes out of its mouth. For example, a polyp first ate a fish worm, then ate some beef crumbs, after digestion, the beef crumbs out of the mouth first, fish worms out of the mouth. That’s the nature of the stack: last in, first out.”

The interviewer put his hand over his mouth and twitched several times. In the last twitch, his cheeks swelled and a few drops of white liquid oozed between his fingers, probably milk or soy milk for breakfast.

The interviewer, a man who had been through a storm, was able to cope with this little situation, and when his throat moved, he swallowed again.

Thanks to the students of one key three even, handsome and beautiful!

The best time to plant a tree was ten years ago. The second best time is now. ** For programmers who are learning to program or want to be promoted at work, if you want to improve your programming skills, help you improve! ** I may be able to help you here ~

C language C++ programming learning exchange circle, QQ group [765803539] wechat official number: C language programming learning base

Share (source code, project actual combat video, project notes, basic introduction tutorial)

Welcome to change careers and learn programming partners, use more information to learn and grow faster than their own thinking oh!

Programming learning video sharing: