Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALGORITHM


  Gaussian Blur Algorithm

Usually, image processing software will provide blur filter to make images blur.There are many algorithms to implement blur, one of them is called Gaussian Blur Algorithm. It utilizes Gaussian distribution to process images.This article is to introduce Gaussian Blur algorithm, you will find this is a simple algorithm. In fact, it is a kind of data smoothing which can be used in many situations.1. Gaussian Blur theoryThe so called blur can be understood as taking a pixel as the average value of its surrounding pixels.On the above graph, 2 is the center point, the surrounding points are 1.The ce...

107,783 8       ALGORITHM GAUSSIAN BLUR IMAGE BLUR


  Implementation of +,-,*,/ with bitwise operator

There is a question asked on Stackoverflow : Divide a number by 3 without using *,/,+,-,% operators. This question is an Oracle interview question. Some people give excellent answers. You can go there and take a look. Usually we need to use bitwise operators to do this kind of implementations. Here I want to show you ways to implement +,-,*,/ with bitwise operators.A bitwise operation operates on one or more bit patterns or binary numerals at the level of their individual bits. It is a fast, primitive action directly supported by the processor, and is used to manipulate values for comparisons ...

39,289 3       DIVISION BITWISE OPERATOR SHIFT ADD SUBTRACT MULTIPLICATION


  Loading images progressively using Gaussian blur

The popular online publishing platform Medium has adopted an impressive image loading mechanism -- pure color - blur image loading - real image loading.Since images on Medium usually have high definition, it takes much time to load an image and hence brings a bad user experience if rendering the image after it's completely downloaded. The solution Medium comes out is to preload an small image when the real image is being loaded. On Medium, the HTML code will have below pattern for every page.<figure name="512a" id="512a" class="graf--figure graf--layoutCroppedHe...

38,249 1       JAVASCRIPT ALGORITHM GAUSSIAN BLUR MEDIUM BLUR IMAGE


  Permutation algorithm with JavaScript

In secondary school, we have learned permutation. Basically, for n numbers, the number of permutations for these n numbers can be calculated to n! which is called 'n factorial'. But to display all the permutations on the screen, we need to use a recursive function. The problem is how to write this function. Next I write a program to display the permutations for n numbers with JavaScript. First, we need to understand that from these n numbers, we can first take any one number from it, and the (n-1) numbers remaining has the similar property as the n numbers, we need to find the permutation...

34,905 0       JAVASCRIPT ALGORITHM PERMUTATION IMPLEME


  How does Base64 work

Base64 is a data encoding scheme used in safe data transfer such as HTTP and its extensions. Base64 encoding can conver arbitrary group of bytes into a sequence of readable ASCII characters. These converted characters can safely put in a HTTP header without causing any problem while the peers process the HTTP header.Base64 encoding was invented as part of the MIME content transfer encoding. It is similar to other encoding schemes such as Uuencode and BinHex but with higher efficiency.8 bit to 6 bitBase64 will divide the bytes into groups of 6 bits. Every 6 bits will map to a characte...

30,652 2       ALGORITHM BASE64


  Traditional recursion vs Tail recursion

Recursion is a frequently adopted pattern for solving some sort of algorithm problems which need to divide and conquer a big issue and solve the smaller but the same issue first. For example, calculating fibonacci  accumulating sum and calculating factorials.In these kinds of issues, recursion is more straightforward than their loop counterpart. Furthermore, recursion may need less code and looks more concise.For example, let's calculate sum of a set of numbers starting with 0 and stopping at N where N might be a large number. The loop way is quite simple for this issue.private stati...

23,558 5       ALGORITHM RECURSION TAIL RECURSION TRADITIONAL RECURSION


  Generate first N prime numbers

Recently I am taking an online course named "Startup Engineering" on coursera. There is one assignment which is to use NodeJS to write a program to generate the first 100 prime numbers. This may be very easy for many people. Here I just want to share with you the code to generate not only the first 100 prime numbers. but also any number of prime numbers.Below is the code snippet://Helper class to generate prime numbersvar PrimeProcessor=(function(){ var primeArray=[]; function _isPrime(num){ if(num<=1){ throw new Error("Number cannot be sm...

11,795 5       JAVASCRIPT ALGORITHM NODEJS PRIME NUMBER COURSERA


  Binary tree iterator algorithm

Binary tree pre-order,in-order and post-order traversal are basics in algorithm and data structure.And the recursive binary tree traversal is a classical application of recursion.We define a binary tree node as :// C++struct Node { int value; Node *left; Node *right;}In order binary tree traversal can be:// C++void inorder_traverse(Node *node) { if (NULL != node->left) { inorder_traverse(node->left); } do_something(node); if (NULL != node->right) { inorder_traverse(node->right); }}Easy enough, right? Pre-order and post-order traversal algorithm...

11,651 1       ITERATOR BINARY TREE TRAVERSAL