Tag Archives: algorithm

(JavaScript) Bresenham’s Line Algorithm

Code obtained from a [stackoverflow question](http://stackoverflow.com/questions/4672279/bresenham-algorithm-in-javascript). This is a javascript implementation of the [Bresenham line algorithm](http://en.wikipedia.org/wiki/Bresenham’s_line_algorithm). Given two points, this function will return an array of coordinates which go from point A to point B, one step at a time.

Posted in JavaScript | Also tagged , , , , | 2 Comments

Minimax algorithm with alpha-beta pruning in C#

Minimax is an algorithm where two players (min and max) play against each other for minimizing loss and maximizing gain. The following picture illustrates minimax with a game of tic-tac-toe. The algorithm uses a tree for the moves and scores of each player. In some cases, it is unnecessary for the algorithm to check certain subtrees. [...]

Posted in C# | Also tagged , , , , , , , , , , , , , , , , | 1 Comment

Closest pair of points problem in C++

Given n points, find two points with the smallest distance to each other. The examples listed below demonstrate two algorithms in C++ to tackle this problem. One algorithm simply checks every combination of points, also known as a brute force approach. The other one is an efficient algorithm which uses a divide and conquer approach.  The [...]

Posted in C++ | Also tagged , , , , , , , , , | 2 Comments

Blowfish-based hashing for passwords in PHP

Storing passwords in a secure manner is very essential. Users can fall victim of cybercrime if a system containing the passwords of the users has been breached. DataLossDB illustrates the amount of data lost due to breaches. A cryptographic hash function can be used for creating a representation of a plaintext password, also known as [...]

Posted in PHP | Also tagged , , , , , , , , , , , | 2 Comments

Bubble sort algorithm in C

Bubble sort is a basic sorting algorithm where the elements rise to the top of the list. The picture below illustrates the algorithm.

Posted in C | Also tagged , , , , , , , | 2 Comments

Quicksort algorithm in C#

Quicksort is a divide and conquer sorting algorithm. This example uses the quicksort algorithm to sort an array of string elements.

Posted in C# | Also tagged , , , , , , | 13 Comments