Posts

Showing posts from January, 2018

MTech Advanced Algorithm Lab (14SCS26)

Programs: Design, develop, and write a program to implement the Bellman-Ford algorithm and determine its performance. Give its applications. Design, develop, and write a program to implement a Monte Carlo algorithm to test the primality of a given integer and determine its performance. Design, develop, and write a program to solve string matching problem using naïve approach and the KMP algorithm. Compare their performances. Design, develop, and write a program to solve String matching problem using Finite Automata and determine its performance. Design, develop, and write a program to solve String matching problem using Rabin Karp algoritm and determine its performance.

Design, develop, and write a program to solve String matching problem using Finite Automataand determine its performance.

#include<stdio.h> #include<string.h> #define CHARS 256 int getNextState(char pat[30], int M, int state, int x) {             int ns, i;             if (state < M && x == pat[state])                         return state+1;             for (ns = state; ns > 0; ns--)             {                         if(pat[ns-1] == x)                         {       ...

Write a multi-class multithreaded program that simulates multiple sleeping barbers, all in one barbershop that has a finite number of chairs in the waiting room. Each customer is instantiated from a single customer class; each barber is instantiated from a single Barber class.

import java.util.concurrent.*; public class SleepingBarber extends Thread {             public static Semaphore customers = new Semaphore(0);                  public static Semaphore barber = new Semaphore(0);             public static Semaphore accessSeats = new Semaphore(1);             /*  the number of chairs in this barbershop is 5. */             public static final int CHAIRS = 5;             public static int numberOfFreeSeats = CHAIRS;             /* THE CUSTOMER THREAD */             class Custo...