C Program to convert infix expression into postfix expression along with algorithm is given below. Conversion of Infix expression to postfix expression is a classical example of use of Data Structure Stack.
Depth First Search (DFS) algorithm is used to traverse a graph depthward motion. DFS Algorithm use data structure stack to remember to get the next vertex to start the search and we will requred an array to keep the track of vertex that it is visited or unvisited.
Breadth First Search (BFS) algorithm is used to traverse a graph in a breadth ward motion. BFS Algorithm use data structure queue to remember to get the next vertex to start the search and we will required an array to keep the track of vertex that it is visited or unvisited.
A binary tree will be balanced tree if its both left subtree and right subtree is balanced i.e The difference between the height of left subtree and right subtree should not be more than 1.
C++ Program to find the level of the target node in a binary tree is given below. Approach is simple we will do the Breadth First Search traversal of the binary tree by using and keep the track of the level.
C++ Program to detect a cycle in directed graph is given below. Approach is simple, we will do DFS traversal of graph from each vertex (which will be source) and look if there is any back edge to the source during traversal. If there is any back edge then it means there is cycle in the graph otherwise there is not any cycle.
C Program to traverse a matrix in spiral order is given below. The program is compiled and checked successfully output is also given below the program. This question has been asked in the interview of many tech giants like Oracle, Microsoft, DE Shaw etc..
Algorithm and the program for detecting any loop inside the singly Linked linked list is given below.
Implementation is simple we will use two pointer. We will increment one pointer by one the other one by two and then check if two pointers are equal or not.
Python program for insertion node at any position in singly linked list is given below. In this program the class LinkedList contains a method insert which will insert the new element at the desired position the program along with output is given.
Floyd Warshall algorithm is used to find the shortest distance between the every pair of vertices in a given weight directed graph which does not contain any cycles of negative length ( The total length of any cycle in the graph should not be negative).