Friday, April 27, 2012

21. BREADTH FIRST SEARCH IN JAVA



import java.io.*;
import java.util.Scanner;
class Queue
{
    int items[]=new int[10];
    int front,rear;
    Queue()
    {
        front=0;
        rear=-1;
    }

    void Insert(int e)
    {
        if(rear==9)
            System.out.println("Queue overflow");
        else
            items[++rear]=e;
    }

20. DEPTH FIRST SEARCH IN JAVA


import java.util.Scanner;
class Stack
{
    int stk[]=new int[10];
    int top;
    Stack()
    {
        top=-1;
    }
    void Push (int item)
    {
        if (top==9)
            System.out.println("Stack overflow");
        else
        stk[++top]=item;
    }

19. LINKED LIST WITH STACK IN JAVA



import java.util.Scanner;
public class StackLL
{
    Node start=new Node();
    Node top=new Node();
    Node curr=new Node();
    int ch,num;

    StackLL()
    {
        num=0;
        start=null;
        top=null;
    }

18. LINKED LIST WITH QUEUE IN JAVA



import java.util.Scanner;

public class Node
{
    int info;
    Node next,prev;
    Node left,right;
}

public class QueueLL
{
    Node start=new Node();
    Node end=new Node();
    Node curr=new Node();
    int ch,num;
    Object obj=new Object();

17. SINGLE LINKED LIST IN JAVA



import java.util.Scanner;
public class SingleLL
{
    Node start=new Node();
    Node end=new Node();
    Node curr=new Node();
    int num;

    SingleLL()
    {
        start=null;
        end=null;
        num=0;
    }

16. DOUBLE LINKED LIST IN JAVA



import java.util.Scanner;

public class Node
{
    int info;
    Node next,prev;
    Node left,right;
}

public class DoubleLL
{
    Node start=new Node();
    Node end=new Node();
    Node curr=new Node();
    int num;
  

15. CIRCULAR QUEUE IN JAVA



import java.util.*;
public class CircularQueue
{
    int front,rear,size=5;
    int a[]=new int[size];

    CircularQueue()
    {
        front=rear=size-1;
    }

14. BINARY TREE TRAVERSAL (RECURSIVE & NON-RECURSIVE) IN JAVA



import java.util.Scanner;
import java.util.Stack;

public class Node
{
    int info;
    Node next,prev;
    Node left,right;
}

13. BINARY TREE ARRAY IN JAVA



import java.util.Scanner;

class NodeBT
{
    int info;
    boolean used;
}

public class BinaryTreeArray
{

    NodeBT node[]=new NodeBT[20];

Saturday, April 21, 2012

12. SRT SCHEDULING IN JAVA


import java.util.*;
public class SRT {
public static void main(String args[]){
int table1[][] = new int[5][6];
int table2[][] = new int[5][6];
int total = 0;
boolean con[] = new boolean[5];
boolean fin[] = new boolean[5];
boolean lowest[] = new boolean[5];
Scanner sc = new Scanner(System.in);
for(int a=0;a<5;a++){

11. SJF SCHEDULING IN JAVA


import java.util.*;
class SJF
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int pno[]=new int[10];
int bt[]=new int[10];
int wt[]=new int[10];
int tt[]=new int[10];
int tempwt[]=new int[10];
int tempno[]=new int[12];//stores process no temporary
int temp[]=new int[12];//represent Gantt chart
int n,i,j,ptr,t,t2;

10.FCFS SCHEDULING IN JAVA


import java.util.*;
class FCFS
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int p;
float t1=0,t2=0;
System.out.println("Enter number of processes");
p=in.nextInt();
int bt[]=new int[p];