A friend of mine came over for an interview and raised a small topic.

Source: Internet
Author: User

A friend of mine came over for an interview and raised a small topic.

 

Interviews with many companies, including Ctrip, are mostly asked about algorithms. The interviews with the ticket business department are basically the hardest hit by algorithm problems.

Use the data structure to test the complexity of some common data structures and some hand-writing algorithms, such as fast sorting and single-chain table, A friend I recommended a few days ago got an arrow in his lap.

The question is not specific. The first small question is to build a single-chain table with non-recursion. We know that building a single-chain table is the basic skill of learning the data structure, it follows Recursion

There are also a lot of links, many chain problems, we can easily solve with recursion, almost no need to move your mind, but if it is not recursive, it is a little more complicated than recursion.

At least one example of memory allocation for the reference type will be taken.

Later, on QQ, I constructed a single-chain table in recursive and non-recursive forms and replied to him. I first gave him a recursive version, which is no problem and can be digested, then I gave a non-recursive version. After reading it, I took it

No.

 

I. Recursive version

 1 class LinkList 2     { 3         public class LinkNode 4         { 5             public int data; 6  7             public LinkNode next; 8         } 9 10         private LinkNode head;11 12         public void Add(int data)13         {14             if (head == null)15             {16                 head = new LinkNode() { data = data };17             }18             else19             {20                 Add(head, data);21             }22         }23 24         public void Add(LinkNode node, int data)25         {26             if (node.next == null)27             {28                 node.next = new LinkNode() { data = data };29                 return;30             }31 32             Add(node.next, data);33         }34     }


Ii. Non-recursive version

 1    class LinkList 2     { 3         public class LinkNode 4         { 5             public int data; 6  7             public LinkNode next; 8         } 9 10         private LinkNode head;11 12         public void Add(int data)13         {14             LinkNode node = new LinkNode() { data = data };15 16             if (head == null)17             {18                 head = node;19             }20             else21             {22                 LinkNode temp = head;23 24                 while (temp.next != null)25                 {26                     temp = temp.next;27                 }28 29                 temp.next = node;30             }31         }32     }


What this non-recursion does not understand is the temporary variable temp. The question raised is: Why does the head value change after "temp. next = node? I cannot understand it.

The memory allocation of the reference type is unknown, and this non-recursive version uses the memory allocation technique of the reference type to implement "non-recursive construction of a single-chain table". In order not to let others step on this trap, I am still big

Let's look at the process. This is probably the case. When we create a new reference type, the CLR will calculate the size of the Instance field and the instance field on all base classes, then allocate reasonable memory blocks on the stack,

Finally, save the first address of the memory block on the stack.

 

For ease of understanding, it is assumed that the LinkList contains three nodes: instance1-> instance2-> instane3,

First sentence:

1 LinkNode temp = head;

 

It is easy to understand this sentence. Assign the head address to temp, And the temp address on the stack is the head address. The head address is the address pointing to the instacnce1 memory block address.

 

The second sentence: From this while sentence, we can see that we are always looking for the next of the instance. We can see that we have given the memory address of instance2 to temp, and then we will give the memory address of instanc4to

After temp, it is found that the next Of instan2010is null and then jumps out of the loop.

1                 while (temp.next != null)2                 {3                     temp = temp.next;4                 }

The third sentence: from the previous sentence, we can see that the next Of instan2010is already null. At this time, we will assign the new node: LinkNode node = new LinkNode () {data = data };

Run the next pointer to temp to build a linked list.

1 temp.next = node;

It can be seen that at this time, instance4 is constructed to instane3, and temp. next is already the memory address for saving instance4. These operations are transparent to the head, and they do not matter.

When you traverse the head, you will be surprised to find that I have an instance4 in my linked list. This is where my friends are confused. If you see this memory distribution chart,

It may suddenly become open-minded. Of course, this blog post has no technical skills and I feel it for a while.

 


I am a fresh graduate. I have been interviewing recently, but I have asked me to go back and wait for the news, so I didn't believe it. Later, an interviewer from a company said that I think I am too long.

I think the image is just the first impression. The most important thing is whether you feel stable and reliable. In just a few minutes of the interview, do you have a good grasp of the time to express yourself? It makes people feel that although you look younger, you are very mature.
Unless the interviewer asks you, do not ask questions about the class leader, the number of credits, and the scores of which subjects are better, others will think that you are still in the learning period and have not invested in society.
You don't have to rush to answer a question. It takes a few seconds to answer it. There is no need to repeat the content on those resumes one by one, such as the graduation School, age, height .... you don't have to make it clear. I will talk more about the experience and insights related to the industry you are interviewing.
In fact, young people also have the advantages of being young. Just like white paper, they have just stepped out of the society and are easy to accept new things. They are easy to integrate into the corporate culture. Unlike old employees, they have formed their own work models, it is very difficult to improve. It depends on whether you can turn your shortcomings into advantages.
Of course, in terms of external image, you should also pay more attention to the fact that wearing dark formal attire is safe, light makeup, and special attention to hair styles. It is best not to wear a ponytail. It feels like a little girl, long hair is recommended to have a curly hair, while Qi liuhai's suggestion is to separate the bangs.

Full score helps me with a small problem encountered during the interview

I think your answer should first eliminate the other party's worries and analyze the worst case with others.
Next, let's talk about how to score points if there is any benefit.
Of course, the key is not to be too nervous during the interview.
As many people mentioned above, we need to eliminate embarrassment, fear, and so on.
Outgoing vertex.

I have read the best answer from the upstairs and try again ~~

I. planning stage.
First, the purpose of planning should be clear: persuade the other party to establish a cooperative relationship with you. How to persuade? This is the key to the problem. I believe that the entire persuasion process is based on the two sides, that is, after analyzing the advantages and disadvantages of both sides, we will propose a cooperation solution that will benefit both sides. I suggest you think like this:
(1) What does the other party need?
Although requests vary, in the final analysis, it is clear that the other party hopes to generate publicity benefits through cooperation, thereby bringing economic benefits; I want to invest 1 RMB to bring him 10 RMB or more of the complicated sponsorship activities .)
(2) What are our advantages and how to leverage them?
This is the answer to the previous question and the basis for persuading the other party to cooperate with you rather than with him.
(3) combine the two, analyze the basis of the cooperation between the two parties, and propose a cooperation plan to make the promotion benefits of the other Party effective, that is, the Plan book.
Of course, before planning a book, we should first conduct investigation and research based on the above ideas, find feasible partners, and make it as targeted as possible.
In the process of searching for partners, we need to consider the point of fit between our advantages and the other party. Compared with school activities, the school activities have an advantage in publicity. Each department also has its own characteristics, such as the computer department to find a computer business; the sports department to find sports equipment for franchise, Music Department, Foreign Language Department, because there are many girls, looking for beauty salons, fashion makeup, and other businesses, theoretically speaking, the success rate is relatively high. In addition, the activity itself also has its own characteristics. For example, if the Mandarin contest cooperates with the bookstore, it will feel more "counterpart" than the dance party ". This is of course an important condition to persuade the other party.
When planning books, you must pay attention to self-positioning, that is, to emphasize equal partnerships: You provide financial resources, I provide manpower, and we will do a good job together; I get your support to make the activity smooth. You get advertisement promotion during the activity, which is a win-win situation. Therefore, the author suggests that self-positioning should not be too arrogant, but should not be too low or "cheap", because sponsorship is essentially cooperation.
This requires us to be as objective and rigorous as possible in the planning book, and highlight propaganda methods and implementation details as much as possible. In addition, you must be honest and be honest about what you can do, what you can't do, what advantages you have, and how you can use them ...... At a glance, I will never open a blank check and try to make the seller feel like you are responsible, experienced, and considerate.
The campus planning book generally consists of several components: Activity introduction, activity arrangement, promotion methods, promotion benefits, budget and so on. As for how to write a planning book, I think this is just like writing a composition. It is enough to clarify the idea, but there is no fixed and omnipotent model. I suggest you think like this when writing a planning book: My goal is to persuade the other party to cooperate with me, so what materials should be prepared and how they should be organized, everything revolves around how to persuade the other party most effectively, because the final criterion for measuring a planning book is: whether to reach the target of persuading the other party.
You must pay special attention to the budget. The author's opinion is that it should be as clear and detailed as possible, with a clear view of how much cash and items are needed, where the cash is spent, and how the items are used. Try to leave the impression to the other Party: it is not a charge, but a basic requirement to ensure the smooth running of the activity. Every penny you use is worth a bit, and you are sincere in cooperation.
Ii. negotiation stage.
If the planning stage is "show love", the negotiation stage should "confirm the relationship. Therefore, the focus of this phase is to resolve the doubts of the other party, discuss the Cooperation details, and finally determine the specific cooperation model.
First, you should pay attention to some etiquette details, such as (1) dress neatly and be as sedated as possible. It implies to the other party that I respect you. I am competent and experienced; (2) Don't be late, show me to the other Party: I am punctual, I am trustworthy, and cooperation with me is correct; (3) No bad habits, such as rubbing your nose and digging your ears, you must pay great attention to the rough talk, especially when the two sides meet for the first time. Of course, this requires us to cultivate good habits at ordinary times.
Second, we should make full use of speech, tone, tone, speed, gestures, and so on to persuade the other party. Note: You can only persuade yourself in advance to... the rest of the full text>

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.