Cadence Design Systems
40+ M-Tek Engineers Interview Questions and Answers
Q1. Puzzle: Jumbled N pens and N caps, all caps separated from their pens, all pens have some thickness properties. How would you cap all the pens?
Match the thickness of each pen with its cap and cap them accordingly.
Sort the pens and caps by thickness.
Match the first pen with the first cap, second pen with the second cap and so on.
Cap the pens with their respective caps.
If there are any leftover caps or pens, they do not have a match.
Q2. Puzzle: 100 floor building and 2 eggs given, find the minimum/maximum number of trys required to find the floor where the egg will break. The answer I gave was 19. He asked me to normalize the solution; we then...
read moreFind the minimum/maximum number of tries required to find the floor where the egg will break in a 100 floor building with 2 eggs.
Use binary search approach to minimize the number of tries
Start with dropping the egg from the 14th floor, then 27th, 39th, and so on
If the first egg breaks, use the second egg to find the exact floor by checking each floor one by one
If the first egg doesn't break, move up to the next floor and repeat the process
The maximum number of tries is 14 if ...read more
Q3. Puzzle: 100 floor building and 2 eggs given, find the minimum/maximum number of trys required to find the floor where the egg will break. The answer I gave was 19. He asked me to normalize the solution; we then...
read moreFind minimum/maximum tries to find the floor where an egg will break in a 100 floor building with 2 eggs.
Use binary search approach to minimize number of tries
Start with dropping egg from 14th floor, then 27th, 39th, and so on
If first egg breaks, use second egg to check floors below the last successful drop
If first egg doesn't break, increase the drop interval and repeat
Minimum tries required is 14 and maximum is 20
Q4. Puzzle: Jumbled N pens and N caps, all caps separated from their pens, all pens have some thickness properties. How would you cap all the pens?
Match the thickness of each pen with its cap and cap them accordingly.
Sort the pens and caps by thickness.
Match the first pen with the first cap, second pen with the second cap and so on.
Cap the pens with their respective caps.
If there are any leftover caps or pens, they do not have a match.
Q5. What is a static function in a C++ class? Why is it used? How to call a static function of class from any part of the code
Static function in C++ class is used to access class-level data without creating an object.
Static functions can be called using the class name and scope resolution operator (::)
They cannot access non-static data members of the class
They can be used to implement utility functions that do not require access to object-specific data
Static functions are shared among all objects of the class
Q6. Concept of virtual function in C++. How is a vtable maintained? What are its enteries? Example code where virtual function is used
Virtual functions in C++ use vtables to enable dynamic binding. Example code included.
Virtual functions allow polymorphism in C++
Vtables are used to maintain a list of virtual functions
Each class with virtual functions has its own vtable
Vtable entries are function pointers to the virtual functions
Example code: class Shape { virtual void draw() = 0; };
Example code: class Circle : public Shape { void draw() override { ... } };
Q7. There is a stack where push and pop operation are happening. At any point of time user will query secondMin(). This API should return second minimum present in the stack
Implement an API to return the second minimum element in a stack.
Create a stack and a variable to store the second minimum element.
Whenever a new element is pushed, compare it with the current second minimum and update if necessary.
Whenever an element is popped, check if it is the current second minimum and update if necessary.
Return the second minimum element when the secondMin() API is called.
Q8. Given a dictionary, how can you represent it in memory? What will be the worst case complexity of a search done on the DS designed?
A dictionary can be represented in memory as an array of strings. Worst case complexity of search is O(n).
A dictionary can be represented as an array of strings where each string contains a key-value pair separated by a delimiter.
For example, ['apple: a fruit', 'banana: a fruit', 'carrot: a vegetable']
The worst case complexity of a search in this DS is O(n) as we may need to traverse the entire array to find the desired key-value pair.
Q9. Concept of virtual function in C++. How is a vtable maintained? What are its enteries? Example code where virtual function is used
Virtual functions in C++ are used for runtime polymorphism. Vtable is maintained to store function pointers.
Virtual functions are declared using the virtual keyword
Vtable is a table of function pointers maintained by the compiler
Each class with virtual functions has its own vtable
Vtable entries are function pointers to the virtual functions of the class
Example code: class Shape { virtual void draw() { ... } };
Example code: Shape* s = new Circle(); s->draw(); // calls Circle::...read more
Q10. There is a stack where push and pop operation are happening. At any point of time user will query secondMin(). This API should return second minimum present in the stack
Implement secondMin() API for a stack with push and pop operations.
Create a second stack to keep track of the minimum values.
Push the current minimum value to the second stack every time a new minimum is found.
Pop the top element from the second stack when the minimum value is removed from the main stack.
Return the second element from the top of the second stack as the second minimum value.
Q11. What is a static function in a C++ class? Why is it used? How to call a static function of class from any part of the code
Static function in C++ class and its usage
Static function belongs to the class rather than the instance of the class
It can be called without creating an object of the class
It is used to perform operations that do not depend on the state of the object
To call a static function, use the class name followed by the scope resolution operator and the function name
Q12. A point and a rectangle are present with the given coordinates. How will you determine whether the point is inside or outside the rectangle?
To determine if a point is inside or outside a rectangle, compare the point's coordinates with the rectangle's boundaries.
Compare the x-coordinate of the point with the x-coordinates of the left and right boundaries of the rectangle.
Compare the y-coordinate of the point with the y-coordinates of the top and bottom boundaries of the rectangle.
If the point's x-coordinate is between the left and right boundaries AND the point's y-coordinate is between the top and bottom boundari...read more
Q13. There is a point inside the rectangle. How will you determine the line that passes through the point and divides the rectangle into 2 equal halves?
To determine the line that passes through a point and divides a rectangle into 2 equal halves, find the midpoint of the rectangle and draw a line through the midpoint and the given point.
Find the midpoint of the rectangle by averaging the x and y coordinates of the opposite corners.
Draw a line through the midpoint and the given point using the point-slope formula.
Check that the line intersects the opposite sides of the rectangle at the same distance from the midpoint to ensur...read more
Q14. There is a scheme which contains 8-bit and 16-bit signed numbers. How many such combinations are possible?
There are 2^24 possible combinations of 8-bit and 16-bit signed numbers.
The scheme contains both 8-bit and 16-bit signed numbers.
The total number of possible combinations is 2^24.
This is because there are 2^8 possible combinations of 8-bit signed numbers and 2^16 possible combinations of 16-bit signed numbers.
Multiplying these two values gives us 2^24 total possible combinations.
Q15. Different segments of memory. Where all can a variable be allocated?
A variable can be allocated in different segments of memory.
Global memory segment
Stack memory segment
Heap memory segment
Code memory segment
Q16. Different segments of memory. Where all can a variable be allocated?
Variables can be allocated in different segments of memory.
Global variables are allocated in the data segment.
Local variables are allocated in the stack segment.
Dynamically allocated variables are allocated in the heap segment.
Static variables are allocated in the data segment.
Thread-local variables are allocated in the thread-local storage segment.
Q17. What does the term “object oriented programming mean?”
Object oriented programming is a programming paradigm that uses objects to represent and manipulate data.
OOP focuses on creating reusable code through the use of classes and objects
It emphasizes encapsulation, inheritance, and polymorphism
Examples of OOP languages include Java, C++, and Python
Q18. What is the difference between overloading and overriding?
Overloading is having multiple methods with the same name but different parameters. Overriding is having a method in a subclass with the same name and parameters as in the superclass.
Overloading is compile-time polymorphism while overriding is runtime polymorphism.
Overloading is used to provide different ways of calling the same method while overriding is used to provide a specific implementation of a method in a subclass.
Overloading is achieved within the same class while ov...read more
Q19. What is auto, volatile variables? Scopes of variables
Auto and volatile are storage classes in C language. Scopes of variables determine where they can be accessed.
Auto variables are declared within a block and have a local scope.
Volatile variables are used to indicate that the value of the variable may change at any time.
Global variables have a file scope and can be accessed from any function within the file.
Static variables have a local scope but retain their value between function calls.
Extern variables have a global scope an...read more
Q20. Given a number, tell number of bits set in the number in its binary representation. Ex. N = 5, Ans – 2 (101 has 2 1’s in it)
Count the number of set bits in a given number's binary representation.
Convert the number to binary representation
Iterate through each bit and count the number of set bits
Use bitwise AND operator to check if a bit is set or not
Keep incrementing the count for each set bit
Q21. What does the term “object oriented programming mean?”
Object-oriented programming is a programming paradigm that uses objects to represent and manipulate data.
It focuses on creating reusable code by organizing data and behavior into objects.
Objects have properties (attributes) and methods (functions) that can be accessed and modified.
Encapsulation, inheritance, and polymorphism are key concepts in object-oriented programming.
Examples of object-oriented programming languages include Java, Python, and C++.
Q22. What is the difference between overloading and overriding?
Overloading is having multiple methods with the same name but different parameters. Overriding is having a method in a subclass with the same name and parameters as in the superclass.
Overloading is compile-time polymorphism while overriding is runtime polymorphism.
Overloading is used to provide different ways of calling the same method while overriding is used to provide a specific implementation of a method in a subclass.
Overloading is done in the same class while overriding...read more
Q23. What is auto, volatile variables? Scopes of variables
Auto and volatile are storage classes in C programming language. Scopes of variables determine where they can be accessed.
Auto variables are created and destroyed automatically within a block of code.
Volatile variables are used to indicate that the value of the variable may change unexpectedly.
Scopes of variables determine where they can be accessed. Local variables have block scope, while global variables have file scope.
Static variables have function scope and retain their ...read more
Q24. Given a number, tell number of bits set in the number in its binary representation. Ex. N = 5, Ans – 2 (101 has 2 1’s in it)
Count the number of set bits in a given number's binary representation.
Convert the number to binary representation using bitwise operators.
Iterate over the binary representation and count the number of set bits.
Alternatively, use built-in functions like bin() and count() in Python.
The time complexity of the algorithm should be O(log n).
Q25. Why does a program crash? Valgrind issues etc
Programs can crash due to various reasons such as memory errors, bugs, hardware issues, etc.
Memory errors such as accessing uninitialized memory, buffer overflows, etc.
Bugs in the code such as infinite loops, null pointer dereferences, etc.
Hardware issues such as power failures, overheating, etc.
External factors such as network failures, input/output errors, etc.
Tools like Valgrind can help detect memory errors and other issues.
Q26. Pointers with increment/decreament, address of and value at operators (++,--,*,&)
Explanation of pointers with increment/decrement, address of and value at operators.
Pointers are variables that store memory addresses.
Increment/decrement operators change the address stored in a pointer.
Address of operator (&) returns the memory address of a variable.
Value at operator (*) returns the value stored at a memory address.
Pointers can be used to manipulate data directly in memory.
Q27. Why does a program crash? Valgrind issues etc
Programs can crash due to various reasons such as memory errors, bugs, hardware issues, etc.
Memory errors such as accessing uninitialized memory or freeing already freed memory
Bugs in the code such as infinite loops or null pointer dereferences
Hardware issues such as power failure or overheating
Valgrind issues such as memory leaks or invalid reads/writes
Operating system issues such as insufficient resources or conflicts with other programs
Q28. Is a C program faster than a C++ compiled program
It depends on the specific use case and implementation.
C and C++ have different strengths and weaknesses.
C is often used for low-level programming and system-level tasks.
C++ is often used for object-oriented programming and high-level tasks.
The performance difference between C and C++ can be negligible or significant depending on the implementation.
Optimizations and compiler settings can also affect performance.
Benchmarking and profiling can help determine which language is f...read more
Q29. Given an array of numbers (+ve and –ve), tell the subarray with the highest sum
Find subarray with highest sum in an array of numbers.
Use Kadane's algorithm to find maximum subarray sum
Initialize max_so_far and max_ending_here to 0
Iterate through the array and update max_ending_here and max_so_far
Return the subarray with highest sum
Example: [-2, 1, -3, 4, -1, 2, 1, -5, 4] => [4, -1, 2, 1]
Q30. What all type of sorting algorithms do you know?
I know various sorting algorithms including bubble sort, insertion sort, selection sort, merge sort, quick sort, heap sort.
Bubble sort - repeatedly swapping adjacent elements if they are in wrong order
Insertion sort - inserting each element in its proper place in a sorted subarray
Selection sort - selecting the smallest element and swapping it with the first element
Merge sort - dividing the array into two halves, sorting them and then merging them
Quick sort - selecting a pivot...read more
Q31. What all type of sorting algorithms do you know?
I know various sorting algorithms including bubble sort, insertion sort, selection sort, merge sort, quick sort, heap sort.
Bubble sort - repeatedly swapping adjacent elements if they are in wrong order
Insertion sort - iteratively inserting elements into a sorted sub-list
Selection sort - repeatedly selecting the smallest element and swapping it with the current element
Merge sort - recursively dividing the array into two halves, sorting them and merging them
Quick sort - recursi...read more
Q32. Is a C program faster than a C++ compiled program
It depends on the specific use case and implementation.
C and C++ have different performance characteristics.
C++ has additional features that may impact performance.
Optimizations can be applied to both languages.
Benchmarking is necessary to determine which is faster in a specific scenario.
Q33. Given an array of numbers (+ve and –ve), tell the subarray with the highest sum
Find subarray with highest sum in an array of numbers.
Use Kadane's algorithm to find maximum subarray sum
Initialize max_so_far and max_ending_here to 0
Iterate through the array and update max_ending_here and max_so_far
Return the subarray with highest sum
Example: [-2, 1, -3, 4, -1, 2, 1, -5, 4] => [4, -1, 2, 1]
Q34. Locate the sum of 2 numbers in a linear array (Unsorted and sorted) and their complexities
Locate sum of 2 numbers in a linear array (sorted/unsorted) and their complexities.
For unsorted array, use nested loops to compare each element with every other element until the sum is found. Complexity: O(n^2)
For sorted array, use two pointers approach starting from both ends of the array and move towards each other until the sum is found. Complexity: O(n)
Hash table can also be used for unsorted array to reduce complexity to O(n).
Binary search can also be used for sorted ar...read more
Q35. What is the difference between C and C++
C++ is an extension of C with object-oriented programming features.
C++ supports classes and objects while C does not.
C++ has better support for polymorphism and inheritance.
C++ has a larger standard library than C.
C++ allows function overloading while C does not.
C++ supports exception handling while C does not.
Q36. What is the difference between a latch and flip flop
Q37. What is the difference between C and C++
C++ is an extension of C with object-oriented programming features.
C++ supports classes and objects while C does not.
C++ has better support for function overloading and templates.
C++ has a standard library that includes many useful functions.
C++ allows for both procedural and object-oriented programming.
C++ is generally considered more complex than C.
Q38. Difference between static and dynamic bindings
Static binding is resolved at compile-time while dynamic binding is resolved at runtime.
Static binding is also known as early binding while dynamic binding is also known as late binding.
Static binding is faster than dynamic binding as it is resolved at compile-time.
Dynamic binding is more flexible than static binding as it allows for polymorphism.
An example of static binding is method overloading while an example of dynamic binding is method overriding.
Q39. Difference between static and dynamic bindings
Static binding is done at compile-time while dynamic binding is done at runtime.
Static binding is also known as early binding while dynamic binding is also known as late binding.
Static binding is faster than dynamic binding as it is done at compile-time.
Dynamic binding is more flexible than static binding as it allows for polymorphism.
An example of static binding is function overloading while an example of dynamic binding is virtual functions in C++.
Q40. Allocate a 2-D array using C/C++
Allocate a 2-D array using C/C++
Use the 'new' operator to allocate memory for the array
Specify the number of rows and columns in the array
Access elements using array indexing
Q41. Height of a tree, diameter of a tree
The height and diameter of a tree are important measurements for forestry and landscaping purposes.
Height can be measured using a clinometer or by using trigonometry and a measuring tape.
Diameter can be measured at breast height (4.5 feet above ground) using a diameter tape or by measuring circumference and dividing by pi.
These measurements are important for determining the health and growth of a tree, as well as for planning and managing forests and landscapes.
For example, a...read more
Q42. Height of a tree, diameter of a tree
The height and diameter of a tree are important measurements in forestry and arboriculture.
Height is typically measured from the base of the tree to the highest point of the crown.
Diameter is measured at breast height, which is 4.5 feet above the ground.
These measurements are used to determine the age, health, and value of a tree.
For example, a tall tree with a narrow diameter may indicate poor growth, while a shorter tree with a wide diameter may indicate healthy growth.
In f...read more
Q43. Allocate a 2-D array using C/C++
Allocate a 2-D array using C/C++
Use the 'new' keyword to allocate memory dynamically
Specify the number of rows and columns in the array
Access elements using array indexing
Q44. What is UNION in C?
UNION in C is a data type that allows storing different data types in the same memory location.
UNION is declared using the 'union' keyword.
It can be used to save memory by sharing the same memory location for different data types.
Accessing the members of a union can be done using the dot operator or the arrow operator.
Example: union myUnion { int i; float f; };
Example: myUnion.u.i = 10; myUnion.u.f = 3.14;
Q45. Cell padding concept in struct/class
Cell padding is the space between the content of a cell and its border in a table.
Cell padding can be set using CSS or HTML attributes.
It affects the appearance of the table and can improve readability.
Padding can be set for individual cells or for the entire table.
Example:
Example: td { padding: 10px; }
Q46. What is UNION in C?
UNION in C is a data type that allows storing different data types in the same memory location.
UNION is declared using the 'union' keyword.
It can be used to save memory by sharing the same memory location for different data types.
Accessing the value of a union member that was not recently assigned results in undefined behavior.
Example: union myUnion { int i; float f; };
Example: myUnion u; u.i = 10; printf("%d %f", u.i, u.f);
Q47. Cell padding concept in struct/class
Cell padding is the space between the content of a cell and its border in a table.
Cell padding can be set using CSS or HTML attributes.
It affects the appearance of the table and can improve readability.
Padding can be set individually for each cell or for the entire table.
Example:
Q48. References in C++
References in C++ allow a variable to refer to another variable's memory address.
References are declared using the '&' symbol.
They are often used as function parameters to avoid copying large objects.
References cannot be null and cannot be reassigned to refer to a different object.
They are commonly used in operator overloading to modify the original object.
Example: int x = 5; int& y = x; y++; // x is now 6.
Example: void swap(int& a, int& b) { int temp = a; a = b; b = temp; }
Q49. References in C++
References in C++ allow a variable to refer to another variable's memory address.
References are declared using the '&' symbol.
They are often used as function parameters to avoid copying large objects.
References cannot be null and cannot be reassigned to refer to a different object.
They are commonly used in operator overloading to modify the behavior of operators.
More about working at Cadence Design Systems
Top HR Questions asked in M-Tek Engineers
Interview Process at M-Tek Engineers
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month