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

SEARCH KEYWORD -- NG-REPEAT



  Gcd Algorithm with JavaScript

How to find the greatest common divisor between two integers? We may encounter this problem frequently in interviews or other occasions. An efficient metho to find gcd is the Euclidean algorithm, which uses the division algorithm in combination with the observation that the gcd of two numbers also divides their difference: divide 48 by 18 to get a quotient of 2 and a remainder of 12. Then divide 18 by 12 to get a quotient of 1 and a remainder of 6. Then divide 12 by 6 to get...

   JavaScript,Algorithm,Gcd,Implementation,     2011-09-21 15:57:32

  Find the kth smallest number in an array

This is an classical question, the general solution to this question is first using sorting algorithm to sort the array, then get the kth number in the array, the complexity is O(nlogn), we can also use selective sort or head sort to, the complexity of selective sort is O(kn) and heap sort is O(nlogk). The better solution is to use quick sort to find the kth smallest number, the complexity is O(n), the worst case cost is O(n^2). But today we introduce one more solution which has the worst case c...

   Sort, Quick sort, Search,Smallest     2013-01-09 06:20:54

  If a programming language was a boat…

我是受最近的一个论坛帖子启发,他的想法至今仍让我感到奇特。Turing(图灵)Turing绝对是一个双人皮划艇(感谢评论里的提醒)。它很小。人力的。它通常被当作初学者的”船“。è€...

   Programming,Turing,C,C#     2011-06-24 01:07:42

  There are no free lunches on the internet

Hot data: An IT technician checks the network servers at a data farm. Alamy Photograph: Juice Images/AlamyPhysics has Newton's first law ("Every body persists in its state of being at rest or of moving uniformly straight forward, except insofar as it is compelled to change its state by force impressed"). The equivalent forinternet services is simpler, though just as general in its applicability: it says that there is no such thing as a free lunch.The strange thing is that most use...

   Free lunch,Facebook,Google,Privacy information     2011-11-21 03:03:31

  What programming languages should I learn?

Since I started this blog, I have gotten quite a few emails asking me “What programming languages do you recommend for X?” I often finding myself writing something along the lines ofI would honestly recommend python. Something about me being biased because I know and love it.  Usually say something about the competing technology with a back handed insult. Also if they are starting out I would recommend a language that enforces better OO (Object Orientated) practic...

   programming language,Popularity,Java,Tre     2011-09-23 13:11:57

  Significance and use of do{...}while(0)

In some Linux kernel and other open source codes, we can see some codes like below: do{ ... }while(0) This code snippet is not a loop, it seems there is no significance of using do...while this way, then why should we use it? In fact, the significance of do{...}while(0) is better than optimizing your code. After some research, we summarize some benefits of it. 1. Help define complex macro to avoid error #define DOSOMETHING()\ foo1();\ foo2(); The me...

   do{...}while(0), optimization     2012-10-21 21:13:22

  Most Pressed Keys and Programming Syntaxes

I switch between programming languages quite a bit; I often wondered what happens when having to deal with the different syntaxes, does the syntax allow you to be more expressive or faster at coding in one language or another. I dont really know about that; but what I do know what keys are pressed when writing with different programming languages. This might be something interesting for people who are deciding to select a programming language might look into, here is a post on the...

   Keyboard,Programming language,Hottest ke     2011-09-23 13:10:10

  How big is sizeof structure?

First let's see the codes of a structure: struct node{ int a; int b; }; Question : What's sizeof(node)? The answer is very simple, on a 32 bit machine, an int will take 4 bytes and two ints will take 8 bytes. So sizeof(node) is 8. The answer for the above codes is 8, then how about the following structure: struct node{ char a; int b; }; Question : Then what's sizeof(node) now? int takes 4 bytes, char takes 1 bytes, is the answer 5? Now the answer may not be 5, on some mac...

   Data structure alignment, pack     2012-10-29 12:13:37

  Why should we drop or reduce use of MD5?

MD5 is a frequently used one-way hash algorithm, it is commonly used in following situations: Check data integrity. We take hash of the data stored in two different places and compare them. If the hash results are the same, then there is no need to check the actual data. This utilizes the collision-resistant feature. Two different data block will have little chance that their hash values will be the same. Many data service providers use such technique to check repeated data to avoild repeating...

   MD5,Vulnerability,attack     2012-09-29 04:47:49

  noConflict mechanism in jQuery

Many JavaScript frameworks like to use $ as function or variable name, jQuery is one of them. In jQuery, $ is just a reference to window.jQuery, so even if $ is deleted, window.jQuery will still be available to ensure the whole library can work normally. jQuery API design takes fully consideration of multiple frameworks conflicts, we can use jQuery.noConflict function to easily handle control. jQuery.noConflict accepts one optional boolean parameter[1] to determine whether to hand jQuery object ...

   jQuery,noConflict,$     2013-03-14 19:40:36