Skip to content

Instantly share code, notes, and snippets.

View AnimeshShaw's full-sized avatar
🏠
Working from home

Animesh Shaw AnimeshShaw

🏠
Working from home
View GitHub Profile
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class PongGame extends Applet implements Runnable {
Thread th;
boolean rbup = false;
boolean rbdown = false;
boolean lbup = false;
import java.awt.*;
import java.applet.*;
import java.awt.image.*;
public class PixeloMatic extends Applet implements Runnable {
int pixl2[] = new int[256];
Thread t = null;
final int width=500, height=500;
Image buffer = null;
@AnimeshShaw
AnimeshShaw / LCS.c
Last active December 22, 2015 18:38
Lowest Common Subsequence in C using Dynamic Programming. Live preview : http://codepad.org/xXbnYDqy
#include<stdio.h>
#include<string.h>
int max(int a, int b) {
return a > b ? a : b;
}//end max()
int main() {
char a[] = "train";
char b[] = "rain";
@AnimeshShaw
AnimeshShaw / LCS_Recursive.c
Last active December 22, 2015 18:38
Recursive implementation of LCS (Lowest Common Subsequence) problem. Live Preview :- http://codepad.org/WWGCWVzJ
#include<stdio.h>
int max(int a, int b)
{
return (a > b)? a : b;
}
/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
int lcs( char *X, char *Y, int m, int n )
{
@AnimeshShaw
AnimeshShaw / NQueens.c
Last active December 22, 2015 18:39
N Queens Problem implemented in C using backtracking technique. Here we have considered n=4. Live Preview : http://codepad.org/FO5V9gk4
#include<stdio.h>
char a[10][10];
int n = 4;
void printmatrix() {
int i, j;
printf("\n");
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++)
@AnimeshShaw
AnimeshShaw / KnapSack.c
Created September 11, 2013 14:36
KnapSack Problem implemented in C using Recursion
#include <stdio.h>
#include <stdlib.h>
int w[10], p[10], v[10][10], n, i, j, capacity, x[10] = {0};
int max(int i, int j) {
return ((i > j) ? i : j);
}
int KnapSack(int i, int j) {
@AnimeshShaw
AnimeshShaw / SelectionSort.java
Created September 12, 2013 18:18
Selection Sort implemented in Java.
import java.util.Scanner;
public class SelectionSort {
private static void swap(Comparable[] a, int i, int j) {
Comparable t = a[i];
a[i] = a[j];
a[j] = t;
}
@AnimeshShaw
AnimeshShaw / BubbleSort.java
Created September 12, 2013 18:19
BubbleSort implemented in Java
import java.util.Scanner;
public class BubbleSort {
private static void swap(Comparable[] a, int i, int j) {
Comparable t = a[i];
a[i] = a[j];
a[j] = t;
}
@AnimeshShaw
AnimeshShaw / InsertionSort.java
Created September 12, 2013 18:23
InsertionSort implemented in Java
import java.util.Scanner;
public class InsertionSort {
private static void swap(Comparable[] a, int i, int j) {
Comparable t = a[i];
a[i] = a[j];
a[j] = t;
}
@AnimeshShaw
AnimeshShaw / GnomeSort.java
Created September 14, 2013 18:10
Gnome Sort implemented in Java
package Sorts;
public class GnomeSort {
private static void gnomeSort(int[] ar) {
int i = 1;
int n = ar.length;
while (i < n) {
if (i == 0 || ar[i - 1] <= ar[i]) {
i++;