Jeliot - interactive algorithm animator
Previous Next Main window Home Index Front page Table of contents Errors

Description of the algorithms

Sequential search fo largest

A simple sequaential search algorithm, where an integer array is first initialized with random numbers. Then the algorithm goes through the array one index at a time, and finally prints the largest value.

Code

Sequential search test

The algorithm initializes an integer array with predefined numbers. It then uses a search() method that sequentially searches the array for a value that is given as a parameter. If the value is found (it it in the example code) the search() method returns true, otherwise false.

Code

Very simple 2D array

Indeed a very simple piece of code that basically just shows how to declare a two dimensional array, and then some assignments done to the array's components.

Code

BubbleSort

One of the classic sorting algorithms. The values to be sorted are in an array that is initialized with random values. The algorithm itself consists of two for-loops, the sorting starts from the end so that after first round of the outer for-loop the largest value is in the last slot, after the next round the two largest values are in their places and so forth.

Code

QuickSort algorithm

The quicksort algorithm is perhaps the most efficient algorithm, better than for example the bubble sort algorithm. QS is not always the best sorting algorithm, but for more discussion about that find a good book on algorithms. The values to be sorted are in an integer array that is intitialized with random values in the init() method. Then the recursive qSort() method is invoked. The algorithm works by splitting the table in smaller parts and sorting them by using the recursive calls - run it and see for your self :).

The swap() method is used to shorten the code in the sorting section. You may also want to notice that the changes made to the array that is given as a parameter have affects also outside the method.

Code

Binary Search

Code

Knuth-Morris-Pratt

A well known pattern matching algorithm. It searches for a pattern in a given text. If the length of the pattern is m and the length of the pattern is n then the algorithm's running time has an asymptotic upper bound of O(m+n). Without going in to detailed analysis of the algorithm one can state that the KMP algorithm has a running time linear to the length of the text (at least in situations such as searching from a text written in natural language, and m << n).

The example code intializes the text and the pattern in the init() method. After the initialization the algorithm advances to the start()

Code

Pattern matching trivial solution

Code A trivial solution for finding a certain string (=pattern) from another string (=text).

Towers of Hanoi

Code

Towers of Hanoi is a famous problem where you are supposed to move a number of disks from one peg to another.

Sample properties:

Loop tests

Code

A queue with life

Code

Fibonacci

Code

Hello Jeliot

A must since K&R.

Code


Sun May 17 1998