Wednesday, June 26, 2013

Algorithm Design & Analysis Lab [CSE-302]

#include<stdio.h>
#include <stdlib.h>

int q[15]={0},prev[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},col[15]={0},s,j,count=0 ;
int front = 0,rear = 0,d[10]={0},black = 2,grey =1,white = 0,in[50][50];

void queue(int val)
{

q[front++] = val;


}
int deque()
{
if(front == rear)
return -1;
return q[rear++];
}
void bfs(int ver)
{
int i,u;
col [s] = grey;
//s is starting vertex
d[s] = 0;
queue(s);

while((u = deque()) != -1)
{
col[u]=grey;
for(i = u,j = 1;j <= ver;j++)
{
if(in[i][j] == 1){//checking if any adjacent of u has an edge with any overtex
if(col[j] == white)
{
col[j] = grey;
prev[j] = i;
d[j] = d[u] + 1;
queue(j);
}
}

}

        col[i] = black;
    }

}

int main()
{
int i,k,u,v;
int a,b,ver,ed;
FILE *fp;
fp = freopen("input.txt","rt",stdin);



printf("Enter ur vertex num :");
scanf("%d",&ver);
printf("%d\n",ver);

printf("Enter ur edge num :");
scanf("%d",&ed);
printf("%d\n",ed);

printf("Enter your starting point :");
scanf("%d",&s);
printf("%d\n",s);

printf("Enter edge list :\n");

for(i = 1;i <= ed;i++)
{
scanf("%d %d",&a,&b);
in[a][b] = 1;
in[b][a] = 1;
printf("in[%d][%d] = 1\n",a,b);


}


bfs(ver);
for(i = 1;i <= ver;i++){

printf("The distance from source %d to vertex %d is - %d and previous is %d\n",s,i,d[i],prev[i]);
}


return 0;
}

Post Comment

Numerical Analysis Lab [CSE-304]

Lab: 2 (Newton-Raphson Method)
<html>
<head>

This is Lab-2 on Numerical Analysis (CSE-304)</br>
Date: 21.06.2013</br>

</head>

<body>

<h1>Newton-Raphson Method:</h1>
<button id="button1" onclick="button1onclick()">Show Table</button>
<p id="table"></p>
<p>Root of the Equation: <span id="root"></span></p>

<script>

function f(x)
{
return x*x*x-x-1;
}
function fd(x)
{
return 3*x*x-1;
}

x=1;

tab="";

for(i=0; i<=10; i++)
{
x=x-f(x)/fd(x);
tab=tab+i+"&nbsp&nbsp&nbsp&nbsp"+x+"</br>";
}
document.getElementById("root").innerHTML=x;

a=1;
function button1onclick()
{
if(a==1)
  {
   document.getElementById("table").innerHTML=tab;
   document.getElementById("button1").innerHTML="Hide Table";
   a=0;
  }
else
  {
   document.getElementById("table").innerHTML="";
   document.getElementById("button1").innerHTML="Show Table";
   a=1;
  }
}
</script>
</br>
</br>
</br>
Coded by : </br>
M.Shawon</br>
Roll No: 09</br>
Batch: CSE E-27th</br>
</body>
</html>

Download .html format from Hacker Box 

Post Comment

Thursday, June 13, 2013

7th Semester Class Routine

Dhaka International University
Department of CSE (Evening)
7th Semester (Batch-E27th)

Day
6.00pm - 7.15pm
07.15pm - 08.30pm
08.30pm - 09.45pm
Monday
GED - 301
CSE - 303
xXx
Tuesday
EEE - 301
GED - 301
CSE - 301
Wednesday
EEE - 301
CSE - 301
xXx
Friday
08.25am - 09.40am
CSE - 303
09.40am - 11.20am
CSE - 302 (Lab)
11.20am - 01.00pm
CSE - 304 (Lab)









Created by Moni                                                                               For more updates: diucse27e.blogspot.com  

Post Comment