Blog Archives

Molecule to atoms

molecules-

Here is a interested algorithm question on codewars site. For a given chemical formula represented by a string, count the number of atoms of each element contained in the molecule and return an object. For example: water = ‘H2O’ parse_molecule(water)

Posted in Algorithm Tagged with: ,

Performance on sum of many ints by Python

sum

There is a such question  at codewars(http://www.codewars.com) site. Write a function to do calculation according below formula: for i from 1 to n, do i % m and return this sum for example: f(n=10,m=5) //return 20 (1+2+3+5+0+1+2+3+4+0) actually it is

Posted in Algorithm Tagged with: ,

Draw Bezier and B-spline curve with HTML5 + Javascript

Draw Bezier and B-spline curve by HTML5 and Javascript

This is a online tool for drawing Bezier and B-spline curve. Main technologies used in this tool are HTML5, Javascript and Paper.js which one is a great framework that runs on top of the HTML5 Canvas.

Posted in CG, HTML5, Javascript Tagged with: , , ,

Algorithm in C# : Write a C# program to sort a array using Bubble Sort algorithm

banner_bubbles[1]

Bubble sort is one of the simplest sorting algorithm but if you ask anyone to implement on the spot it gives you an opportunity to gauge programming skills of a candidate. Let us take the array of numbers “5 1

Posted in Algorithm, C# Tagged with: ,

Algorithm in C# : How to reverse String

hellowworld

This is one of my favorite question. Since String is one of the most important type in programming, you expect lot of question related to String any data structure interview. There are many ways to reverse Sting in C# or any other programming language, and

Posted in Algorithm, C# Tagged with: ,

Algorithm in C# : In an integer array, there is 1 to 100 number, out of one is duplicate, how to find?

number array

This is a rather simple data structures question, especially for this kind of. In this case you can simply add all numbers stored in array, and total sum should be equal to n(n+1)/2. Now just subtract actual sum to expected sum,

Posted in Algorithm, C# Tagged with: ,

Algorithm in C# : How to find 3rd element from end in a linked list in one pass?

ironchain

This is another frequently asked linked list interview question. This question is exactly similar to finding middle element of linked list in single pass. If we apply same trick of maintaining two pointers and increment other pointer, when first has moved upto 3rd element, than

Posted in Algorithm, C# Tagged with: ,

Algorithm in C# : How to find if linked list has loop ?

linkedlist

This question has bit of similarity with earlier algorithm and data structure interview question. I mean we can use two pointer approach to solve this problem. If we maintain two pointers, and we increment one pointer after processing two nodes and other

Posted in Algorithm, C# Tagged with: ,

Algorithm in C# : How to find middle element of linked list in one pass?

linkedlist

One of the most popular question from data structures and algorithm, mostly asked on telephonic interview. Since many programmer know that, in order to find length of linked list we need to first traverse through linked list till we find last

Posted in Algorithm, C# Tagged with: ,

Princeton Univerisy Lectures: Algorithms Part I – Analysis of Algorithms(4) – Order-of-Growth Classifications

1

by Kevin Wayne, Robert Sedgewick Now, fortunately when we analyze algorithms, actually not too many different functions arise and actually that property allows us to really classify algorithms according to their performance as the problem size grows. So that’s what

Posted in Algorithm Tagged with: