Skip to content

Various algorithms and data structures in c, prolog, sml, ocaml, java.

License

Notifications You must be signed in to change notification settings

alexMet/algorithms

Repository files navigation

Γλώσσες Προγραμματισμού Ι

My solutions for some algorithms, using multiple programming languages.

Γλώσσες Προγραμματισμού Ι (Programming Languages I) Προπτυχιακό μάθημα, 6ου εξαμήνου. Υποχρεωτικό στη ροή Λ της ΣΗΜΜΥ https://courses.softlab.ntua.gr/

C

gcc –std=c99 -Wall –Werror -O3 program.c -o el

SML

  • Priority queue
  • A* algorithm
  • Bresenham algorithm
  • Binary search
  • Merge sort
sml program.sml

OCaml

ocamlopt -O3 program.ml -o el

JAVA

  • Fibonacci Heap
  • Dijkstra
  • Bresenham algorithm
javac Program.java

Prolog

  • Binary search
swipl program.pl

YAP

yap program.pl

YAP is way faster than swipl. On the top of your program you'll need some imports, e.x.

:- use_module(library(readutil)).
:- use_module(library(heaps)).
:- use_module(library(assoc)).
:- use_module(library(lists)).

Examples

SML

- dromoi("testcases/anaptyksi04.txt");
val it = 1952 : int

val kouvadakia = fn : int -> int -> int -> string
- kouvadakia 5 7 6;
val it = "02-21-10-21-02-21-10-21-02-21" : string

Prolog

?- time(dromoi("testcases/anaptyksi05.txt", ANS)).
% 26,143,024 inferences, 36.835 CPU in 38.045 seconds (97% CPU, 709741 Lips)
ANS = 10435.

?- kouvadakia(5, 7, 6, X).
X = ['02', '21', '10', '21', '02', '21', '10', '21', '02'|...].

Java

time java Bats testcases/testcase1
896.8
java Bats testcases/testcase1  4.74s user 0.13s system 120% cpu 4.052 total

java Kouvadakia 5 7 6
02-21-10-21-02-21-10-21-02-21