C++ Program to Implement Floyd Warshall Algorithm

Floydâ€“Warshall algorithm is an algorithm for finding shortest paths in a weighted graph with positive or negative edge weights (but with no negative cycles). A single execution of the algorithm will find the lengths (summed weights) of the shortest paths between all pairs of vertices, though it does not return details of the paths themselves. Pseudo code: let dist be…

Shortest Path using Bellman Ford Algorithm

C++ Program to Use the Bellman Ford Algorithm to Find the Shortest Path Between Two Vertices. Assuming that Negative Size Edges Exist in the Graph Here is source code of the C++ Program to Use the Bellman Ford Algorithm to Find the Shortest Path Between Two Vertices Assuming that Negative Size Edges existing the Graph. #include <stdio.h> #include <stdlib.h> #include…

Program to find LCM and HCF of 3 numbers in C++

Write a Program to find LCM and HCFof 3 numbers in C++ #include<iostream> using namespace std; int lcm(int, int, int); int hcf(int, int, int); int main() { int a,b,c; int LCM, HCF; cout<<“Enter 1st number: “; cin>>a; cout<<“Enter 2nd number: “; cin>>b; cout<<“Enter 3rd number: “; cin>>c; LCM = lcm(a,b,c); HCF = hcf(a,b,c); cout<<“LCM of “<<a<<“,”<<b<<“,”<<c<<” is = “<<LCM<<endl; cout<<“HCF…

Default Arguments C++: Look at them Closely

We all know what are Default Arguments C++ are, but while playing with them, I found 2 interesting things, many of you might know this but this will be new for freshers and learners.   1-) Look at the following code closely: #include <iostream> // something looks missing void init(int =1, int =2, int =3); int main() { init(); return…

Union and Intersection of Arrays C++

Union and Intersection of Arrays Let us suppose we have two sorted Arrays int Arr1[]={1, 3, 4, 5, 7}; int Arr2[]={2, 3, 5, 6}; then UNION will be: {1, 2, 3, 4, 5, 6, 7} INTERSECTION : {3, 5} C++ Program for UNION of arrays: #include<iostream> #include<stdio.h> using namespace std; /* Function prints union of arr1[] and arr2[] m is…

Median of two sorted arrays Program C++

What is Median? In probability theory and statistics, a median is described as the number separating the higher half of a sample, a population, or a probability distribution, from the lower half. The median of a finite list of numbers can be found by arranging all the numbers from lowest value to highest value and picking the middle one. How…

Multiple Inheritance in c++ example

What is Multiple Inheritance? Multiple inheritance is a feature of some object-oriented computer programming languages in which an object or class can inheritÂ characteristics and features from more than one parent object or parent class. Deriving directly from more than one class is usually called multiple inheritance. Since it’s widely believed that this concept complicates the design and debuggers can have…