# algorithm

## C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem

/* Write a C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem */ #include<iostream> #include<conio.h> #include<stdio.h> using namespace std; #define MAX 10 int find(int i,int j); void print(int,int); int p[MAX],q[MAX],w[10][10],c[10][10],r[10][10],i,j,k,n,m; char idnt[7][10];   main() { cout << "enter the no, of identifiers"; cin >>n; cout <<"enter identifiers"; for(i=1;i<=n;i++) gets(idnt[i]); […]

## C++ program to implement dynamic programming algorithm to solve the all pairs shortest path problem

/* Write a C++ program to implement dynamic programming algorithm to solve the all pairs shortest path problem */ #include<iostream> #include<conio.h> using namespace std; int min(int a,int b); int cost[10][10],a[10][10],i,j,k,c;   main() { int n,m; cout <<"enter no of vertices"; cin >> n; cout <<"enter no od edges"; cin >> m; cout<<"enter the\nEDGE Cost\n"; for(k=1;k<=m;k++) […]

## C Program to implement the midpoint circle drawing algorithm

C Program to implement the midpoint circle drawing algorithm to draw a circle. Modify the algorithm toimplement specified arc or sector.

## C program for SJF CPU Scheduling Algorithm

OUTPUT:
enter no of processes: 5

enter process1 name: aaa
enter process time: 4
enter process2 name: bbb
enter process time: 3
enter process3 name: ccc
enter process time: 2
enter process4 name: ddd
enter process time: 5
enter process5 name: eee
enter process time: 1

## C program for LRU page replacement algorithm

OUTPUT :
2 -1 -1
2 3 -1
2 3 -1
2 3 1
2 5 1
2 5 1
2 5 4
2 5 4
3 5 4
3 5 2
3 5 2
3 5 2
no of page faults : 4

## Program for FIFO page replacement algorithm

OUTPUT :
2 -1 -1
2 3 -1
2 3 -1
2 3 1
5 3 1
5 2 1
5 2 4
5 2 4
3 2 4
3 2 4
3 5 4
3 5 2

Number of page faults : 6

## Program for Deadlock detection algorithm

INPUT: enter total no. of processes : 4 enter claim matrix : 0 1 0 0 1 0 0 1 0 1 0 0 0 0 1 1 0 1 0 1 enter allocation matrix : 1 0 1 1 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 […]

## Insertion sort in C program

Here is the program to sort the given integer in ascending order using insertion sort method. Please find the pictorial tutor of the insertion sorting. Logic : Here, sorting takes place by inserting a particular element at the appropriate position, that’s why the name-  insertion sorting. In the First iteration, second element A[1] is compared […]