Tip 1 : Be very clear with your project explanation.
Tip 2 : Also try to cover all the cs core subjects explanation clearly.
Tip 1 : Make it clean with appropriate knowledge.
Tip 2 : Provide true information and avoid telling lie in which You are not sure.
It was morning time and from 9:00 am . It happened via the google meet online process and it was very smooth onboarding . Interviewer was very friendly kind of nature .



For the given binary tree [1, 2, 3, -1, -1, 4, 5, -1, -1, -1, -1]
1
/ \
2 3
/ \
4 5
Output: 1 3 2 4 5
#include
#include
using namespace std;
// Binary Tree node
struct Node {
int data;
struct Node *left, *right;
};
// function to print the zigzag traversal
void zizagtraversal(struct Node* root)
{
// if null then return
if (!root)
return;
// declare two stacks
stack currentlevel;
stack nextlevel;
// push the root
currentlevel.push(root);
// check if stack is empty
bool lefttoright = true;
while (!currentlevel.empty()) {
// pop out of stack
struct Node* temp = currentlevel.top();
currentlevel.pop();
// if not null
if (temp) {
// print the data in it
cout << temp->data << " ";
// store data according to current
// order.
if (lefttoright) {
if (temp->left)
nextlevel.push(temp->left);
if (temp->right)
nextlevel.push(temp->right);
}
else {
if (temp->right)
nextlevel.push(temp->right);
if (temp->left)
nextlevel.push(temp->left);
}
}
if (currentlevel.empty()) {
lefttoright = !lefttoright;
swap(currentlevel, nextlevel);
}
}
}
// A utility function to create a new node
struct Node* newNode(int data)
{
struct Node* node = new struct Node;
node->data = data;
node->left = node->right = NULL;
return (node);
}
// driver program to test the above function
int main()
{
// create tree
struct Node* root = newNode(1);
root->left = newNode(2);
root->right = newNode(3);
root->left->left = newNode(7);
root->left->right = newNode(6);
root->right->left = newNode(5);
root->right->right = newNode(4);
cout << "ZigZag Order traversal of binary tree is \n";
zizagtraversal(root);
return 0;
}
It was again the morning session and the interviewer was very supportive in nature and gave me the hint too to think the approach and finally i came up the solution which he was expecting.



V is the number of vertices present in graph G and vertices are numbered from 0 to V-1.
E is the number of edges present in graph G.
The Graph may not be connected i.e there may exist multiple components in a graph.
#include
using namespace std;
// Graph class represents a directed graph
// using adjacency list representation
class Graph {
public:
map visited;
map > adj;
// function to add an edge to graph
void addEdge(int v, int w);
// DFS traversal of the vertices
// reachable from v
void DFS(int v);
};
void Graph::addEdge(int v, int w)
{
adj[v].push_back(w); // Add w to v’s list.
}
void Graph::DFS(int v)
{
// Mark the current node as visited and
// print it
visited[v] = true;
cout << v << " ";
// Recur for all the vertices adjacent
// to this vertex
list::iterator i;
for (i = adj[v].begin(); i != adj[v].end(); ++i)
if (!visited[*i])
DFS(*i);
}
// Driver's code
int main()
{
// Create a graph given in the above diagram
Graph g;
g.addEdge(0, 1);
g.addEdge(0, 2);
g.addEdge(1, 2);
g.addEdge(2, 0);
g.addEdge(2, 3);
g.addEdge(3, 3);
cout << "Following is Depth First Traversal"
" (starting from vertex 2) \n";
// Function call
g.DFS(2);
return 0;
}
It was really very cool, and felt very comformtable with the interviewer .
What is thread in OS?
Tip 1:Keep your answers with real life example.
Tip 2:Keep the answers very clear and crisp if you know.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?