<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>algorithm | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/algorithm/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sat, 10 Dec 2022 04:29:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-dynamic-programming-algorithm-to-solve-the-optimal-binary-search-tree-problem/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-dynamic-programming-algorithm-to-solve-the-optimal-binary-search-tree-problem/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 11 Mar 2010 17:39:44 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[binary tree]]></category>
		<category><![CDATA[optimal binary search tree]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1042</guid>

					<description><![CDATA[<p>/* Write a C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem */ #include #include #include 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 >n; cout</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-dynamic-programming-algorithm-to-solve-the-optimal-binary-search-tree-problem/">C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>/* Write a C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem */</p>
<pre lang="cpp">
#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]);
	cout <<"enter success propability for identifiers";
	for(i=1;i<=n;i++)
		cin >>p[i];
	cout << "enter failure propability for identifiers";
	for(i=0;i<=n;i++)
		cin >> q[i];
	for(i=0;i<=n;i++)
	{
		w[i][i]=q[i];
		c[i][i]=r[i][i]=0;
		w[i][i+1]=q[i]+q[i+1]+p[i+1];
		r[i][i+1]=i+1;
		c[i][i+1]=q[i]+q[i+1]+p[i+1];
	}
	w[n][n]=q[n];
	r[n][n]=c[n][n]=0;
	for(m=2;m<=n;m++)
	{
		for(i=0;i<=n-m;i++)
		{
		     j=i+m;
		     w[i][j]=w[i][j-1]+p[j]+q[j];
		     k=find(i,j);
		     r[i][j]=k;
		     c[i][j]=w[i][j]+c[i][k-1]+c[k][j];
		}
	}
       cout <<"\n";
       print(0,n); }

int find(int i,int j)
{
int min=2000,m,l;
for(m=i+1;m<=j;m++)
if(c[i][m-1]+c[m][j]<min)
{
min=c[i][m-1]+c[m][j];
l=m;
}
return l;
}
void print(int i,int j)
{
if(i<j)
puts(idnt[r[i][j]]);
else
return;
print(i,r[i][j]-1);
print(r[i][j],j);
}
</pre>
<p><strong>OUTPUT</strong></p>
<p>enter the no, of identifiers4<br />
enter identifiers<br />
do<br />
if<br />
int<br />
while<br />
enter success propability for identifiers3 3 1 1<br />
enter failure propability for identifiers2 3 1 1 1</p>
<p>tree in preorder form<br />
if<br />
do<br />
int<br />
while</p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-dynamic-programming-algorithm-to-solve-the-optimal-binary-search-tree-problem/">C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-dynamic-programming-algorithm-to-solve-the-optimal-binary-search-tree-problem/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program to implement dynamic programming algorithm to solve the all pairs shortest path problem</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-dynamic-programming-algorithm-to-solve-the-all-pairs-shortest-path-problem/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-dynamic-programming-algorithm-to-solve-the-all-pairs-shortest-path-problem/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 11 Mar 2010 17:36:22 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[dynamic programming]]></category>
		<category><![CDATA[shortest path problem]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1040</guid>

					<description><![CDATA[<p>/* Write a C++ program to implement dynamic programming algorithm to solve the all pairs shortest path problem */ #include #include 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 n; cout m; cout>j>>c; a[i][j]=cost[i][j]=c; } for(i=1;i</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-dynamic-programming-algorithm-to-solve-the-all-pairs-shortest-path-problem/">C++ program to implement dynamic programming algorithm to solve the all pairs shortest path problem</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>/* Write a C++ program to implement dynamic programming algorithm to solve the all pairs shortest path problem */</p>
<pre lang="cpp">
#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++)
{
cin>>i>>j>>c;
a[i][j]=cost[i][j]=c;
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
if(a[i][j]== 0 &#038;&#038; i !=j)
a[i][j]=31999;
}
for(k=1;k<=n;k++)
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
cout <<"Resultant adj matrix\n";
for(i=1;i<=n;i++)
{
for( j=1;j<=n;j++)
  {
  if(a[i][j] !=31999)
  cout << a[i][j] <<" ";
  }
cout <<"\n";
}
getch();
}
int min(int a,int b)
{
if(a<b)
return a;
else
return b;
}
</pre>
<p><strong>OUTPUT</strong></p>
<p>enter no of vertices3<br />
enter no od edges5<br />
enter the<br />
EDGE Cost<br />
1 2 4<br />
2 1 6<br />
1 3 11<br />
3 1 3<br />
2 3 2<br />
Resultant adj matrix<br />
0 4 6<br />
5 0 2<br />
3 7 0</p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-dynamic-programming-algorithm-to-solve-the-all-pairs-shortest-path-problem/">C++ program to implement dynamic programming algorithm to solve the all pairs shortest path problem</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-dynamic-programming-algorithm-to-solve-the-all-pairs-shortest-path-problem/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>C Program to implement the midpoint circle drawing algorithm</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-midpoint-circle-drawing-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-midpoint-circle-drawing-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 10:09:47 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[midpoint circle]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[circle drawing]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=825</guid>

					<description><![CDATA[<p>C Program to implement the midpoint circle drawing algorithm to draw a circle. Modify the algorithm toimplement specified arc or sector.</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-midpoint-circle-drawing-algorithm/">C Program to implement the midpoint circle drawing algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program to implement the midpoint circle drawing algorithm to draw a circle. Modify the algorithm toimplement specified arc or sector.</p>
<pre lang="c" escaped="true" line="1">
#include <graphics.h>
#include <conio.h>
#include <math.h>
#include <stdio.h>

#define PI 3.14

float startangle,endangle;
int x,y;

int Can_draw( float theta )
{
	if( theta >= startangle && theta<= endangle )
		return 1;
	return 0;
}

void Circlepoints(int x,int y,int xc,int yc)
{
	float theta;
	theta = atan( (float)y/x );
	theta = theta * (180/M_PI);
	
if( Can_draw(theta))
		putpixel(xc+x,yc-y,WHITE);
	if( Can_draw(360-theta))
		putpixel(xc+x,yc+y,WHITE);
	
if( Can_draw(90-theta))
		putpixel(xc+y,yc-x,WHITE);
	if( Can_draw(270+theta))
		putpixel(xc+y,yc+x,WHITE);
	
if( Can_draw(180-theta))
		putpixel(xc-x,yc-y,WHITE);
	if( Can_draw(180+theta))
		putpixel(xc-x,yc+y,WHITE);
	
if( Can_draw(90+theta))
		putpixel(xc-y,yc-x,WHITE);
	if( Can_draw(270-theta))
		putpixel(xc-y,yc+x,WHITE);
}

void MidPointcircle(int xc,int yc,int rad)
{
	float d = (5/4.0) - rad;
	x=0,y=rad;

	while(y>x)
	{
		if(d<0) 
 			d += 2*x+3;
		else 	
			d+=(2*x)-(2*y)+5,y--;
		x++;
		Circlepoints(x,y,xc,yc);
		delay(90);
	}
}
void main()
{
	int gd=DETECT,gm;
	int radius,xc,yc,choice,temp;
	float xstart,ystart,xend,yend;
	initgraph(&#038;gd,&#038;gm,"..\\bgi");
	do
	{
		clrscr();
		cleardevice();
		printf("\n Enter your choice\n");
		printf("\n 1.Draw a Circle\n 2.Draw a Sector\n 3.Draw an Arc\n 4.Exit\n");
		scanf("%d",&#038;choice);
		switch(choice)
		{
			case 1: printf("\n Enter the center:");
				scanf("%d %d",&#038;xc,&#038;yc);
				printf("\n Enter the radius:");
				scanf("%d",&#038;radius);
				cleardevice();
				startangle=0,endangle=360;
				MidPointcircle(xc,yc,radius);
				getch();
				break;

			case 2: printf("\n Enter the center:");
				scanf("%d %d",&#038;xc,&#038;yc);
				printf("\n Enter the radius:");
				scanf("%d",&#038;radius);
				printf("\n Enter the startangle:");
				scanf("%f",&#038;startangle);
				printf("\n Enter the endangle:");
				scanf("%f",&#038;endangle);
				cleardevice();
				if(startangle>endangle)
				{
					temp=startangle;
					startangle=endangle;
					endangle=temp;
				}
				MidPointcircle(xc,yc,radius);
				xstart=xc+radius*cos(PI/180*startangle);
				ystart=yc-radius*sin(PI/180*startangle);
				xend=xc+radius*cos(PI/180*endangle);
				yend=yc-radius*sin(PI/180*endangle);
				line(xc,yc,xstart,ystart);
				line(xc,yc,xend,yend);
				getch();
				break;

			case 3: printf("\n Enter the center:");
				scanf("%d %d",&xc,&yc);
				printf("\n Enter the radius:");
				scanf("%d",&radius);
				printf("\n Enter the startangle:");
				scanf("%f",&startangle);
				printf("\n Enter the endangle:");
				scanf("%f",&endangle);
				cleardevice();
				if(startangle>endangle)
				{
					temp=startangle;
					startangle=endangle;
					endangle=temp;
				}
				MidPointcircle(xc,yc,radius);
				getch();
				break;

		       case 4:  closegraph();
		}
	}while(choice!=4);
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-midpoint-circle-drawing-algorithm/">C Program to implement the midpoint circle drawing algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-midpoint-circle-drawing-algorithm/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
		<item>
		<title>C program for SJF CPU Scheduling Algorithm</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/c-program-for-sjf-cpu-scheduling-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/c-program-for-sjf-cpu-scheduling-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Sun, 20 Sep 2009 05:05:43 +0000</pubDate>
				<category><![CDATA[C Programs]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[CPU Scheduling]]></category>
		<category><![CDATA[CPU Sched]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=787</guid>

					<description><![CDATA[<p>OUTPUT:<br />
enter no of processes: 5</p>
<p>enter process1 name: aaa<br />
enter process time: 4<br />
enter process2 name: bbb<br />
enter process time: 3<br />
enter process3 name: ccc<br />
enter process time: 2<br />
enter process4 name: ddd<br />
enter process time: 5<br />
enter process5 name: eee<br />
enter process time: 1</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/c-program-for-sjf-cpu-scheduling-algorithm/">C program for SJF CPU Scheduling Algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>OUTPUT:<br />
enter no of processes: 5</p>
<p>enter process1 name: aaa<br />
enter process time: 4<br />
enter process2 name: bbb<br />
enter process time: 3<br />
enter process3 name: ccc<br />
enter process time: 2<br />
enter process4 name: ddd<br />
enter process time: 5<br />
enter process5 name: eee<br />
enter process time: 1</p>
<p>p_name  P_time  w_time</p>
<p> eee	1	0<br />
 ccc	2	1<br />
 bbb	3	3<br />
 aaa	4	6<br />
 ddd	5	10<br />
total waiting time=20<br />
avg waiting time=4.00</p>
<pre lang="c" escaped="true" line="1">
#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
char p[10][5],temp[5];
int tot=0,wt[10],pt[10],i,j,n,temp1;
float avg=0;
clrscr();
printf("enter no of processes:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter process%d name:\n",i+1);
scanf("%s",&#038;p[i]);
printf("enter process time");
scanf("%d",&#038;pt[i]);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(pt[i]>pt[j])
{
temp1=pt[i];
pt[i]=pt[j];
pt[j]=temp1;
strcpy(temp,p[i]);
strcpy(p[i],p[j]);
strcpy(p[j],temp);
}
}
}
wt[0]=0;
for(i=1;i<n;i++)
{
wt[i]=wt[i-1]+et[i-1];
tot=tot+wt[i];
}
avg=(float)tot/n;
printf("p_name\t P_time\t w_time\n");
for(i=0;i<n;i++)
printf("%s\t%d\t%d\n",p[i],et[i],wt[i]);
printf("total waiting time=%d\n avg waiting time=%f",tot,avg);
getch();
}

</pre>
<p>OUTPUT:<br />
enter no of processes: 5</p>
<p>enter process1 name: aaa<br />
enter process time: 4<br />
enter process2 name: bbb<br />
enter process time: 3<br />
enter process3 name: ccc<br />
enter process time: 2<br />
enter process4 name: ddd<br />
enter process time: 5<br />
enter process5 name: eee<br />
enter process time: 1</p>
<p>p_name  P_time  w_time</p>
<p> eee	1	0<br />
 ccc	2	1<br />
 bbb	3	3<br />
 aaa	4	6<br />
 ddd	5	10<br />
total waiting time=20<br />
avg waiting time=4.00</p><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/c-program-for-sjf-cpu-scheduling-algorithm/">C program for SJF CPU Scheduling Algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/c-program-for-sjf-cpu-scheduling-algorithm/feed/</wfw:commentRss>
			<slash:comments>48</slash:comments>
		
		
			</item>
		<item>
		<title>C program for LRU page replacement algorithm</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/c-program-for-lru-page-replacement-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/c-program-for-lru-page-replacement-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Sat, 19 Sep 2009 18:23:01 +0000</pubDate>
				<category><![CDATA[C Programs]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[LRU]]></category>
		<category><![CDATA[c program]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=775</guid>

					<description><![CDATA[<p>OUTPUT :<br />
2 -1 -1<br />
2  3 -1<br />
2  3 -1<br />
2  3  1<br />
2  5  1<br />
2  5  1<br />
2  5  4<br />
2  5  4<br />
3  5  4<br />
3  5  2<br />
3  5  2<br />
3  5  2<br />
no of page faults : 4</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/c-program-for-lru-page-replacement-algorithm/">C program for LRU page replacement algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>OUTPUT :<br />
2 -1 -1<br />
2  3 -1<br />
2  3 -1<br />
2  3  1<br />
2  5  1<br />
2  5  1<br />
2  5  4<br />
2  5  4<br />
3  5  4<br />
3  5  2<br />
3  5  2<br />
3  5  2<br />
no of page faults : 4</p>
<pre lang="c" escaped="true" line="1">
#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
int fr[3];
void main()
{
void display();
int p[12]={2,3,2,1,5,2,4,5,3,2,5,2},i,j,fs[3];
int index,k,l,flag1=0,flag2=0,pf=0,frsize=3;
clrscr();
for(i=0;i&lt;3;i++)
{
fr[i]=-1;
}
for(j=0;j&lt;12;j++)
{
flag1=0,flag2=0;
for(i=0;i&lt;3;i++)
{
if(fr[i]==p[j])
{
flag1=1;
flag2=1;
break;
}
}
if(flag1==0)
{
for(i=0;i&lt;3;i++)
{
if(fr[i]==-1)
{
fr[i]=p[j];
flag2=1;
break;
}
}
}
if(flag2==0)
{
for(i=0;i&lt;3;i++)
fs[i]=0;
for(k=j-1,l=1;l&lt;=frsize-1;l++,k--)
{
for(i=0;i&lt;3;i++)
{
if(fr[i]==p[k])
fs[i]=1;
}
}
for(i=0;i&lt;3;i++)
{
if(fs[i]==0)
index=i;
}
fr[index]=p[j];
pf++;
}
display();
}
printf("\n no of page faults :%d",pf);
getch();
}
void display()
{
int i;
printf("\n");
for(i=0;i&lt;3;i++)
printf("\t%d",fr[i]);
}
</pre>
<p>OUTPUT :<br />
2 -1 -1<br />
2  3 -1<br />
2  3 -1<br />
2  3  1<br />
2  5  1<br />
2  5  1<br />
2  5  4<br />
2  5  4<br />
3  5  4<br />
3  5  2<br />
3  5  2<br />
3  5  2<br />
no of page faults : 4</p><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/c-program-for-lru-page-replacement-algorithm/">C program for LRU page replacement algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/c-program-for-lru-page-replacement-algorithm/feed/</wfw:commentRss>
			<slash:comments>29</slash:comments>
		
		
			</item>
		<item>
		<title>Program for FIFO page replacement algorithm</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/program-for-fifo-page-replacement-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/program-for-fifo-page-replacement-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Sat, 19 Sep 2009 18:18:41 +0000</pubDate>
				<category><![CDATA[C Programs]]></category>
		<category><![CDATA[algor]]></category>
		<category><![CDATA[replacement]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[FIFO First in first out]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=773</guid>

					<description><![CDATA[<p>OUTPUT :<br />
2 -1 -1<br />
2  3 -1<br />
2  3 -1<br />
2  3  1<br />
5  3  1<br />
5  2  1<br />
5  2  4<br />
5  2  4<br />
3  2  4<br />
3  2  4<br />
3  5  4<br />
3  5  2</p>
<p>Number of page faults  : 6</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/program-for-fifo-page-replacement-algorithm/">Program for FIFO page replacement algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>OUTPUT :<br />
2 -1 -1<br />
2  3 -1<br />
2  3 -1<br />
2  3  1<br />
5  3  1<br />
5  2  1<br />
5  2  4<br />
5  2  4<br />
3  2  4<br />
3  2  4<br />
3  5  4<br />
3  5  2</p>
<p>Number of page faults  : 6</p>
<pre lang="c" escaped="true" line="1">
#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
int fr[3];
void main()
{
void display();
int i,j,page[12]={2,3,2,1,5,2,4,5,3,2,5,2};
int flag1=0,flag2=0,pf=0,frsize=3,top=0;
clrscr();
for(i=0;i&lt;3;i++)
{
fr[i]=-1;
}
for(j=0;j&lt;12;j++)
{
flag1=0;
flag2=0;
for(i=0;i&lt;12;i++)
{
if(fr[i]==page[j])
{
flag1=1;
flag2=1;
break;
}
}
if(flag1==0)
{
for(i=0;i&lt;frsize;i++)
{
if(fr[i]==-1)
{
fr[i]=page[j];
flag2=1;
break;
}
}
}
if(flag2==0)
{
fr[top]=page[j];
top++;
pf++;
if(top&gt;=frsize)
top=0;
}
display();
}
printf("Number of page faults  : %d ",pf);
getch();
}
void display()
{
int i;
printf("\n");
for(i=0;i&lt;3;i++)
printf("%d\t",fr[i]);
}
</pre>
<p>OUTPUT :<br />
2 -1 -1<br />
2  3 -1<br />
2  3 -1<br />
2  3  1<br />
5  3  1<br />
5  2  1<br />
5  2  4<br />
5  2  4<br />
3  2  4<br />
3  2  4<br />
3  5  4<br />
3  5  2</p>
<p>Number of page faults  : 6</p><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/program-for-fifo-page-replacement-algorithm/">Program for FIFO page replacement algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/program-for-fifo-page-replacement-algorithm/feed/</wfw:commentRss>
			<slash:comments>29</slash:comments>
		
		
			</item>
		<item>
		<title>Program for Deadlock detection algorithm</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/program-for-deadlock-detection-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/program-for-deadlock-detection-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Sat, 19 Sep 2009 18:07:02 +0000</pubDate>
				<category><![CDATA[C Programs]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[deadlock]]></category>
		<category><![CDATA[algorithm]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=767</guid>

					<description><![CDATA[<p>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</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/program-for-deadlock-detection-algorithm/">Program for Deadlock detection algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>INPUT:<br />
enter total no. of processes : 4<br />
enter claim matrix :<br />
0 1 0 0 1<br />
0 0 1 0 1<br />
0 0 0 0 1<br />
1 0 1 0 1<br />
enter allocation matrix :<br />
1 0 1 1 0<br />
1 1 0 0 0<br />
0 0 0 1 0<br />
0 0 0 0 0<br />
enter resource vector :<br />
2 1 1 2 1<br />
enter the availability vector :<br />
0 0 0 0 1</p>
<p>OUTPUT :<br />
deadlock causing processes are : 1 2</p>
<pre lang="c">#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
void main()
{
int found,flag,l,p[4][5],tp,c[4][5],i,j,k=1,m[5],r[5],a[5],temp[5],sum=0;
clrscr();
printf("enter total no of processes");
scanf("%d",&amp;tp);
printf("enter clain matrix");
for(i=1;i&lt;=4;i++)
for(j=1;j&lt;=5;j++)
{
scanf("%d",&amp;c[i][j]);
}
printf("enter allocation matrix");
for(i=1;i&lt;=4;i++)
for(j=1;j&lt;=5;j++)
{
scanf("%d",&amp;p[i][j]);
}
printf("enter resource vector:\n");
for(i=1;i&lt;=5;i++)
{
scanf("%d",&amp;r[i]);
}
printf("enter availability vector:\n");
for(i=1;i&lt;=5;i++)
{
scanf("%d",&amp;a[i]);
temp[i]=a[i];
}
for(i=1;i&lt;=4;i++)
{
sum=0;
for(j=1;j&lt;=5;j++)
{
sum+=p[i][j];
}
if(sum==0)
{
m[k]=i;
k++;
}
}
for(i=1;i&lt;=4;i++)
{
for(l=1;l&lt;k;l++)
if(i!=m[l])
{
flag=1;
for(j=1;j&lt;=5;j++)
if(c[i][j]&gt;temp[j])
{
flag=0;
break;
}
}
if(flag==1)
{
m[k]=i;
k++;
for(j=1;j&lt;=5;j++)
temp[j]+=p[i][j];
}
}
printf("deadlock causing processes are:");
for(j=1;j&lt;=tp;j++)
{
found=0;
for(i=1;i&lt;k;i++)
{
if(j==m[i])
found=1;
}
if(found==0)
printf("%d\t",j);
}
getch();
}</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/program-for-deadlock-detection-algorithm/">Program for Deadlock detection algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/program-for-deadlock-detection-algorithm/feed/</wfw:commentRss>
			<slash:comments>28</slash:comments>
		
		
			</item>
		<item>
		<title>Insertion sort in C program</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/sorting/program-to-sort-the-numbers-using-insertion-sort/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/sorting/program-to-sort-the-numbers-using-insertion-sort/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 04 Dec 2008 06:12:42 +0000</pubDate>
				<category><![CDATA[C Tutorials]]></category>
		<category><![CDATA[Sorting Programs]]></category>
		<category><![CDATA[Insertion sort]]></category>
		<category><![CDATA[logic]]></category>
		<category><![CDATA[Source Codes]]></category>
		<category><![CDATA[C/C++ Programms]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[sorting]]></category>
		<category><![CDATA[sorting demo]]></category>
		<category><![CDATA[sorting in c]]></category>
		<category><![CDATA[sorting numbers]]></category>
		<category><![CDATA[sort in c]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=351</guid>

					<description><![CDATA[<p>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&#8217;s why the name-  insertion sorting. In the First iteration, second element A[1] is compared</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/sorting/program-to-sort-the-numbers-using-insertion-sort/">Insertion sort in C program</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>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.</p>
<p><strong>Logic :</strong> Here, sorting takes place by inserting a particular element at the appropriate position, that&#8217;s why the name-  insertion sorting. In the First iteration, second element A[1] is compared with the first element A[0]. In the second iteration third element is compared with first and second element. In general, in every iteration an element is compared with all the elements before it. While comparing if it is found that the element can be inserted at a suitable position, then space is created for it by shifting the other elements one position up and inserts the desired element at the suitable position. This procedure is repeated for all the elements in the list.</p>
<p>If we complement the if condition in this program, it will give out the sorted array in descending order. Sorting can also be done in other methods, like selection sorting and bubble sorting, which follows in the next pages.</p>
<figure id="attachment_912" aria-describedby="caption-attachment-912" style="width: 580px" class="wp-caption aligncenter"><img decoding="async" class="size-full wp-image-912" title="Insertion Sort Demo" src="https://studentprojects.in/wp-content/uploads/2008/12/insertion_sort.jpg" alt="Insertion Sort Demo" width="580" height="1332" /><figcaption id="caption-attachment-912" class="wp-caption-text">Insertion Sort Demo</figcaption></figure>
<p><strong>C program for Insertion Sort:</strong></p>
<pre lang="c" line="1" escaped="true">#include
void main()
{
	int A[20], N, Temp, i, j;
	clrscr();
	printf("\n\n\t ENTER THE NUMBER OF TERMS...: ");
	scanf("%d", &amp;N);
	printf("\n\t ENTER THE ELEMENTS OF THE ARRAY...:");
	for(i=0; i&lt;N; i++)
	{
		scanf("\n\t\t%d", &amp;A[i]);
	}
	for(i=1; i&lt;N; i++)
	{
		Temp = A[i];
		j = i-1;
		while(Temp&lt;A[j] &amp;&amp; j&gt;=0)
		{
			A[j+1] = A[j];
			j = j-1;
		}
		A[j+1] = Temp;
	}
	printf("\n\tTHE ASCENDING ORDER LIST IS...:\n");
	for(i=0; i&lt;N; i++)
		printf("\n\t\t\t%d", A[i]);
	getch();
}
</pre>
<p><a href="https://studentprojects.in/wp-content/uploads/2008/12/ins_srt.zip">Download exe and source code here.</a></p><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/sorting/program-to-sort-the-numbers-using-insertion-sort/">Insertion sort in C program</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/sorting/program-to-sort-the-numbers-using-insertion-sort/feed/</wfw:commentRss>
			<slash:comments>194</slash:comments>
		
		
			</item>
	</channel>
</rss>
