Synopsys
Continental Interview Questions and Answers
Q1. Algorithm to find GCD
Algorithm to find GCD
Use Euclid's algorithm to find GCD
Divide the larger number by the smaller number
If remainder is 0, smaller number is GCD
If remainder is not 0, repeat with smaller number and remainder
Q2. find leaves in a binary tree, left to right.
Traverse the binary tree using a queue to find leaves from left to right.
Start by adding the root node to a queue
While the queue is not empty, dequeue a node and check if it is a leaf node (both children are null)
If it is a leaf node, add its value to the result array
If it is not a leaf node, enqueue its children in left to right order
Q3. Matrix traversal algorithm
Matrix traversal algorithm is used to visit each element of a matrix in a specific order.
Matrix traversal can be done using nested loops.
There are different traversal orders like row-wise, column-wise, spiral, diagonal, etc.
Traversal can be optimized using techniques like caching and parallel processing.
Q4. Fundamentals of data structure
Data structure is a way of organizing and storing data in a computer so that it can be accessed and used efficiently.
Data structures are used to manage large amounts of data efficiently.
Common data structures include arrays, linked lists, stacks, queues, trees, and graphs.
Choosing the right data structure for a particular problem can greatly improve the efficiency of an algorithm.
Understanding data structures is essential for designing and implementing efficient algorithms.
Q5. Code of in-order traversal
In-order traversal is a way of visiting all nodes of a binary tree in a specific order.
Start at the root node
Traverse the left subtree recursively
Visit the root node
Traverse the right subtree recursively
Q6. Reverse the linklist.
To reverse a linked list, iterate through the list and change the direction of pointers.
Iterate through the linked list and keep track of the previous, current, and next nodes.
Update the pointers of each node to reverse the direction.
Set the head of the linked list to the last node encountered during iteration.
Q7. Find cycle in linked list
Detecting cycles in a linked list using Floyd's Tortoise and Hare algorithm
Use two pointers - slow and fast
If there is a cycle, the two pointers will eventually meet
Time complexity is O(n) and space complexity is O(1)
Q8. bfs in binary tree
Breadth-first search (BFS) is a traversal algorithm used to visit all nodes of a binary tree level by level.
Start at the root node and visit all nodes at the current level before moving to the next level.
Use a queue data structure to keep track of nodes to visit next.
Example: BFS traversal of a binary tree - 1 -> 2 -> 3 -> 4 -> 5
More about working at Synopsys
Interview Process at Continental
Reviews
Interviews
Salaries
Users/Month