What are Hash Tables and how do they work?

As we saw with binary search, certain data structures such as a binary search tree can help improve the efficiency of searches. From linear search to binary search, we improved our search efficiency from O(n) to O(logn). We now present a new data structure, called a hash table, that will increase our efficiency to O(1), or constant time. Continue reading ‘What are Hash Tables and how do they work?’

What is a Binary seach algorithm and how does it work?

A binary search algorithm (or binary chop) is a technique for finding a particular value in a linear array, by ruling out half of the data at each step, widely but not exclusively used in computer science. Continue reading ‘What is a Binary seach algorithm and how does it work?’

Huffman encoding algorithm

Data transmission and storage cost money. The more information being dealt with, the more it costs. In spite of this, most digital data are not stored in the most compact form. Rather, they are stored in whatever way makes them easiest to use, such as: ASCII text from word processors, binary code that can be executed on a computer, individual samples from a data acquisition system, etc. Continue reading ‘Huffman encoding algorithm’

What is Heap sort and how does it work? Heap sort algorithm animation

Heapsort is one of the best general-purpose sorting algorithms, a comparison sort and part of the selection sort family. Continue reading ‘What is Heap sort and how does it work? Heap sort algorithm’

What is QuickSort and how does it work? Quick Sort algorithm

Pick an element from the array (the pivot), partition the remaining elements into those greater than and less than this pivot, and recursively sort the partitions. There are many variants of the basic scheme above: to select the pivot, to partition the array, to stop the recursion on small partitions, etc. Continue reading ‘What is QuickSort and how does it work? Video of cards sorted by Quick sort’

Selection sort in C++, What is selection sort?

Selection sort performs sorting by repeatedly putting the largest element in the unprocessed portion of the array to the end of the this unprocessed portion until the whole array is sorted. Continue reading ‘What is Selection sort and how does it work? Selection sort algorithm’

The Towers of Hanoi

In an ancient city in India, so the legend goes, monks in a temple have to move a pile of 64 sacred disks from one location to another. The disks are fragile; only one can be carried at a time. A disk may not be placed on top of a smaller, less valuable disk. Continue reading ‘The Towers of Hanoi’

Sort by repeatedly taking the next item and inserting it into the final data structure in its proper order with respect to items already inserted. It inserts each element of the array into its proper position. Continue reading ‘The Insertion sort algorithm’

The Backtracking algorithm/method, MAZE
Backtracking method tries to find a solution by trying one of several choices. If the choice proves incorrect, computation backtracks or restarts at the point of choice and tries another choice. Continue reading ‘The Backtracking algorithm/method’

The Las Vegas algorithm/method

A Las Vegas algorithm is a randomized algorithm that always gives the correct answer. Because of its nondeterministic nature, the run-time of a Las Vegas algorithm is a random variable. Continue reading ‘The Las Vegas algorithm/method’

Fibonacci numbers, The Dynamic programming method

It can be described as follows: solve each small problem once, saving their solution; use the solutions of small problems to obtain solutions to larger problems. Continue reading ‘The Dynamic programming method’

The divide and conquer method works as follows, divide big problem into smaller sub problems; conquer each sub problem separately; merge the solutions of the sub problems into the solution of the big problem. Continue reading ‘The Divide and Conquer algorithm/method’

The Monte Carlo method is a way of solving problems using statistical methods; stochastic technique (which means using random numbers) and probability. Continue reading ‘The Monte Carlo algorithm/method’

A greedy algorithm repeatedly executes a procedure which tries to maximize the return based on examining local conditions, with the hope that the outcome will lead to a desired outcome for the global problem. Continue reading ‘The Greedy algorithm/method’

Bubble sort, sometimes shortened to bubblesort, also known as exchange sort, is a simple sorting algorithm. Continue reading ‘What is Bubble sort and how does it work?’

Sorting algorithm, What is sorting?

In computer science and mathematics, a sorting algorithm is an algorithm that puts elements of a list in a certain order. The most used orders are numerical order and lexicographical order. Continue reading ‘What is sorting?’