Ansys Software Private Limited
Tata Communications Interview Questions and Answers
Q1. 0/1 Knapsack Problem Statement
A thief is planning to rob a store and can carry a maximum weight of 'W' in his knapsack. The store contains 'N' items where the ith item has a weight of 'wi' and a value of 'vi'....read more
Yes, the 0/1 Knapsack problem can be solved using dynamic programming with a space complexity of not more than O(W).
Use a 1D array to store the maximum value that can be stolen for each weight from 0 to W.
Iterate through each item and update the array based on whether including the item would increase the total value.
The final value in the array at index W will be the maximum value that can be stolen.
Q2. Binary Tree Right View Problem Statement
Given a binary tree of integers, your task is to print the right view of it. The right view represents a set of nodes visible when the tree is viewed from the right side...read more
The task is to print the right view of a binary tree, representing nodes visible from the right side in top-to-bottom order.
Traverse the tree level by level and keep track of the rightmost node at each level
Print the rightmost node of each level to get the right view of the tree
Use a queue for level order traversal and a map to store the rightmost nodes
Maximum Path Sum Problem Statement
You are given an n-ary tree consisting of 'N' nodes. Your task is to determine the maximum sum of the path from the root to any leaf node.
Example:
Input:
For the given tree:
Find the maximum sum of the path from the root to any leaf node in an n-ary tree.
Traverse the tree from root to leaf nodes while keeping track of the sum of each path.
At each node, calculate the sum of the path from the root to that node and update the maximum sum found so far.
Consider using depth-first search (DFS) or breadth-first search (BFS) for tree traversal.
Handle cases where nodes have negative values or where the tree is unbalanced.
You can find the size of an array in C or C++ by dividing the total size of the array by the size of one element.
Calculate the total size of the array by multiplying the number of elements by the size of each element.
Divide the total size by the size of one element to get the size of the array.
For example, if you have an array of strings arr[] = {'hello', 'world', 'example'}, you can find the size by dividing the total size of the array by the size of one string.
B+ trees are used for indexing in databases to efficiently search and retrieve data.
B+ trees are balanced trees where each node can have multiple keys and child pointers.
Data is stored in leaf nodes, while non-leaf nodes are used for navigation.
B+ trees are commonly used in databases because of their ability to efficiently search and retrieve data.
Example: In a database table with an index on a specific column, B+ trees can be used to quickly locate the rows that match a cert...read more
Q6. Write down the recursion tree for this code:
Recursion tree for a given code
Identify the base case of the recursion
Draw a tree structure with each recursive call as a node
Label each node with the input parameters and return values
More about working at Ansys Software Private Limited
Interview Process at Tata Communications
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month