Skip to content

Instantly share code, notes, and snippets.

//*******************************************************************
// File: HuffmanEncoding.c
// Author(s): Mohamed Ennahdi El Idrissi
// Date: 14-Aug-2012
//
// Input Files: in.txt
// Output Files: out.txt
// Description: CSC 2302 - <Data Structures>
// <Struct, Array, File I/O, Recursion, Pointers, Binary Tree>
// This program covers the Huffman Encoding concept.
package com.exercises.test;
import java.util.Random;
import com.exercises.main.EvaluationExercise;
public class EvaluationExerciseTest {
/**
* Unit testing of a random number of cases.
package com.exercises.main;
import java.util.Scanner;
/**
* @author Mohamed Ennahdi El Idrissi
*
*
* This program does the following:
* - Reading the size (int) of the array from the keyboard;
* - Reading each element of the array from the keyboard;
package com.blogspot.mohalgorithmsorbit.equation;
/**
*
* @author Mohamed Ennahdi El Idrissi
*
*/
public class Equation {
int n;
int base;
@mohamed-ennahdi
mohamed-ennahdi / MaximumSubsequence.c
Created February 24, 2014 04:08
Maximum Subsequence Contest Problem. Dynamic Programming.
#include <stdio.h>
#define N 256
#define L 1000000
#define nstr 100
/*
* 'str1' and 'str2' are two temporary variables where we store strings to process
*/
char str1[N];
char str2[N];
@mohamed-ennahdi
mohamed-ennahdi / PerfectHash.c
Created February 24, 2014 04:07
Perfect Hash Contest Problem.
#include <stdio.h>
#define LIST_MAX_SIZE 200
#define NUMBER_OF_WORDS 30
#define NUMBER_OF_CHARACTERS 5
typedef struct {
char word[NUMBER_OF_CHARACTERS];
int number;
int hashedNumber;
@mohamed-ennahdi
mohamed-ennahdi / TournamentStandings.c
Created February 24, 2014 04:05
Tournament Standings Contest Problem.
#include <stdio.h>
/*
* Maximum number of tournaments we can have.
*/
#define MAX 1000 - 1
/*
* Maximum size of the description string.
*/
#define DESC 80 + 1
@mohamed-ennahdi
mohamed-ennahdi / DNASorting.c
Created February 24, 2014 04:03
DNA Sorting Contest Problem
/*
* Mohamed Ennahdi El Idrissi
*/
#include <stdio.h>
/*
* M is the length of the string ( 0 < M <= 100 )
*/
#define M 100
/*
@mohamed-ennahdi
mohamed-ennahdi / MineSweeper.c
Created February 24, 2014 04:01
Mine Sweeper Contest Solution.
#include<stdio.h>
/*
* M is the maximum size that a line can take.
*/
#define M 100
/*
* N is the maximum size that a column can take.
*/
#define N 100
@mohamed-ennahdi
mohamed-ennahdi / HuffmanEncoding(ContestVersion).c
Created February 24, 2014 03:59
A contest Huffman Encoding Problem. This solution is expensive from an algorithm analysis perspective (unsuitable data structure preliminary choice). However, the algorithm is worth it.
#include <stdio.h>
#define N 26
/*
* This structure gathers the elements (letters) and their frequency.
*/
typedef struct {
char sourceAlphabet[N];
unsigned frequency;
} Symbol;