MiQ Digital
10+ TCS Interview Questions and Answers
Q1. Right view of tree (recursive and using level order)
Printing the right view of a tree using recursion and level order traversal.
Recursively traverse the right subtree first and then the left subtree.
For level order traversal, use a queue to store nodes at each level.
Print the rightmost node at each level.
Example: For tree 1-2-3-4-5, the right view is 1-2-4-5.
Q2. Find the number of leaf nodes to a binary tree with 4 internal nodes?
A binary tree with 4 internal nodes has 5 leaf nodes.
A binary tree with n internal nodes has n+1 leaf nodes.
A leaf node is a node with no children.
Count the number of leaf nodes to find the answer.
Q3. Given the preorder traversal of the tree is DEBFGCA and the postorder traversal of the tree is ABDECFG. Find the inorder traversal?
Given preorder and postorder traversal, find inorder traversal of a binary tree.
The last element of postorder traversal is the root of the tree
Find the root in preorder traversal and divide the tree into left and right subtrees
Recursively find the inorder traversal of left and right subtrees
Combine the inorder traversal of left subtree, root, and inorder traversal of right subtree
Q4. The number of swapping operations required to sort the array [8,22,7,9,31,19,5,13] in bubblesort?
The number of swaps required to sort an array using bubblesort
Bubble sort compares adjacent elements and swaps them if they are in the wrong order
Count the number of swaps required to sort the given array
The given array requires 19 swaps to be sorted using bubblesort
Q5. SQL: 1. find the duplicates in a given dataset 2. order of execution 3. output of rank and dense rank 4. running total Tableau: 1. live vs extract 2. scatter plot and box plot 3. formula for IDR and outliers Gu...
read moreInterview questions for Analyst II position on SQL, Tableau, and Guesstimate
SQL: finding duplicates, order of execution, rank and dense rank, running total
Tableau: live vs extract, scatter plot and box plot, IDR and outliers formula
Guesstimate: estimating number of flights taking off from an airport in a day
Q6. EDA in python, how to find outliers?
Outliers can be found using statistical methods such as z-score, IQR, or using machine learning algorithms like isolation forest.
Calculate z-score for each data point and consider points with z-score greater than 3 or less than -3 as outliers.
Use interquartile range (IQR) to identify outliers. Points outside the range of Q1 - 1.5*IQR and Q3 + 1.5*IQR are considered outliers.
Isolation Forest is a machine learning algorithm that can be used to identify outliers in a dataset.
Vis...read more
Q7. What is naive in Naive Bayes?
Naive Bayes assumes independence between features, hence 'naive'.
Naive Bayes assumes all features are independent of each other, which is often not true in real-world data.
Despite its simplifying assumption, Naive Bayes is still widely used in text classification and spam filtering.
The 'naive' assumption allows for fast and efficient classification, especially with large datasets.
Q8. Guesstimate to evaluate my approach
To evaluate your approach, I would estimate the number of cars passing through a busy intersection in a day.
Identify the average number of cars passing through the intersection per minute
Calculate the total number of minutes in a day
Multiply the average cars per minute by total minutes in a day to get an estimate
Q9. Execution of SQL
Execution of SQL involves writing and running queries to retrieve, manipulate, and manage data in a database.
Write SQL queries to retrieve specific data from database tables
Use SQL functions and operators to manipulate data
Execute SQL statements to update or delete records in database
Manage database schema by creating, altering, or dropping tables
Optimize SQL queries for better performance
Q10. Recursive problem
Recursive problem involving finding the factorial of a number.
Implement a recursive function to calculate the factorial of a number.
Base case: if n is 0 or 1, return 1.
Recursive case: return n * factorial(n-1).
Q11. Parking lot design
Parking lot design involves layout, capacity, accessibility, and efficiency.
Consider the layout of the parking lot to maximize space and ease of navigation.
Include designated spots for different types of vehicles (e.g. compact, electric, handicap).
Implement efficient traffic flow patterns to reduce congestion and improve safety.
Incorporate technology such as sensors or apps for real-time parking availability updates.
Q12. Explain Gradient Decent Algo
Gradient Descent is an optimization algorithm used to minimize the error of a model by adjusting its parameters iteratively.
Gradient Descent is used in machine learning to find the optimal parameters for a model by minimizing a cost function.
It works by calculating the gradient of the cost function at a given point and moving in the opposite direction to reach the minimum.
There are different variations of Gradient Descent such as Batch Gradient Descent, Stochastic Gradient De...read more
Interview Process at TCS
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month