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 Heap<E extends Comparable> { | |
private java.util.ArrayList<E> list = new java.util.ArrayList<E>(); | |
/** Create a default heap */ | |
public Heap() { | |
} | |
/** Create a heap from an array of objects */ | |
public Heap(E[] objects) { | |
for (int i = 0; i < objects.length; i++) |
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 SelectionSort { | |
/** The method for sorting the numbers */ | |
/* | |
* Worst Case: O(n^2) | |
*/ | |
public static void selectionSort(double[] list) { | |
for (int i = 0; i < list.length - 1; i++) {//Runs n times | |
// Find the minimum in the list[i..list.length-1] | |
//Get each element in the list for comparisons |
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 MergeSort { | |
/** The method for sorting the numbers */ | |
/* | |
* Worst Case: O(n log n) | |
*/ | |
public static void mergeSort(int[] list) { | |
if (list.length > 1) { | |
// Merge sort the first half |
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 InsertionSort { | |
/** The method for sorting the numbers */ | |
/* | |
* Worst Case: O(n^2) | |
*/ | |
public static void insertionSort(double[] list) { | |
for (int i = 1; i < list.length; i++) { ///Runs n times | |
/** insert list[i] into a sorted sublist list[0..i-1] so that |
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
/* | |
============================================================================ | |
Name : Dining_Philosopher.c | |
Author : | |
Version : | |
Copyright : Your copyright notice | |
Description : Hello World in C, Ansi-style | |
============================================================================ | |
*/ |
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 <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <netdb.h> | |
#include <stdlib.h> | |
#include <string.h> | |
// error handling | |
void error(char *msg) |
NewerOlder