Nvidia interview prep
8 practice questions on the topics candidates reported from Nvidia interviews, with answers. The questions are ours; each one links to the interview report that names its topic.
DSA 3
-
In [4, 3, 6, 2, 6, 4, 2, 3, 4] every number occurs an even number of times except one. XOR all the numbers together. What is the result?
- 0
- 3
- 6
- 4
Show the answer
D. 4
x ^ x = 0 and XOR is order-independent, so every pair cancels and only the odd-count number is left. 4 appears three times; one copy survives. O(n) time and O(1) space.
This topic is named in a candidate’s interview report: System software engineer interview, on GeeksforGeeks.
-
A sorted array of distinct numbers has been rotated, for example [5, 6, 7, 1, 2, 3, 4]. A binary search finds its minimum by comparing arr[mid] with arr[high]. If arr[mid] > arr[high], where is the minimum?
- At mid
- Somewhere to the left of mid
- Strictly to the right of mid
- At index 0
Show the answer
C. Strictly to the right of mid
arr[mid] > arr[high] means the drop happens after mid, so set low = mid + 1. Otherwise the minimum is at mid or to its left, so set high = mid. The loop ends with low at the minimum, in O(log n).
This topic is named in a candidate’s interview report: System software engineer interview, on GeeksforGeeks.
-
How do you copy a linked list whose nodes have a next pointer and a random pointer, using O(1) extra space besides the copy?
- Insert each copy right after its original, set copy.random = original.random.next, then separate the two lists
- Store a map from each original node to its copy
- Copy the next pointers, then leave the random pointers pointing at the original list
- Sort the nodes by address first
Show the answer
A. Insert each copy right after its original, set copy.random = original.random.next, then separate the two lists
Interleaving puts each copy one step after its original, so the copy of any node X is X.next. That turns every random pointer into a one-step lookup with no hash map. A final pass restores the original list and links the copies.
This topic is named in a candidate’s interview report: System software engineer interview, on GeeksforGeeks.
C and C++ 4
-
In C, what does static do to a global variable declared at file scope?
- Makes it a constant
- Limits its visibility to that source file (internal linkage); it still lives for the whole program
- Moves it onto the stack
- Makes it visible to every file without extern
Show the answer
B. Limits its visibility to that source file (internal linkage); it still lives for the whole program
Every global already has static storage duration. Adding static changes only linkage, so another file cannot refer to it with extern. Inside a function, static instead keeps a local's value between calls.
This topic is named in a candidate’s interview report: System software engineer interview, on GeeksforGeeks.
-
How do C++ compilers usually make a virtual function call through a base-class pointer reach the right override?
- They inline every virtual call
- Each object of a class with virtual functions holds a pointer to its class's vtable, a table of function pointers read at run time
- They look the function up by name at run time
- They generate a template for every derived class
Show the answer
B. Each object of a class with virtual functions holds a pointer to its class's vtable, a table of function pointers read at run time
A call such as p->area() loads the vtable pointer from the object, then the slot for area, then calls it. That indirection is why virtual calls are slightly slower and usually cannot be inlined.
This topic is named in a candidate’s interview report: On-campus interview, Pune, 2017, on GeeksforGeeks.
-
How does a static library differ from a dynamic (shared) library?
- A static library is copied into the executable at link time; a shared library is loaded at run time and one copy can serve many programs
- A static library can only be used by one program at a time while it runs
- A shared library is copied into the executable at compile time
- There is no difference once the program is built
Show the answer
A. A static library is copied into the executable at link time; a shared library is loaded at run time and one copy can serve many programs
Static linking (.a, .lib) makes a larger self-contained binary that must be rebuilt to pick up a fix. Shared libraries (.so, .dll) save memory and disk and can be updated separately, but must be present when the program runs.
This topic is named in a candidate’s interview report: System software engineer interview, on GeeksforGeeks.
-
What does this print?
#include <stdio.h> int main(void) { int n = 10; /* 1010 */ n |= (1 << 0); /* set bit 0 */ n ^= (1 << 3); /* toggle bit 3 */ printf("%d", n); return 0; }- 11
- 3
- 2
- 15
Show the answer
B. 3
Setting bit 0 turns 1010 into 1011 (11). Toggling bit 3 flips its 1 to 0, giving 0011, which is 3. OR sets a bit, AND with the complement clears it, and XOR toggles it.
This topic is named in a candidate’s interview report: System software engineer interview, on GeeksforGeeks.
Operating systems 1
-
On Linux, what happens to a running child process when its parent process is killed?
- The child is killed too, always
- The child becomes a zombie at once
- The child keeps running as an orphan and is adopted by init (PID 1) or a subreaper, which collects its exit status
- The child is paused until the parent restarts
Show the answer
C. The child keeps running as an orphan and is adopted by init (PID 1) or a subreaper, which collects its exit status
A child is not killed just because its parent dies, unless it set up something such as PR_SET_PDEATHSIG or belongs to the same session as a closing terminal. A zombie is the opposite case: a finished child whose parent has not yet collected its status.
This topic is named in a candidate’s interview report: On-campus interview, Pune, 2017, on GeeksforGeeks.