close all;
clear all;
d=[1,0,1,1,0];
for i=1:length(d)
if d(i)==1
a(i)=-2;
b(i)=2;
else
a(i)=2;
b(i)=-2;
end
hold on;
for j=i:0.01:i+0.5
plot(j,a(i),'.-r');
end
for j=i+0.5:0.01:i+1
plot(j,b(i),'.-r');
end
grid on;
en...
Wednesday, September 12, 2012
[MATLAB] Differential Manchester technique using simulink
close all;
clear all;
d=[1,0,1,1,0];
for i=1:length(d)
if i>1
if d(i)==1
a(i)=b(i-1);
b(i)=a(i-1);
else
a(i)=a(i-1);
b(i)=b(i-1);
end
else
if d(i)==1
a(i)=2;
b(i)=-2;
else
...
[MATLAB]NRZ technique using simulink
close all;
clear all;
d=[1,0,1,1,0];
for i=1:length(d)
if d(i)==1
a(i)=2;
else
a(i)=0;
end
hold on;
for j=i:0.01:i+1
plot(j,a(i),'.-r');
end
grid on;
en...
Implementation of circular queue in C/C++
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<iostream.h>
struct node
{
int info;
struct node* link;
};
struct node *last=0;
void main()
{
struct node*first=0;
int n;
clrscr();
struct node* add_first(struct node*);
struct node* add_last(struct node*);
struct node* del_first(struct node*);
struct node* del_last(struct node*);
void traverse(struct node*);
cout<<" \n 1.add at first ";
cout<<" \n 2.add at last...
Implementation of DFS in C & C++
/*
DFS TRAVERSAL
ROLL NO:- 09BCE006
*/
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void create();
void dfs();
struct node
{
int data,status;
struct node *next;
struct link *adj;
}*start,*p,*q;
struct link
{
struct node *next;
struct link *adj;
}*l,*k;
void main()
{
clrscr();
create();
dfs();
}
void create()
{
int dat,flag=0;
start=NULL;
...
Implementation of binary search in C & C++
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<process.h>
int binary_search(int ,int ,int,int);
int a[100],loc;
void main()
{
clrscr();
int n,x,low,high;
cout<<"\nEnter number of element:";
cin>>n;
cout<<"Enter elements in ascending order:\n";
for(int i=0;i<n;i++)
{
cin>>a[i];
cout<<endl;
}
cout<<"Enter element which u want to found:\n";
cin>>x;
...
Implementation of Priority Queue in C & C++
/* ROLL NO:- 09BCE006
PRIORITY QUEUE
*/
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<stdlib.h>
void insert(void);
void del(void);
void disply(void);
struct node
{
int priority;
int value;
struct node *link;
}*first=NULL;
void main()
{
int n;
clrscr();
while(1)
{
cout<<"\n 1.insert \n 2.delete \n 3.display \n 4.Exit \n";
cin>>n;
switch(n)
{
case 1:insert();
break;
...
Implementation of binary search tree in C & C++
/* Binary Search Tree
Roll no:- 09BCE006
*/
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<process.h>
struct tree
{
int info;
struct tree *lptr,*rptr;
}*root,*head,*hroot;
void insert(struct tree*,int);
void del(struct tree*,int);
void inorder(struct tree*);
void preorder(struct tree*);
void postorder(struct tree*);
void main()
{
clrscr();
int ch,x;
char cho;
while(1)
{
cout<<"\n\n1.INSERTION\n2.INORDER...
Implementation of Quick sort in C & C++
#include<stdio.h>
#include<conio.h>
int a[10];
void q_s(int lb,int ub);
void main()
{
int ub,lb,i,j;
clrscr();
printf("enter elements:");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
q_s(0,9);
printf("elements in the sorted order are:");
for(i=0;i<10;i++)
{
printf("%d\n",a[i]);
}
getch();
}
void q_s(int lb,int ub)
{
int i,j,t;
int flag=1,key;
if(lb<ub)
{
i=lb;
j=ub+1;
key=a[lb];
while(flag)
{
...
Implementation of Heap sort in C & C++
/*
HEAP SORT
ROLL NO:- 09BCE006
*/
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<stdlib.h>
void create_heap(int n);
void heap_sort(int n);
int k[100];
void main()
{
int n;
clrscr();
cout<<"Enter the no of elements which you want to sort :: ";
cin>>n;
cout<<"Enter the elements "<<endl;
for(int i=1;i<=n;i++)
{
cin>>k[i];
}
heap_sort(n);
cout<<"The sorted list is as follows "<<endl;
for(int...
Implementation of Link list in C & C++
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<stdlib.h>
#include<process.h>
struct node
{
int dat;
struct node *p;
};
struct node *first;
void main()
{
int a;
clrscr();
struct node * insf(struct node *);
struct node * insend(struct node *);
struct node * del(struct node*);
struct node * reverse(struct node*);
void trv(struct node *);
again:
cout<<" \n 1. insert a node at first ";
cout<<" \n 2. insert a node at end ";
cout<<" \n 3. traverse ";
cout<<" \n 4. deletion ";
cout<<"...
Implementation of stack in C
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
int top=-1;
int *stk;
void PUSH(int n)
{ if(top>n)
cout<<"\nSTACK OVERFLOW";
else
{ top++;
cout<<"\nEnter the element to be inserted:";
cin>>stk[top];
}
}
void POP()
{ if(top<0)
cout<<"\nSTACK UNDERFLOW";
else
{ int item=stk[top];
top--;
cout<<"\nThe deleted element is:"<<item;
...
Program of JAVA RMI
//----------------------------RmiServer.java--------------------------------//
import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;
import java.net.*;
public class RmiServer extends java.rmi.server.UnicastRemoteObject
implements ReceiveMessageInterface
{
int thisPort;
String thisAddress;
Registry registry; // rmi registry for lookup the remote objects.
// This method is called from the remote client by the RMI.
// This is the implementation of the...
C Program of iget & iput algorithm
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<dos.h>
#include<sys/stat.h>
#include<alloc.h>
#include<stdlib.h>
typedef struct used
{
int inode;
struct stat temp;
struct used *next;
struct time create;
struct time modi;
int lock;
int ref;
};
used *getnode()
{ used *t=(used *)malloc(sizeof(used));
t->next=NULL;
t->ref=1;
struct time temptime;
gettime(&temptime);
t->create=temptime;
return t;
}
used...
C Program of bmap algorithm
#include<protos.h>
void main()
{
long int offset;
clrscr();
printf("Enter byteoffset : ";
cin>>offset;
int b_offset;
int single=-1,doubles=-1,triples=-1;
long int block=offset/1024;
if(block < 266)
{ single=block;
b_offset=offset%1024;
goto SKP;
}
else if(block > 266 && block < 65802)
{ single=block/256;
doubles=block%256-10;
b_offset=offset%1024;
...
How to chat using named pipe in UNIX?
#include<unistd.h>
#include<stdio.h>
#include<fcntl.h>
char string[]="patel";
int main(char argv[10][100],int argc)
{
int fd;
char buf[200];
mknod("fifo",010777,0);
if(argc == 2)
fd=open("fifo",O_WRONLY);
else
fd=open("fifo",O_RDONLY);
while(1)
{
if(argc==2)
{ printf("writing");
write(fd,string,6);
}
else
{
...
Tower of Hanoi problem using PROLOG
%program of tower of hanoi predicates hanoi(integer). hanoi1(integer,symbol,symbol,symbol). clauses hanoi(P):- hanoi1(P,"A","B","C"). hanoi1(0,R,S,T). hanoi1(P,R,S,T):- U=P-1, hanoi1(U,R,T,S), write("move disk no ",P," from ",R," to ",T),nl, readchar(A), hanoi1(U,S,R,T). %output %move disk no 1 from A to C %move disk no 2 from A to B %move disk no 1 from C to B %move disk no 3 from A to C %move disk no 1 from B to A %move disk no 2...
Subscribe to:
Posts (Atom)