Infibeam
CODEC Networks Interview Questions and Answers
Q1. Program to find the lowest common ancestor of two nodes in binary search tree as well as binary tree. I was also asked to give the brute force approach for the same
Program to find lowest common ancestor of two nodes in binary search tree and binary tree with brute force approach.
For binary search tree, traverse from root to both nodes and store the path. Then compare paths to find LCA.
For binary tree, traverse from root to both nodes and store the path. Then compare paths to find LCA.
Brute force approach involves checking each node's descendants to see if they contain both nodes.
Time complexity for brute force approach is O(n^2) for wor...read more
Q2. Given an unsorted array of numbers, find two numbers which add up to the given sum in O(n)
Find two numbers in an unsorted array that add up to a given sum in O(n)
Use a hash table to store the difference between the sum and each element in the array
Iterate through the array and check if the current element is in the hash table
If it is, return the current element and the corresponding difference
If not, add the current element to the hash table
Q3. Program to print the elements of a matrix in spiral order recursively
Program to print matrix elements in spiral order recursively
Create a recursive function to print the elements in spiral order
Define the boundaries of the matrix and traverse the matrix in spiral order
Call the recursive function to print the elements in spiral order
Handle edge cases such as empty matrix or matrix with only one row/column
Q4. Program to print all ancestors of a node in a binary tree
Program to print all ancestors of a node in a binary tree
Create a recursive function to traverse the binary tree
Check if the current node is the target node
If yes, print all the nodes in the call stack
If not, recursively call the function for left and right subtrees
Q5. Program to implement Dijkstra’s algorithm
Dijkstra's algorithm finds shortest path between nodes in a graph
Create a graph with nodes and edges
Initialize distances from source node to all other nodes as infinity
Set distance from source node to itself as 0
Create a set of unvisited nodes
While unvisited set is not empty, select node with minimum distance
For each neighbor of selected node, calculate distance from source node
If calculated distance is less than current distance, update distance
Mark selected node as visited
R...read more
Q6. Program to implement FloydWarshall’s agorithm
Floyd-Warshall's algorithm is used to find the shortest path between all pairs of vertices in a weighted graph.
Create a 2D array to store the distances between all pairs of vertices.
Initialize the array with the weights of the edges in the graph.
Use nested loops to iterate over all pairs of vertices and update the distances if a shorter path is found through a third vertex.
The final array will contain the shortest distances between all pairs of vertices.
Q7. Program to swap two pointers
A program to swap two pointers.
Declare two pointers of the same data type
Assign the first pointer to a temporary variable
Assign the second pointer to the first pointer
Assign the temporary variable to the second pointer
Q8. Explain indexing in DBMS
Indexing is a technique used in DBMS to improve the performance of queries.
Indexing creates a separate data structure that allows faster retrieval of data.
It works by creating a pointer to the location of data in the table.
Indexes can be created on one or more columns of a table.
Types of indexing include B-tree, hash, and bitmap indexing.
Indexes can also be clustered or non-clustered.
Clustered indexes determine the physical order of data in a table.
Non-clustered indexes creat...read more
Q9. Explain B and B+ trees
B and B+ trees are data structures used for efficient searching and sorting of large datasets.
B trees are balanced trees used for disk-based storage systems.
B+ trees are similar to B trees but have all data stored in the leaf nodes for faster searching.
B trees have a variable number of keys per node, while B+ trees have a fixed number.
B trees have a higher fanout than B+ trees, making them more efficient for smaller datasets.
B+ trees are commonly used in databases and file sy...read more
Top Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month