# Source Codes

## C++ program to solve the single source shortest path problem Using Dijkstra’s algorithm

/* Write a C++ program to solve the single source shortest path problem using Dijkstra’s algorithm */ #include<iostream> #include<conio.h> #include<stdio.h> using namespace std; int shortest(int ,int); int cost[10][10],dist[20],i,j,n,k,m,S[20],v,totcost,path[20],p; main() { int c; cout <<"enter no of vertices"; cin >> n; cout <<"enter no of edges"; cin >>m; cout <<"\nenter\nEDGE Cost\n"; for(k=1;k<=m;k++) { cin >> i […]

## C++ programs to implement the Prim’s algorithm to generate a minimum cost spanning tree

/* Write C++ programs to implement the Prim’s algorithm to generate a minimum cost spanning tree */ #include<iostream> #include<conio.h> #include<stdlib.h> using namespace std; int cost[10][10],i,j,k,n,stk[10],top,v,visit[10],visited[10],u;   main() { int m,c; cout <<"enterno of vertices"; cin >> n; cout <<"ente no of edges"; cin >> m; cout <<"\nEDGES Cost\n"; for(k=1;k<=m;k++) { cin >>i>>j>>c; cost[i][j]=c; } for(i=1;i<=n;i++) […]

## C++ programs to implement the Stack ADT using a singly linked list

while(temp->next != NULL)
temp=temp->next;
temp1=new node;
temp->next=temp1;
temp1->next=NULL;
temp1->data=x;

## C++ program to implement all the functions of a dictionary (ADT) using hashing

class Dictionary
{
public:
int index;

Dictionary();
void insert(int);
void search(int);
void delete_ele(int);
};

## C++ program to implement the double ended queue using a double linked list

class node
{
public:
int data;
class node *next;
class node *prev;
};

## C graphics program for analog clock

Time_Dig[0]=hour/10+48;
Time_Dig[1]=hour%10+48;
Time_Dig[2]=’:’;
Time_Dig[3]=min/10+48;
Time_Dig[4]=min%10+48;
Time_Dig[5]=’:’;
Time_Dig[6]=sec/10+48;

## C program to for Moving Car

line(80+i,300,90+i,270);
line(90+i,270,120+i,270);
line(120+i,270,160+i,240);
line(160+i,240,230+i,240);
line(230+i,240,275+i,270);

1 Comment

## C program to implement Spiral Model

setcolor(YELLOW);
printf(“ENTER THE NUMBER OF RINGS IN THE SPIRAL MODEL\n”);
scanf(“%d”,&n);
printf(“Enter the origin point of the spiral”);
scanf(“%d%d”,&x,&y);

1 Comment

## C program to implement Bar Graph

setcolor(CYAN);
printf(“ENTER THE NUMBER OF DATA ELEMENTS\n”);
scanf(“%d”,&n);

line(1,1,1,479);// Y axis
line(1,479,640,479);// X axis

## C Program for Optimal Page Replacement Algorithm

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

no of page faults : 3