First, ask about the thesis/research, which is easy to solve.
1. output the last 10 digits of 1234567*(2 ^ 987654321)
The answer is (1234567*(2 ^ 987654321) % (10 ^ 10). The key is how to calculate this number.
Use the modulo operation. Modulo fulfillment allocation rate: (A * B) % C = (a % C) * (B % C) % C
2 ^ 987654321 can be divided into 2 ^ m * 2 ^ m *... * 2 ^ n (m> = N ).
2. What is the average complexity of inserting an element in arraylist in Java?
O (1). The answer is poor. Visible data structure: Linear table/array section.
After the interview, I immediately entered another one, or the person on the other side, but another one.
It may be a matter of coordination. The two people will face me at the same time.
The second person also asked questions about scientific research, which soon ended.
1. How do I obtain the intersection between the two sets?
Similar to the join operation in the DB, there are two types: Merge/hash.
Merge: sort the two sets in order, and then use the method similar to merge to take the intersection.
Hash: Create a hash table with a relatively small set, and search for each element in a large set in the hash table. All elements that can be found are the intersection.
Then I asked why I should not use a relatively small hash table. Why?
Because small hash tables occupy a small amount of space, searching is fast.
For example, if the size of a hash table is 1 and the size of the other table is 100, you can use the hash table of 100 to obtain the intersection after one query.
Almost fell into the trap. However, I immediately replied: creating a hash table is overhead.
2. What is the idea of fast sorting?
Recursive Division: divides a group that is smaller than the number in the middle to one side, and the other side is larger. It will be done when the length of the list is 1.
3. What is the average complexity of the fast rank? Maximum complexity?
Average O (N * logn), maximum O (N ^ 2 ).
4. Why is the average complexity of the fast sorting O (N * logn )?
The answer is poor.
5. Now there is a single-chip microcomputer that only provides single-byte (char) read/write functions. How can I support float read/write?
Convert to multiple char-type operations.
6. Now there is an advertising system. How can we ensure rank fairness?
Open Question. For example, if there are two advertisements, the click/display of advertisement 1 is 10/10000, advertisement 2 is 1/10, and advertisement 3 is 0/5, how can we display them fairly?
The implication is that the CTR of AD 1 is 1/1000, which is a relatively stable CTR (because the number of impressions is already large). Although Ad 2 has a relatively high CTR, it is rarely displayed, it cannot be determined whether it is truly popular (the previous click may be accidental, and may not be clicked in the next tens of thousands of times); although advertisement 3 is the lowest, however, there may be no points for the moment. Therefore, it is not fair to simply rank by click rate.
The core issue is:
1) how to give new advertisements a chance (such as advertisement 3 );
2) at the same time, let those difficult-to-hit advertisements sink quickly (for example, advertisement 2 has never been clicked since then, and how to let it sink quickly. It is very slow to fall below 1/1000 only through the click rate ).
My ideas:
1) give each newly added advertisement a high starting value I
2) Add the non-click attenuation factor C to accelerate sinking when a hit occurs.
For example, if the current rank = click/show = H/S. is displayed next time, and then click, the rank is changed to (H + 1)/(S + 1) (this is not changed for the time being)
However, when the display is not clicked, rank is not simply changed to H/(S + 1), but updated to H/(S + 1 + C) with an attenuation factor ), c> 0.
Then the other party asks how to determine the reasonable I and C values?
I used historical data for simulation. Suppose there are n ads (A1, A2,..., an) in T1 time point. The rank value set is R1.
Now, we can roll back the time To T0 (Initial State), and then consider different I and C values to simulate the advertising, presentation, and access processes in (T0-> T1) time periods, i, C, T1, N ads (A1, A2 ,..., an) rank value set r1 '.
Compared with R1 and r1', whether r1' has a better differentiation degree than R1 (that is, whether r1' has a lower level in R1, whether the relatively high value in R1 is higher in r1)
After several iterations, the optimal I and C values are calculated. The discussion is complete.
I feel I should be able to get an offer.
Lesson: The algorithm analysis capability is too poor.
Update: Get offer.