# 1 k

Questions d'entretien pour Systems Developer partagées par les candidats

## Principales questions d'entretien

Trier: Pertinence|Populaires|Date
On a demandé à un Systems Software Engineer...27 avril 2012

### Given a page size and a number, align the number with the nearest page. (Note: This was a phone interview question. The interviewer and I used an online document to share ideas about this problem.

7 réponses

I think that at the faster solution you mean int getAlignedValue_Fast(int pageSize, int valueToAlign) { return valueToAlign &amp; ~(pageSize-1); } Note: There is a difference between !(pageSize-1) and ~(pageSize-1) ~(0x11) is 0xee !(0x11) is 0 Moins

I just wanted to point out that the "faster solution" only works if the pageSize is assumed to be a power of 2. For example, suppose pageSize = 10 (or 01010 in binary), and valueToAlign = 24 (or 11000 in binary), then the fast method would give 16, but it should be 20. Anyways, thanks for posting the question and solution. Moins

@observer I see how the mask works out for the alignment, why it is works mathematically? Thanks Moins

Afficher plus de réponses

### identify the number of 1s in an integer is odd or even

7 réponses

Was taken from: http://graphics.stanford.edu/~seander/bithacks.html unsigned int v; // word value to compute the parity of bool parity = false; // parity will be the parity of v while (v) { parity = !parity; v = v &amp; (v - 1); } Moins

Above solution is incorrect. void OnesAreOdd(int n) { int i=0; while(n!=0) { n=n&amp;(n-1); i=i^1; } return i==1?true:false; } Moins

Let number be c int count = 0; while ( c != 0 ) { count += (c &amp; 1); c &gt;&gt; 1; } if ( count%2 == 0) printf("Number of 1s are even); Moins

Afficher plus de réponses

### Implement memcpy.

4 réponses

you should care about how src and dest are overlapped, and copy from left or from right. Moins

void my_memcpy(void *dst, void *src, int size) { for(int i=0; i Moins

void memcpy (void *dest, void *src, size_t length) { int *currSrc = src; int *currDest = dest; chat *charSrc, *chardst; size_t nTimes = length / sizeof(int) for(int i=0; i Moins

Afficher plus de réponses

### How would you triage and go about fixing infrastructure problems? Giving an input file, get the number of lines matching a specific piece of text using bash scripting. Give the percentage of lines in the file that match that string.

3 réponses

1.) I said hard to tell because that is a very vague question. 2.) Use grep and awk and wc. 3.) Use the above plus "bc" to calculate percentage. Moins

for: 2.) Use grep and awk and wc. I believe grep + uniq + wc would be better and simpler, right? Moins

for: 2.) Use grep and awk and wc. 'grep -c' is enough

### write a function to set a particular field of register to the desired value. ( For example, set bit 3 - 10 of a word to the given value)

3 réponses

Example: Value=0x1234 Desired Bits are 0,1, 7 &amp; 15 Desired value=0x8083

Example: Value=0x1234 Desired Bits are 0,1, 7 &amp; 15 Desired value=0x8083

Have you tried using this website? www.rooftopslushie.com It says you can get career advice and interview prep info from Nvidia employees. Moins

### You are hosting a party with 1000 bottles of wine and 10 servants, however, one of the bottles has been poisoned. How do you determine, using the servants, which bottle of wine is poisoned?

3 réponses

The below solution comes at the answer in 1 single try: Let the bottles have a 10 digit binary number (supports upto 1024 bottles). Servant 1 drinks from all bottles whose first binary digit is 1, and leaves those with digit 0 alone. (500 bottles) Servant 2 drinks from bottles with 2nd binary digit 1, and leaves alone digit 0, and so on. Depending on whether the servant dies or not, you have the binary digit that corresponds to him, and can root out the bottle with one iteration. However, this can kill upto 9 servants in single try depending on the number on the poisoned bottle. (Killing all 10 not possible as a number with all ones will number 1023, we dont have that many bottles) Moins

Let's divide the 1000 bottles among 10 servants. This way each servant has to check for only 10 bottles and they can start at the same time. If any servant dies, all other servants stop (given, only one poisonous bottle) ... So we know the exact bottle which is poisonous. Worst possible case, a servant needs to check all 10 bottles and the last bottle has poison. Moins

You can determine which bottle was poisoned by having a unique combination of servants try every bottle. For example servant 1 and 2 will try bottle 1. Servant 1, 2, and 3 will try bottle 2, and then continue on but with a unique combination of servants testing the bottles. Moins

### 5 bags, each bag has some balls. 1 bag has faulty balls. There are faulty balls weighing 1.1kg and good ones weighing 1kg. There is a weighing machine. Determine in how many measurements can you find the bag with faulty balls and which bag contains it.

3 réponses

I like the other answer a lot, but it assumes that all balls in a bag are the same. When I read the question, I don't think that's a safe assumption (but the interviewer would probably clarify). In the case of there being a mix of good and faulty balls in the faulty bag, I'm going to guess 4 measurements. Group pairs of bags, weighing bags 1+2 together, then 3+4 together. That's 2 weight measurements so far. If these measurements are the same, then bag 5 is the faulty bag. If they're not the same, then of whichever group is heavier, weigh each of those bags. The faulty bag is the heavier of the 2 remaining bags. That's 2 more measurements, for a total of 4 Moins

Interesting q. Lets name the bag 1,2,3,4 and 5. Correspondingly take one ball from bag 1, two ball from bag 2, three ball from bag3... Total weight should come 15kg. If weight comes out as 15.2 kg, then bag two has defective balls. Similarly if it comes out as 15.3 kg, the bag three has defective balls. Moins

Can you highlights key points of your profile

### Say the program you are running has stack overflow. You want to know when and where this happens, but you don't want to use debuggers, because they slow. How would you do this?

3 réponses

Manual Inspection or Ram dump should help

write a pattern to end of stack. uint32_t *StackPtr = (uint32_t *) 0x7FFFFFFF; //0x7FFFFFFFis end of stack *StackPtr = 0xDEADBEEF; A memory dump or a simple check in your code like will suffice if (*StackPtr != 0xDEADBEEF) { //Stack overflow } Moins

Align the stack memory at the end of a read only memory, this would cause an automatic err fatal Moins

### 1. You have two strings. A test string and a glob Test string can have a & b, any number of times, any location. Glob can have a, b, ? and *, any number of times, any location. E.g. test= {a,b,a,a,a,a,b,b,b,b,b,b} glob = {a,?, *, b} Now, ? means ANY character, single occurrence. So it's either a or b, one time * means ANY OR NO character, any number of occurrences. E.g. the above glob and test actually match. Problem is: write an algorithm to match glob with test. You MAY NOT use regular expressions :D 2. The input is any string of any length of any characters. Write a program to generate ALL unique permutations of those characters. Unique. You may not store in an array or list, due to memory constraints. e.g. for input of abc your program should give 6 permutations but for aba your program should give 3. Hint: make the list alphabetical.

3 réponses

public class perm { public static void main(String[] args) { // TODO Auto-generated method stub String input = "abcdefg"; permutation(input, ""); } private static void permutation(String input, String sofar) { // TODO Auto-generated method stub if (input.equals("")) { System.out.printf("%s,", sofar); } for (int i = 0; i &lt; input.length(); i++) { char c = input.charAt(i); if (input.indexOf(c, i + 1) != -1) continue; permutation(input.substring(0, i) + input.substring(i + 1), sofar+c); } } } Moins

#include #include #include using namespace std; void str_permute(char *str, int start, int end) { if (start == end) { cout &lt;&lt; str &lt;&lt; endl; return; } bool char_set[256]; memset(char_set, 0, sizeof(char_set)); for (int i = start; i != end; ++i) { if(char_set[str[i]]) { continue; } char_set[str[i]] = true; swap(str[start], str[i]); str_permute(str, start+1, end); swap(str[start], str[i]); } } int main(int argc, char **argv) { str_permute(argv[1], 0, strlen(argv[1])); return 0; } Moins

As for the "regex" question, one way to go about solving this would be to create an NFA (non-deterministic finite automaton), turn it into a DFA (deterministic finite automaton), and manually parse the string. If the glob has length L and the query string has length M, constructing the DFA takes O(2^L) time and O(2^L) space while running the query through the DFA takes O(M) time. Moins

### If we have a string : "abc ef 12 g", write a function that takes the pointer to the string reorganizes the string to be: "g 12 ef abc". Note that there are 3 spaces after abc, 2 spaces after ef, and 1 space after 12 in the original string, but the spaces are reversed. So in essence, write a function to reverse a string and then put the words between the spaces back in order. And the string length can be known or not.

3 réponses

I answered the question miserably....and didn't get to finish this question and obviously this may not be the best way to do it. assuming we know the string with strlength characters that are not \0 void myfun(char* string) { reverseString(string) //Reverse the characters between spaces here... } void reverseString(char* s) { for(int i = 0; i &lt; strlenth/2; i++) { swap(s+i,s+(strlenth-1-i)); } } void swap(char* c1, char* c2) { char ctemp = *c1; *c1 = *c2; *c2 = ctemp; } Moins

#include #include using namespace std; void myReverse(string &amp;str) { // First reverse the whole string : lkjol fdha hh eds reverse(str.begin(), str.end()); // Now iterate through and reverse sections separated by space string::iterator beg = str.begin(); string::iterator end = str.begin(); while (end != str.end()) { while ((*end != ' ') &amp;&amp; (end != str.end())) end++; reverse(beg, end); while ((*end == ' ') &amp;&amp; (end != str.end())) end++; beg = end; } } int main() { string mystring("sde hh ahdf lojkl"); cout &lt;&lt; "\n str = " &lt;&lt; mystring.c_str() &lt;&lt; endl; myReverse(mystring); cout &lt;&lt; "\n Afer str = " &lt;&lt; mystring.c_str() &lt;&lt; endl; return 0; } Moins

Through questions like this, interviewers are mostly trying to test your skillset (and its relevance to the role) as robustly as possible, so be prepared for multiple offshoots and followups. It could be a useful exercise to do mocks with friends or colleagues in Nvidia to get a real sense of what the interview is actually like. Alternatively Prepfully has a ton of Nvidia Systems Software Engineer experts who provide mock interviews for a pretty reasonable amount. prepfully.com/practice-interviews Moins

1 - 10 sur 1 266 questions d'entretien d'embauche

## Consultez les questions posées en entretiens pour des emplois similaires

applications developersoftware developersenior developersoftware engineer