Find Square Root (without using sqrt).
Explanation: The program uses the Newton-Raphson method, an iterative technique to estimate the square root of a number. Key Components Output:
Find Powerfully Connected Components using Kosaraju’s Algorithm
Overview of Kosaraju’s Algorithm Kosaraju’s algorithm is a two-pass method to find all strongly connected components in a directed graph. A strongly connected component is a maximal subgraph where every…
Check if Binary Tree is Balanced
Explanation of the Code: Output: For the given sample tree: The output would be: Explanation of Output:
Find Maximum of Two Numbers
Explanation return 0;: This indicates that the program has executed successfully and is returning an exit status of 0. #include <stdio.h>: This line includes the standard input-output library. It allows…
Check if Binary Tree is Symmetric
Explanation Output When the program runs with the example tree, the output will be: If you modify the tree structure in the main function (e.g., remove a node), it will…
Implementation of Breadth First Search (BFS)
What is Breadth First Search (BFS)? BFS is a traversal algorithm for graph or tree data structures. It explores nodes level by level, starting from a specified node (often called…
Implementation of Kruskal’s Algorithm
Understanding Kruskal’s Algorithm Kruskal’s algorithm is a greedy algorithm that finds the minimum spanning tree for a connected, weighted graph. The steps involved are: Explanation of Kruskal’s Code Sample Input…
Implementation of Prim’s Algorithm
Understanding Prim’s Algorithm Prim’s algorithm builds a minimum spanning tree (MST) for a connected, weighted graph. It does this by starting from an arbitrary vertex and progressively adding the smallest…
Converting Decimal to Hexadecimal.
Explanation: Input: The program asks the user to enter a decimal number .Conversion: It repeatedly divides the decimal number by 16, storing the remainders (which represent hexadecimal digits). If the…