Cainiao B2B First Interview Experience Record, C++ Backend Development

Introduction

I’m a second-year master’s student, and my advisor doesn’t allow internships, but I interviewed for spring internships to gain interview experience. My resume is very simple and modest, so the interviewer’s questions were relatively easy. The first interview was scheduled for 7 PM on March 8, 2018. Since I was doing an Alibaba test the night before, the interviewer said the interview would be postponed by one day, which gave me time to prepare. I especially reviewed basic knowledge again, which was very helpful.

Self-introduction

  • Omitted

Project experience and its impact on you

  • Omitted

What are the four layers of network architecture?

  • I answered the physical layer which includes fiber optics, switches, and twisted pairs; the network layer with IP; the transport layer with TCP, ICMP, and UDP; and the application layer with HTTP and DNS.
  • Standard answer: Actually, the TCP/IP standard does not define functionalities corresponding to the ISO data link layer and physical layer. Instead, it defines protocols like the Address Resolution Protocol (ARP), which provides interfaces between TCP/IP protocol data structures and actual physical hardware. So the first layer should be the link layer, which includes the ARP protocol and device drivers.

Which layer are you most familiar with?

  • I answered the transport layer with the TCP protocol.

What are the differences between TCP and UDP?

  • Omitted

Three-way handshake and four-way termination?

  • Omitted

Why are you familiar with this process?

  • I answered that I mainly learned it from books. Of course, I also used it in projects and observed the process by capturing packets with tcpdump and Wireshark.

How does I/O multiplexing work?

  • I answered that it’s because multithreading is resource-intensive, etc. After listening for a while, the interviewer said that’s not what they meant; they wanted to know the implementation principle of I/O multiplexing. I replied that I had forgotten, but I remembered that in the implementation process of select, poll, and epoll, efficient data structures are used to check which file descriptor has I/O operations.

  • The standard answer is:

    The efficiency of epoll lies in the fact that when we call epoll_ctl to insert millions of handles, epoll_wait can still return quickly and effectively give us the handles with events. This is because when we call epoll_create, the kernel not only creates a file node in the epoll file system for us and builds a red-black tree in the kernel cache to store the sockets passed by epoll_ctl later, but also establishes a list to store ready events. When epoll_wait is called, it only needs to observe whether there is data in this list. If there is data, it returns; if there is no data, it sleeps until it returns when the timeout time arrives, even if the list has no data. Therefore, epoll_wait is very efficient. Another fatal weakness of traditional select/poll is that when you have a large socket collection, due to network latency, only part of the sockets are “active” at any time, but select/poll will linearly scan the entire collection for each call, causing efficiency to decrease linearly. However, epoll does not have this problem; it only operates on “active” sockets - this is because in the kernel implementation, epoll is implemented based on the callback function on each fd. Therefore, only “active” sockets will actively call the callback function, while other idle state sockets will not.

Explain polymorphism in C++

  • Omitted

What is a destructor and what is its purpose?

  • Omitted

What is the purpose of a virtual destructor?

  • Omitted

Should the parent class’s destructor be set as a virtual function?

  • Definitely yes

What is the difference between shallow copy and deep copy?

  • Omitted

If a function accepts an object as a parameter, is that a shallow copy or a deep copy?

  • I answered that it depends on the copy constructor. But I wasn’t sure about the specifics.
  • The standard answer should be: if references or pointers are used, no copying occurs. If the passed class hasn’t implemented a copy constructor, it’s a shallow copy. If it has implemented a copy constructor, it depends on whether the implemented copy constructor performs a shallow or deep copy.

What is a pointer in C language?

  • I answered that it’s first a variable that stores the address of the internal data type or object it points to. Dereferencing it retrieves the data or object.
  • In fact, a pointer is not necessarily a variable; there are also constant pointers, but generally, “pointer” is short for “pointer variable.” So the above expression doesn’t have any issues.

What is the difference between formal parameters and actual parameters?

  • Honestly, I wasn’t clear about this either. I said I didn’t know but explained pointers, references, and regular parameter passing.
  • Later I found out that actual parameters (arguments) refer to the parameters passed in when an external function is called, and formal parameters are the parameters used when processing inside the function.

Introduce the simulated annealing algorithm

  • Because it was mentioned on my resume

What is entropy, and what does an increase represent?

  • Omitted

The department primarily uses Java development. Would you be resistant if asked to do Java development?

  • Omitted

What would you like to know about the company?

  • Omitted

Aftermath

Total duration was 27 minutes. I spoke rather quickly and was a bit nervous and excited. That’s about it, and I’ll add more if I remember anything else.

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy