Senior Engineer Interview Questions | Glassdoor

# Senior Engineer Interview Questions

7,485

Senior engineer interview questions shared by candidates

## Top Interview Questions

Sort: Relevance Popular Date

### Senior Systems Engineer at Qualcomm was asked...

Apr 25, 2012
 Given a wireless channel with loss rate 0.1, what's the throughput one can get with retransmission. 8 Answers It can modeled as binary symmetric channel. As to my understanding, channel capacity can be acheived with perfect feedback and simple retransmission scheme, so i guess the answer is 1-H(0.1). 10/(1.23456...)=8.1 packets per sec Interviewer was correct. With probability 0.1 you have one retransmission, with probability (0.1)^2 you have two, etc., since you can also lose the retransmitted packets, reducing the throughput to approximately 0.89. Show More Responses It is equivalent to simply a binary erasure channel with erasure probability 0.1, whose capacity is 1-0.1 = 0.9. aa should re-learn information theory and stochastic process First of all I don't think it has anything to do with the capacity of BSC. Note that h(0.1) = 0.46 and that means 1 - h(0.1) is roughly 0.5. If the packet error rate is 10% then BER is in the order of 0.1 / N where N is the length of the packet in bits. For that, the capacity of BSC is almost 1. In any case, in the non-ergodic case I believe the throughput is less than 0.9. Assume you want to send packets p_1, p_2, ..., p_k and each one takes N_1, N_2, ..., N_k time slots. Then, define the k-Packet Throughput (I made it up) as follows k-packet Throughput = (k / (N_1 + N_2 + ... + N_k)). Note that this throughput is a random variable. We can define the throughput based on this as the expected value of k-packet Throughput with respect to random variables N_1 , N_2, ... E[k-packet throughput] = E[ k / (N_1 + N_2 + ... +N_k)] 8' from the law of large numbers we have N_1 + N_2 + ... + N_k -> k E[N] = 1 / 0.9 * k. This suggests that k-packet throughput is a random variable which converges to its mean for large k, but for a finite k, its average is less than 0.9 All in all, I would have answered the question the way you did. In the long run, out of N transmissions you have 0.9 received and therefore the throughput should be 0.9 Model the problem based on the average number of transmissions it takes to deliver a packet. Let N be the number of transmissions. Then: Pr[N=1] = 0.9 Pr[N=2] = 0.1*0.9 Pr[N=3] = 0.1*0.1*0.9 ... and so on. The expected number of transmissions per packet is: E[N] = Sum{ k*Pr[N=k] } = 1*Pr[N=1] + 2*Pr[N=2] + 3*Pr[N=3] + ... where the summation index k goes from 1 to infinity. Then the throughput is 1/E[N] packets per transmission, which is 0.896... In the last solution, the number is calculated incorrectly. Accurate calculation gives the expected number of transmissions per packet E[N] = 1.11111, so that 1/E(N)=0.9, which corresponds to the reduction of transmission rate by exactly 10%, as suggested earlier. p=0.1 - probability of a packet transmission failure If we transmit a sequence of N packets with retransmission then an expected number of successfully transmitted packets will be E[N]=p*E[N-1]+(1-p)*(E[N-1]+1)=(1-p)+E[N-1], and as E[0]=0 it easy to solve the recursion: E[N]=N*(1-p) Expected number of successfully transmitted packets per one transmitted packet will be C[N]=E[N]/N=(1-p). The channel capacity is limit of C[N] as N approaching to infinity that is clearly equal to 1-p=0.9

### Senior Software Engineer at Palantir Technologies was asked...

Aug 26, 2010
 Given and array. How do you find if there are such three numbers whose sum is Zero. What is the cost of this algorithm? 4 Answers Iterate over array using two nested loops, calculate sum of any possible combination of two numbers and store result in the set. Cardinality of this set would be n^2. Then, iterate over the array once again and check if for element e, we have -e in the set. Cost of this algorithm is O(n^2). The solution suggested by the Interview Candidate is not suitable to solve this problem. Consider the array contains [-6 3], if you use that solution, you will end up in the last phase of the algorithm checking if a 3 exists in the array, which resolved to true. However there are no three numbers in the array that sum to zero; we just considered 3 two times. One solution is to keep track of the numbers used in each case, but that's an additional O(2n) space complexity. I propose a more efficient solution in O(n^2) time complexity and O(1) space complexity. Let's first sort the array in O(n log n) using quicksort; that's in place sort so no additional space requirements. At this point, all elements are sorted in ascending order. for (int i = 0; i j) { int sum = arr[i] + arr[j] + arr[k]; if (sum == 0) { return true; } else if (sum < 0) { // We need a larger number j++; } else { // We need a smaller number k--; } } return false; } Correction: the return false should be moved after the last brace. Show More Responses shouldnt variable j be initialized to i+1? otherwise the first time sum is computed it uses arr[i] twice?

Jan 2, 2014

### Senior Software Engineer at Nimbula was asked...

Mar 17, 2011
 What will this program do ? ======== int main(void) { char *s = "123"; s[0] = 'a'; printf("%s", s); } ======== 4 Answers It will print a23 if you are lucky. Otherwise it will core dump since "123" is a constant (kept in the text area of your program I believe) and its contents should not be modified. It will not crash because it is not a constant. You can consider it as a pointer pointing to a modifiable 4-bytes char array. "123" is not a modifiable 4-byte array. It IS a constant and should not be modified. Try this out on different platforms and see what it does. Show More Responses C99 has a const qualifier to define constants. It makes no claims about whether the mentioned array is a non-modifiable array. If your platform crashes and burns on modifying the array then your platforms "c" implementation has an error.

### Senior Hardware Verification Engineer at NVIDIA was asked...

Jan 29, 2010
 Describe a circuit that implements the following truth table using only NAND gates. A B OUT 0 0 1 0 1 1 1 0 0 1 1 1 6 Answers ((A NAND B) NAND C) out = (A NAND (B NAND B)) out = ((A NAND A) NAND (A NAND A)) NAND (B NAND B) Show More Responses OUT = (A NAND (B NAND 1)) or out = (A NAND (B NAND B)) like what anonymous said. OUT = A' + B OUT = A' + B.1= A' + B.(A+A') = A'+ BA+ BA'= A'(1+B) + BA = A' +BA= (A.(BA)')' [Demorgans] = (A NAND(A NAND B)) out = A' & B' + A' & B + A & B; => A' & B' + B => (A' +B) & (B' +B) => A' + B => (A NAND (B NAND B))

Jul 13, 2009
 Create a cache with fast look up that only stores the N most recently accessed items. 4 Answers Use a hash map and a queue. I think you can do better than hash map and a queue...or just simply it. Since you're only interested in the N most recently accessed items, an array is suffice. Because N is essentially the index right? To ml: N was not the index, instead some random key. The combined data structure had the implement the interface: Object get(String key); and void put (String key, Object obj); Besides the array isn't the best choice when you have to take an object out of the array and add it to the front of the queue every time the object is accessed. A double linked list works better. The hash map entries points to an item in the linked list, which then points to the object to be returned. This way you can find the item quickly to move it to the front of the queue. Show More Responses This answer below has the best solution: http://stackoverflow.com/questions/1935777/c-design-how-to-cache-most-recent-used

### Senior Software Engineer at Apple was asked...

Dec 16, 2011
 Print out, from small to big, of a sequence intergers, without sorting. 5 Answers priority queue then The problem refers to dynamic programming, Longest increasing sequence in the given array. The time complexity of solution is o(n2). Add the sequence of integers to HashSet, which will apply natural order and then print the collection elements. Show More Responses If the integers are within a small range, then create an vector array, loop through all integers and flag the array. Then print out. Construct binary search tree and do inorder traversal.

Apr 7, 2010
 Write algorithm to compute a Log to the base 2 of a number (integral results no need for floating point). Solution should not assume a particular size of integer 5 Answers result = 0 while(number != 1) { result++ number>>1 } return result // this c routine SHOULD compile and run ok regardless of sizeof (int) // It returns -1 for i<=0 as an error flag. otherwise it returns (int) log2(i) int l(int i){for(int j=0,k=1;k<=i;k<<=1,j++);return(j-1);} There are at least 2 bugs in the first proposed answer: "number >> 1" should be "number >>=1" Also, if initial value of number is 0 or less, this routine will infinite loop Likewise, the second solution only works for inputs less than 1/2 of maxint But I like it because it is concise :) Show More Responses public class Test2 { public static void main(String[] args) { System.out.println(new Test2().log(31)); // prints 4 } int log(int n) throws RuntimeException { if (n 0) { result++; n >>= 1; } return result; } } Binary numbers. The binary representation is in powers of two, like a logarithm. So. If you this "integer logarithm base-2" is the length of the binary representation of the number, minus one. def fast_log2(n): return len(bin(n)) - 3 Here I have to use "-3" instead of "-1" because Python's bin() function turns a number into a string with the prefix "0b".