This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.util.Pair; | |
import java.util.ArrayList; | |
import java.util.Scanner; | |
public class Main { | |
static int[][] cities = { | |
//0 1 2 3 4 5 | |
{-1, 20, 30, -1, -1, -1}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int id; | |
int main() { | |
id = fork(); | |
if (id == 0) { | |
printf("Child : Child ID: %d, Parent ID: %d\n", getpid(), getppid()); | |
} | |
else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.SortedMap; | |
import java.util.TreeMap; | |
import java.util.Vector; | |
public class SchedulingProblem { | |
static Vector<Integer> processTime = new Vector<>(); | |
static Vector<Integer> processWeight = new Vector<>(); | |
static SortedMap<Integer, Double> timeWeightRatio = new TreeMap<Integer, Double>() { | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Comparator; | |
import java.util.TreeSet; | |
public class ChangeMaking { | |
static TreeSet<Integer> coins = new TreeSet<>(Comparator.reverseOrder()); | |
static int amount = 126; | |
public static void main(String[] args) { | |
coins.add(50); | |
coins.add(25); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <pthread.h> | |
#include <semaphore.h> | |
#include <ctype.h> | |
char inputString[100],uppercaseString[100]; | |
sem_t len; | |
void *reader() { | |
printf("Enter first text:"); | |
scanf("%s", inputString); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <pthread.h> | |
#include <semaphore.h> | |
#include <math.h> | |
#include <ctype.h> | |
int number = 10, buff = 0; | |
char queue[10]; | |
sem_t full_sem, empty_sem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <pthread.h> | |
#include <semaphore.h> | |
#include <math.h> | |
#include <ctype.h> | |
int number = 10, buff = 0; | |
char queue[10][10]; | |
sem_t full_sem, empty_sem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.util.PriorityQueue; | |
import java.util.Scanner; | |
import java.util.TreeMap; | |
/* Huffman coding , decoding */ | |
public class Huffman { | |
static final boolean readFromFile = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class GeneticOperators { | |
public static int[] initialize(int[] gene) { | |
int dimensions = (int) Math.sqrt(gene.length); | |
for (int i = 0; i < gene.length; i++) { | |
if (gene[i] == 0) gene[i] = new Random().nextInt(dimensions) + 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CoinOfValues { | |
public static void main(String[] args) { | |
int number = 10; | |
int[] coins = {2, 3, 7}; | |
int[][] dpMatrix = new int[coins.length + 1][number + 1]; | |
for (int i = 0; i <= coins.length; i++) | |
dpMatrix[i][0] = 1; | |
for (int i = 1; i <= number; i++) | |
dpMatrix[0][i] = 0; |