Bounteous x Accolite
10+ Bharat Electronics Interview Questions and Answers
Q1. Ninja and the Maze Problem Statement
Ninja is stuck in a maze represented as a 2D grid. He can move in four directions (Up, Down, Left, Right) until he hits a wall ('1'). Once stopped, he can choose a new direc...read more
The problem involves determining if a ninja can reach the destination in a maze by moving in four directions until hitting a wall.
Create a function that takes in the maze, starting point, and destination coordinates as input.
Implement a recursive algorithm to explore all possible paths in the maze.
Check if the destination can be reached from the starting point by moving in four directions.
Return 'True' if a path exists, otherwise return 'False'.
Q2. Topological Sort Problem Statement
Given a Directed Acyclic Graph (DAG) consisting of V
vertices and E
edges, your task is to find any topological sorting of this DAG. You need to return an array of size V
repr...read more
Topological sort of a Directed Acyclic Graph (DAG) is found by ordering the vertices in such a way that for every directed edge u -> v, u comes before v in the ordering.
Use Depth First Search (DFS) to find the topological ordering of the vertices.
Start by visiting a vertex and recursively visit its neighbors before adding it to the result array.
Maintain a visited array to keep track of visited vertices and a stack to store the topological ordering.
Once all neighbors of a vert...read more
Q3. Kth Largest Element Problem
Given an array containing N
distinct positive integers and a number K
, determine the Kth largest element in the array.
Example:
Input:
N = 6, K = 3, array = [2, 1, 5, 6, 3, 8]
Output...read more
Find the Kth largest element in an array of distinct positive integers.
Sort the array in non-increasing order and return the Kth element.
Use a priority queue or quick select algorithm for efficient solution.
Ensure the array contains distinct positive integers for accurate result.
Q4. Left Rotations of an Array
Given an array of size N
and Q
queries, each query requires left rotating the original array by a specified number of elements. Return the modified array for each query.
Input:
The fi...read more
Rotate an array left by a specified number of elements for each query.
Iterate through each query and rotate the array left by the specified number of elements using array slicing.
Handle cases where the number of rotations exceeds the length of the array by taking the modulo of the rotations.
Return the modified array after each query.
Q5. Trapping Rain Water Problem Statement
You are given a long type array/list ARR
of size N
, representing an elevation map. The value ARR[i]
denotes the elevation of the ith
bar. Your task is to determine the tota...read more
Calculate the total amount of rainwater that can be trapped between given elevations in an array.
Iterate through the array and calculate the maximum height on the left and right of each bar.
Calculate the amount of water that can be trapped at each bar by taking the minimum of the maximum heights on the left and right.
Sum up the trapped water at each bar to get the total trapped water for the entire array.
Q6. Distinct Occurrences Problem Statement
You are given two strings 'A' and 'B' of lengths 'N' and 'M' respectively. Your task is to determine how many distinct ways string 'B' occurs as a subsequence in string 'A...read more
Count the number of distinct occurrences of one string as a subsequence in another string.
Iterate through string A and string B to find all occurrences of B as a subsequence in A.
Use dynamic programming to keep track of the number of distinct occurrences.
Handle edge cases such as empty strings or strings of different lengths.
Example: For strings A='aabbcc' and B='abc', there are 3 distinct occurrences of B in A.
Q7. Median of Two Sorted Arrays
Given two sorted arrays A
and B
of sizes N
and M
, find the median of the merged array formed by combining arrays A
and B
. If the total number of elements, N + M
, is even, the median ...read more
Find the median of two sorted arrays by merging them and calculating the median of the combined array.
Merge the two sorted arrays into one sorted array.
Calculate the median of the merged array based on the total number of elements.
If the total number of elements is even, take the mean of the two middle elements as the median.
Q8. Distance Between Two Nodes in a Binary Tree
Given a binary tree and the values of two distinct nodes, determine the distance between these two nodes in the tree. The distance is defined as the minimum number of...read more
Calculate the distance between two nodes in a binary tree.
Traverse the tree to find the paths from the root to each node
Find the lowest common ancestor of the two nodes
Calculate the distance by summing the distances from each node to the common ancestor
Q9. Sort 0 1 2 Problem Statement
Given an integer array arr
of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.
Input:
The first line contains an integer 'T' representing the number of...read more
Sort an array of 0s, 1s, and 2s in linear time complexity.
Use three pointers to keep track of 0s, 1s, and 2s while iterating through the array.
Swap elements based on the values encountered to sort the array in-place.
Time complexity should be O(N) and space complexity should be O(1).
Q10. Intersection of Linked List Problem
You are provided with two singly linked lists containing integers, where both lists converge at some node belonging to a third linked list.
Your task is to determine the data...read more
Find the node where two linked lists merge, return -1 if no merging occurs.
Traverse both lists to find their lengths and the difference in lengths
Move the pointer of the longer list ahead by the difference
Traverse both lists simultaneously until they meet at the merging point
There are 3 levels of normalization in database management systems.
First Normal Form (1NF) - Eliminate duplicate data and ensure data is stored in a tabular format.
Second Normal Form (2NF) - Meet 1NF requirements and ensure all non-key attributes are fully functional dependent on the primary key.
Third Normal Form (3NF) - Meet 2NF requirements and ensure that there are no transitive dependencies between non-key attributes.
The sub-parts or phases of the analysis part in compiler design include lexical analysis, syntax analysis, and semantic analysis.
Lexical analysis involves breaking the input into tokens such as keywords, identifiers, and operators.
Syntax analysis checks the structure of the tokens to ensure they conform to the grammar rules of the language.
Semantic analysis verifies the meaning of the program by checking for type compatibility and other semantic rules.
Examples include lexing ...read more
Segmentation in operating systems is a memory management technique where memory is divided into segments of variable sizes.
Segments are logical units of a program such as code, data, stack, etc.
Each segment has its own base address and length.
Segmentation allows for more efficient memory management and protection.
Examples include Intel x86 architecture with segment registers like CS, DS, SS, etc.
Interview Process at Bharat Electronics
Top Software Developer Intern Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month