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...

106,436 8       ALGORITHM GAUSSIAN BLUR IMAGE BLUR


  Algorithm: Traverse binary tree

PrefaceThere are three ways to traverse a binary tree based on the traversing order.Pre-Order: Root - Left - RightIn-Order: Left - Root - RightPost-Order: Left - Right - RootTake below binary tree as exampleThe node to be traversed in different order would bePre-Order: A - B - C - D - E - FIn-Order: C - B - D - A - E - FPost-Order: C - D - B - F - E - ABelow are the implementations of different orders for traversing the binary tree.Pre-Order TraversingRecursive implementationNon-recursive implementationIn-Order traversingRecursive implementationNon-recursive implementationPost-Order traversing...

2,242 0       ALGORITHM BINARY TREE


  Sort an array with only one local variable

Array sorting algorithm question is frequently asked during technical interviews. There are lots of sort algorithms including bubble sort, selection sort, insertion sort, quick sort, merge sort etc. Usually interviewees will be asked to implement sort algorithms. But have you ever been asked to sort an array which you are allowed to define ONLY ONE local variable in your algorithm? Bubble sort can be used to do this actually. Normally a bubble sort algorithm may need three local variables : the index variable, the boolean variable to determine whether continue, a temp varia...

4,994 3       JAVASCRIPT ALGORITHM SORTING BUBBLE SORT


  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,142 1       JAVASCRIPT ALGORITHM GAUSSIAN BLUR MEDIUM BLUR IMAGE


  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,001 5       ALGORITHM RECURSION TAIL RECURSION TRADITIONAL RECURSION


  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,172 2       ALGORITHM BASE64


  Algorithm : Reverse singly linked list

Questions about singly linked list are the lovers of interviewers during interviews given the characteristic that singly linked list is one-directional list and it's difficult to get the previous node of one node without some buffering tricks. In this post, we will demonstrate one of the most frequently asked question about singly linked list -- Reversing the singly list.Given the first node of a singly linked list, reverse the singly linked list. For example :A->B->C->DAfter reverse, it becomes:D->C->B->AThe general idea here is to changing the next node of one to its p...

5,429 0       C ALGORITHM INTERVIEW


  Algorithm : Delete middle node from singly linked list

Questions about singly linked list are frequently asked during technical interviews. Today we will share with you one algorithm question about singly linked list. Here is the problem description.Assuming the only information you are giving is there is a pointer to a middle node of a singly linked list, no other information about the linked list is given. Please delete this node and don't affect the structure of the linked list.Initially you may think this question is easy if you know the head node of the linked list, but unfortunately we don't know what the head is and hence we cannot know the...

8,241 0       C ALGORITHM LINKED LIST