Recently I had gone through four rounds of Synopsys Interviews for R&D Senior Engineer 1
Round 1:
Output-based questions:
-
C++ int j = 0; for(int i = n; i > 1; i = i/2) j++; int add(int &a, int &b) { int c = a + b; return c; } int main() { int int1, int2, sum; sum = add(int1, int2); }
-
C++ int a =10; int &r = a; int b = 25; r = b; r++; cout << r << endl << a << endl << b << endl; void printArray(int A[]) { // write code here } int main() { int Arr[5] = {2, 4, 6, 8, 10}; printArray(Arr); return 0; }
-
C++ void ChangeArray(int A[], int n) { for(int i = 0; i < n; i++) A[i]++; } int main() { int Arr[5] = {2, 4, 6, 8, 10}; ChangeArray(Arr, 5); for(int i = 0; i < 5; i++) cout << Arr[i] << " "; return 0; }
-
C++ void func(int n) { cout << n; func(n-1); } int main() { func(3); return 0; } int func(int n) { static int x = 0; if(n<=0) return 0; x++; return func(n-1) + x; } main() { func(5); }
-
C++ void foo(int n, int sum) { if(n==0) return; int k = n%10; int j = n/10; sum = sum + k; foo(j, sum); cout << k << ", "; } int main() { int a = 2048, sum = 0; foo(a, sum); cout << sum << endl; }
-
C++ int j = 0; for(int i = n; i > 1; i = i/2) j++; int i = n; 8 int j = 0; while(i > 1) { j++; i = i/2; }
-
C++ void printArray(int A[]) { // write code here int len = sizeof(A)/sizeof(A[0]); for(int i = 0; i < len; i++) { printf("%d ", A[i]); } } int main() { int Arr[5] = {2, 4, 6, 8, 10}; printArray(Arr); return 0; }
-
C++ int func(int n) { static int x = 0; if(n<=0) return 0; x++; return func(n-1) + x; } main() { func(5); }
-
C++ void foo(int n, int sum) { if(n==0) return; int k = n%10; int j = n/10; sum = sum + k; foo(j, sum); cout << k << ", "; } int main() { int a = 2048, sum = 0; foo(a, sum); cout << sum << endl; }
- Build Binary search tree using preorder and inorder traversal
- Virtual function questions in C++
Round 2:
- Design Queue using stacks
- Next Greater element and previous smaller element
- Declare 2d array in C++
- What each declaration means below
const char* p; // pointer itself is constant char * const p; // value is consstant const char * const p; // both are constants
- Design your own vector class and difference between vector and array.
Round 3:
- Second largest element in a BST.
- Cycle in a directed and undirected graph
- Basic C++ questions related to virtual functions and constructors.
Round 4:
- Find the next number in the series
3, 5, 8, 13, 22 3 * 2 = 6 - 1 5 5 * 2 = 10 - 2 8 8 * 2 = 16 - 3 13 13 * 2 = 26- 4 22 22 * 2 = 44- 5 39
- Convert string number to integer like atoi and ensure proper test cases are covered
- Why looking for a change and few other behavioral questions.