Open In App

# Synopsys Interview Experience for R&D-2 Engineer | 4 Years Experienced

Screening Round with Hiring Manager(around 1hr):

2. Output based problem:

## C

 `int` `main(){`` ` `int` `i=5;`` ` `int` `j=6;`` ` `int` `k=(i+j)++;  ``//what will be value of i,j and k  ?`` ` `}`

3. How dynamic casting works?
4. Write truth table for AND and OR gate.  Using arithmetic operators(+,-,*,/), derive functionality of AND and OR gates

Sol: AND gate using multiplication, OR gate using +,*,-

5. Given a 4 digit number. Find next closer number to it using same digits.

I told approach of finding immediate next greater number.https://www.geeksforgeeks.org/find-next-greater-number-set-digits/

He asked to find next closer number either greater or smaller than original number. I told approach to find immediate greater and previous number and take number with minimum difference.

Then he asked me to do it in one traversal. I told to compare adj. digits from right and when digits mismatch, swap them, but it failed with following tc:  9891->9819,  But 9918 is more closer to 9891

I told to perform swapping on all adjacent pairs from right, sort remaining numbers in ascending and descending order and keep track of numbers closer to the original number.

I would appreciate readers for suggesting correct approach to this problem.

6. 10 coins are placed on table. 4 shows tail, 6 shows head.

Now flip 7 coins. After flipping, 9 coins state is known, 4 tails, 5 heads, find state of 10th coin.

I gave mathematical proof that last coin is tail.

Then he asked to do it without doing equation. And flip 7 coins means, 1 coin can also be flipped 7 times.

As flip is done an odd number of times and 4 tails, 5heads are present before and after flip, definitely, at least 1 coin has changed it’s state=> 1head has changed to 1 tail

Technical Round(1 hr 30 mins):

1. Asked about my current projects and some cross questions related to that

2. Asked why we need BST. Checked BST creation logic.

Write a function that will print a node in the BST if the difference between the sum of right node and sum of left node is equal to the parent_node.

Asked if this program can crash? Factors outside this can lead to crashes?

If this tree is very large or infinite recursion, will lead to stack overflow and will lead to a crash.

3. Asked if a task is assigned to me and that is not clear to me. What will I do to complete that task?
4. You’re are given n point on a plane, you have to connect all of them with minimum wire so that when current is applied on anyone node it reaches all the nodes. If a,b and b,c connected. we can assume that a,c are also connected.

Solved with minimum spanning tree approach.

5. Output based problem:

## C

 `Void f1 (``int` `x, ``int` `y ) {   x = y;   }`` ` `void` `f2 (``int`  `*x, ``int` `*y ) { *x = *y;  }`` ` `void` `f3 (``int`  `*x, ``int` `*y ) { x = y;  }`` ` `void` `f4 (``int`  `*x, ``int` `*y ) {  ``int` `z = 20; *x = &z ;   }`` ` `void` `main (``void` `)`` ` `{`` ` `Int a = 5 ;            Int b = 10 ;`` ` `f1(a,b);   ``//print a, b           `` ` `a= 5, b =10 ;        `` ` `f2(&a,&b);   ``//print a, b           `` ` `a= 5, b =10 ;`` ` `f3(&a,&b);    ``//print a, b           `` ` `a= 5, b =10 ;`` ` `f4(&a,&b);      ``//print a, b  `` ` `}`

6. Asked why I want to switch?
7. How many circles can be drawn with 2 points in plane? infinitely many and with 3 points? only one, but if points lie on same line, circle can’t be drawn.

Technical Round(1 hr):

1. Design API to Move Contents of buffer from one location to another location, lots of discussions to make program work in all the situations like on function arguments, use of unsigned int.
2. https://www.geeksforgeeks.org/print-all-combinations-of-balanced-parentheses/
3. https://www.geeksforgeeks.org/median-of-two-sorted-arrays-of-different-sizes/

Told O(n+m) approach

Technical Round(2 hrs):

2. Do you know big-endian and little-endian? Write prog to check endian of the machine.

https://www.geeksforgeeks.org/little-and-big-endian-mystery/

3. Print all prime numbers from start to 150. https://www.geeksforgeeks.org/sieve-of-eratosthenes/
4. Write singleton class. Can we inherit it? Write code for that.

We can make Singleton class constructor protected to make it accessible in Derived class

5. Output-based program

## C

 `Void function (``int``* a) {`` ` `If (a == NULL) {`` ` `  ``a = ``new` `int``(4);}`` ` `}`` ` `Int main() {`` ` `  ``Int *a = NULL;`` ` ` ``Function(a);`` ` `Printf(“%d”,*a);   -> what it will print?`` ` `}`

6. arr-> 1 4 5 7 8 10 15. Make it height-balanced tree.

We need to make middle element root for that.

7. Write a program to print -4 to -10 without using a semicolon
8. Program to stop elevator each 5th floor in a 42nd story tower. For ex: 5,10,,,,40,35,30, 5, 0, 5,
9. Find count of nodes that are a parent to a leaf node in a bst.  Also, find the count of all parent for a node
10. Write your own Iterator of a list class.
11. print left view of binary tree using recursion.
12. Template specialization. https://www.geeksforgeeks.org/template-specialization-c/
13. 81 coins, 1 is lighter/heavier,  find out odd one out using minimum weighing.
14. https://www.geeksforgeeks.org/given-an-array-a-and-a-number-x-check-for-pair-in-a-with-sum-as-x/

Name mangling concept

16. Design a library system (Without using database) (Will have Book name and Author Name)

a.Add entry of a book in system

b.Delete entry of book in system

c.Get list of books starting with “Abc”.  If System has books like “Abcd”, “Abc of C code”, “Let us C”, “ABC of c++” – It should display

1.“Abcd”
2.“Abc of C code”
3.“ABC of c++”

d.Get all the books of a particular author

17. Discussed trie and linked list approach