Join Regular Classroom : Visit ClassroomTech

TCS Ninja interview experience

TCS Ninja Interview Experience

Date of Interview: 17th May 2021

About Panelist :

3 panelists
1HR 1TR 1MR ( All re senior guys)

After checking the Resume, the Interviewers asked the Candidate the following questions…
They told Which topic would you like to take first,
He replied Data Structures.

cropped-logo_remastered_nb.png

Linear and non linear data structure.

In this linear structure, the elements are arranged sequentially or linearly and attached to one another. Arrays, linked list, stack, queue are the types of a linear data structure. The time complexity of linear data structure increases with the increase in the input size. Where as, in non-linear structure, the elements are arranged hierarchically or non-linear manner.
Trees and graphs are the types of  non-linear data structure. The time complexity of non-linear data structure often remains same with the increase in the input size.

What is a binary tree? Why is there a need to use a binary tree?

A binary tree is a tree-type non-linear data structure with a maximum of two children for each parent. To implement Hashing, routing data for network traffic, data compression, preparing binary heaps, and binary search trees we need to use a Binary Tree.

Why do we need a Binary Search Tree?

The two major factors that make binary search tree an optimum solution to any real-world problems are Speed and Accuracy.

Due to the fact that the binary search is in a branch-like format with parent-child relations, the algorithm knows in which location of the tree the elements need to be searched. This decreases the number of key-value comparisons the program has to make to locate the desired element.

Additionally, in case the element to be searched greater or less than the parent node, the node knows which tree side to search for. The reason is, the left sub-tree is always lesser than the parent node, and the right sub-tree has values always equal to or greater than the parent node.

BST is commonly utilized to implement complex searches, robust game logics, auto-complete activities, and graphics.

The algorithm efficiently supports operations like search, insert, and delete.

Explain all traversals

BFS stands for Breadth First Search. It is also known as level order traversal. The Queue data structure is used for the
Breadth First Search traversal. When we use the BFS algorithm for the traversal in a graph, we can consider any node as a root node. DFS stands for Depth First Search. In DFS traversal, the stack data structure is used, which works on the LIFO (Last In First Out) principle. In DFS, traversing can be started from any node, or we can say that any node can be considered as a root node until the root node is not mentioned in the problem.
In the case of BFS, the element which is deleted from the Queue, the adjacent nodes of the deleted node are added to the Queue. In contrast, in DFS, the element which is removed from the stack, then only one adjacent node of a deleted node is added in the stack.

You may check out

What are views and materialized view?

A view uses a query to pull data from the underlying tables. A materialized view is a table on disk that contains the result set of a query. Materialized views are primarily used to increase application performance when it isn’t feasible or desirable to use a standard view with indexes applied to it.

 

Can we do indexing on views?

You cannot create an index over a view, which is just a query. You can, instead, create an index over a materialized view. A materialized view is a table which is created by evaluating a view, so that you can create an index over it.

How would you tune a sql query?

Define business requirements first. .
SELECT fields instead of using SELECT * .
Avoid SELECT DISTINCT. …
Create joins with INNER JOIN (not WHERE) .
Use WHERE instead of HAVING to define filters.
Use wildcards at the end of a phrase only.

How to create a trigger ?

Trigger: A trigger is a stored procedure in database which automatically invokes whenever a special event in the
database occurs. For example, a trigger can be invoked
when a row is inserted into a specified table or when
certain table columns are being updated.
Syntax:
create trigger [trigger_name]
[before | after]
{insert | update | delete}
on [table_name]
[for each row]
[trigger_body

You may check out

You cannot create an index over a view, which is just a query. You can, instead, create an index over a materialized view. A materialized view is a table that is created by evaluating a view so that you can create an index over it.

Deep discussion on having group by and where clause

The GROUP BY statement groups rows that have the same values into summary rows, like “find the number of customers in each country”.
The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more columns.
The HAVING clause was added to SQL because the WHERE a keyword cannot be used with aggregate functions.

Recent Posts
Pages