Sunday, June 24, 2012

44.UDP PROTOCOL IN JAVA


Server Program:

import java.io.*;
import java.net.*;
public class Server
{
public static void main(String str1[]) throws Exception
{
DatagramSocket ds;
byte[] buf=new byte[1024];
ds=new DatagramSocket(200);
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter the String”);
InetAddress ia=InetAddress.getLocalHost();
while(true)
{

43. PRIORITY QUEUE USING HEAP


//PRIORITY QUEUE USING HEAP
#include<iostream.h>
#include<process.h>
#include<math.h>
#include<iomanip.h>
#include<malloc.h>
struct Heap
{
int capacity;
int size;
int *element;
};

42. HASHING TECHNIQUE IN C++



//HASHING TECHNIQUE
#include<iostream.h>
#include<iomanip.h>
struct listnode;
typedef struct listnode *position;
typedef position list;
struct hashtbl;
typedef struct hashtbl *hashtable;
hashtable initialize(int tablesize);
void destroytable(hashtable h);
position find(int key, hashtable h);
void insert(int key,hashtable h);
int retrieve(position p);
int hash(int key, int tablesize);

41. PRODUCER CONSUMER PROBLEM USING SEMAPHORE


//PRODUCER CONSUMER PROBLEM
#include<stdio.h>
#include<sys/types.h>
#include<sys/sem.h>
#include<stdlib.h>
#include<sys/shm.h>
#include<errno.h>
#include<sys/ipc.h>
void sem_acq(int);
void sem_rel(int);
int main()
{          int mutex,empty,full,shmid, n;
pid_t ret;
int in=-1,out=-1;
char *buffer;
char c[2];

40. KNAPSACK PROBLEM USING BACKTRACKING APPROACH



//KNAPSACK PROBLEM USING BACKTRACKING APPROACH
#include <stdio.h>
#include <conio.h>
#define max 10
int w[max],i,j,p[max];
int n,m;
float unit[max];
int y[max],x[max],fp=-1,fw;
void get()
{
printf(“\n Enter total number of items: “);
scanf(“%d”,&n);

39. CONVERSION OF COLOR MODELS


//CONVERSION OF COLOR MODELS
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float r,g,b,y,i,c,m,h,s,v;
int ch;
clrscr();
do
{

38. 2D REFLECTION & SHEAR IN C


//2D REFLECTION & SHEAR
#include<stdio.h>
#include<process.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void disp(int n,float c[][3])
{
float maxx,maxy;
int i;
maxx=getmaxx();
maxy=getmaxy();
maxx=maxx/2;
maxy=maxy/2;
i=0;
while(i<n-1)
{

37. 2D TRANSFORMATIONS IN C


//2D TRANSFORMATIONS
#include<stdio.h>
#include<process.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void disp(int n,float c[][3])
{
float maxx,maxy;
int i;
maxx=getmaxx();
maxy=getmaxy();
maxx=maxx/2;
maxy=maxy/2;
i=0;

36. MIDPOINT ELLIPSE DRAWING ALGORITHM

//MIDPOINT ELLIPSE DRAWING ALGORITHM
#include<stdio.h>
#include<graphics.h>
#include<math.h>
main()
{
long d1,d2;
int i,gd,gm,x,y;
long rx, ry, rxsq,rysq,tworxsq,tworysq,dx,dy;
/* Read the radius x and y
---------------------------- */
printf("Enter the x radius of the ellipse :");
scanf("%ld",&rx);
printf("Enter the y radius of the ellipse :");
scanf("%ld",&ry);

35. OPTIMAL BINARY SEARCH TREE


//OPTIMAL BINARY SEARCH TREE
import java.io.*;
import java.util.*;
class Optimal
{
 public int p[];       
 public int q[];       
 public int a[];     
 public int w[][];
 public int c[][]; 
 public int r[][]; 
 public int n;             
 int front,rear,queue[];
 public Optimal(int SIZE)
 {
  p=new int[SIZE];
  q= new int[SIZE];
  a=new int[SIZE];
  w=new int[SIZE][SIZE];
  c=new int[SIZE][SIZE];
  r=new int[SIZE][SIZE];
  queue=new int[SIZE];
  front=rear=-1;
}