0% found this document useful (0 votes)
7 views5 pages

Daa Program

The document contains two programs: one for solving the job sequencing with deadlines problem, and another for the all pairs shortest path problem. The job sequencing program sorts jobs based on profit and schedules them according to their deadlines, while the shortest path program implements the Floyd-Warshall algorithm to find the shortest paths between all pairs of vertices. Both programs utilize standard input/output functions and basic control structures in C programming.

Uploaded by

s9008905
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

Daa Program

The document contains two programs: one for solving the job sequencing with deadlines problem, and another for the all pairs shortest path problem. The job sequencing program sorts jobs based on profit and schedules them according to their deadlines, while the shortest path program implements the Floyd-Warshall algorithm to find the shortest paths between all pairs of vertices. Both programs utilize standard input/output functions and basic control structures in C programming.

Uploaded by

s9008905
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Aim: Write a program to find solution for job sequencing with deadlines problem.

Program:

#include<stdio.h>

#include<conio.h>

int jobseq();

void psort();

int tp,j[10],d[10],p[10],n;

void main()

int i,k;

clrscr();

printf("\n Enter the n'o of jobs:");

scanf("%d",&n);

printf("\n Enter the %d Deadlines for the jobs:",n);

for(i=1;i<=n;i++)

scanf("%d",&d[i]);

printf("\n Enter the Profits required for jobs:");

for(i=1;i<=n;i++)

scanf("%d",&p[i]);

psort();

for(i=1;i<n;i++)

printf("%d",p[i]);

k=jobseq();

printf("\n The Required Solution is:");

for(i=1;i<=k;i++)

tp=tp+p[j[i]];

printf("%d-->",j[i]);

printf("\n Profits:%d",tp);

getch();
}

int jobseq()

int i,k,q;

d[0]=0;

j[0]=0;

j[1]=1;

k=1;

for(i=2;i<=n;i++)

int r=k;

while((d[j[r]]>d[i]) && (d[j[r]]!=r))

r=r-1;

if((d[j[r]]<=d[i]) && (d[i]>r))

for(q=k;q>=r+1;q--)

j[q+1]=j[q];

j[r+1]=i;

k=k+1;

return k;

void psort()

int i,k,temp1;

for(i=1;i<=n;i++)

for(k=1;k<=n-i;k++)
{

if(p[k]<p[k+1])

temp1=p[k];

p[k]=p[k+1];

p[k+1]=temp1;

temp1=j[k];

j[k]=j[k+1];

j[k+1]=temp1;

temp1=d[k];

d[k]=d[k+1];

d[k+1]=temp1;

Experiment No:

Aim: Write a program for all pairs shortest path problem.

Program:

#include<stdio.h>

#include<conio.h>

void readf();

void amin();

int cost[20][20],a[20][20];

int i,j,k,n;

void readf()

printf("\n Enter the no of vertices:");

scanf("%d",&n);

printf("\n Enter the Cost of vertices:");

for(i=0;i<n;i++)
{

for(j=0;j<n;j++)

scanf("%d",&cost[i][j]);

if(cost[i][j]==0 && (i!=j))

cost[i][j]=999;

a[i][j]=cost[i][j];

void amin()

for(k=0;k<n;k++)

for(i=0;i<n;i++)

for(j=0;j<n;j++)

if(a[i][j]>a[i][k]+a[k][j])

a[i][j]=a[i][k]+a[k][j];

printf("\n The All pair shortest path is:");

for(i=0;i<n;i++)

printf("\n");

for(j=0;j<n;j++)

{
printf("%d\t",a[i][j]);

void main()

clrscr();

readf();

amin();

getch();

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy