Thursday, February 23, 2012

Technique: Binary search animation (recursive)

    Step by step animation. For the programming beginners to get a better understanding of binary search.(Click snail button to start animation and click it again to go back to the first page)
    Search a keyword, if found, return the index of the item in the array, if not found, return the index where the element should be inserted.(4 example keywords)





Cost: O(logn)

Binary search code in C++:

int binsearch( vector<string> words, int low, int high, string word )
{
     if ( high < low ) return -low ;//position to insert
     int mid = (low+high) / 2;
     if(words[mid]==word)
     {
         return mid;
     }
     else if ( word < words[mid] )
     {
         return binsearch( words, low, mid-1, word );
     }
     else
     {
         return binsearch( words, mid+1, high, word );
     }

}


More technique animations:

Quick Sort
Heap Sort
Merge Sort 
Bubble Sort 
Selection Sort 

Technique: Quick sort animation

    First round quick sort step by step animation, for the programming beginners to get a better understanding of quick sort algorithm.(Click snail button to start animation and click it again to go back to the first page)



Cost: O(nlogn)
Worst case: O(n^2)
Best case: O(nlogn)

Quick sort code in C++:

void quickSort(int arr[], int left, int right) {
      int i = left, j = right;
      int temp;
      int pivot = arr[(left + right) / 2];

      /* partition */
      while (i <= j) {
            while (arr[i] < pivot)
                  i++;
            while (arr[j] > pivot)
                  j--;
            if (i <= j) {
                  temp = arr[i];
                  arr[i] = arr[j];
                  arr[j] = temp;
                  i++;
                  j--;
            }
      };

      /* recursion */
      if (left < j)
            quickSort(arr, left, j);
      if (i < right)
            quickSort(arr, i, right);
}



More technique animations:

Heap Sort
Binary Search
Merge Sort 
Bubble Sort 
Selection Sort 

Friday, February 10, 2012

Jiangnan 江南

    I thought I loved traveling before I arrived here. Later, I suddently found a place, without history, without culture, only beautiful views is meaningless for me. I started to read Chinese history again. A history book writer said history is not a story,but is real,which gives me a new angle to view it. People in history spent every single seconds in their lives just as what you are doing now.Thousands of years, technology was improved, environment was changed, but people are still there. They repeatedly did the same thing and considered about the same questions.
 
    For long time, a huge question always confused me: what my life will be?  I tried to find the answer by searching the people with similar personality, background and experiences in history. I know it is silly because I will finally figure it out at the end of my life. I believe that people can control their destiny somehow. But I also believe everyone follows a certain path, not designed by any supernatural being, but by the historical rules. We can find it if we do a huge data analysis of all the people in history,but it is a secret of life.

    Back to today's topic. Jiangnan is the general name of several provinces located in the middle south of China, near the east coast.Many cities have more than 5000 years of history and 2000 years of culture. It is not my hometown, but I was deeply impressed. In history, the richest people, literati and poets all lived there. Not like the north, where the wars, disasters and famine often happened; Not like the further south, where the land was uncivilized; Jiangnan is a place represented peace, harmony and richness.



    This Flash is not a picture gallery, if you want, you can find many photos online.(http://allold.blogspot.com/2012/02/old-garden-chinese-garden-art.html) I just want to show what Jiangnan looks like and why it is special. My favorite picture is the right lower corner one. Imagine in the early summer, you sit in the pavilion. In front of you is a large lake with several boats on it. You can see a stone bridge and several willow trees shaking its branches slightly. Outside is the soft and misty rain dropped on the lake. It is the only sound you can hear. You can think anything or nothing, just like the people thousands years ago. I can not find a second place, without religion, but can purify your heart.

    The top one and left lower corner one are not part of Jiangnan. The top one is  an old north city. The left one is an old town where minority lives. (Click the dolphin to open the poem, and click the poem to hide it.)

Thursday, December 22, 2011

Psychological Tests & Love Tests

    To celebrate Christmas, and one year anniversary of this blog, I made a simple psychological test in Flash. It is not something professional,I read it from a Chinese blog, translated and made some changes, just for fun. Test your future love.




    Here is another love test I read in Chinese, which is very interesting. I do not know the original author, but it seems come from in Japan. It is about the fingerprint, which I think is universal. I translated it, you can try.

[The index finger of your right hand can decide your LOVE ] 

    A Janpanese engineer collected fingerprints from 50000 people through internet. After his analysis, he found the fingerprint had some relationship with people's personality, especially their opinions on "Love". The fingerprints were divided into 8 categories, and each represents one kind of love. It says the accuracy is 90%. If you are interested in it, you can compare your finger with the picture below. (Check your right hand index finger)


A.You have strong loyalty to your sweetheart. You are gental and kind, but you are a little lack of enthusiasm.

B.Although you have a stable relationship,once you find another attractive person, you will become exciting again because you always like the feeling of fresh.

C.When in a relationship, you are always the passive role,and are always waiting for him or her to make decision. Sometime, you may unrealistically idealize your partner.

D.You need long time to watch your partner's behaviors. Once you find the personality is not fit, you will end it. However, it is hard for you to forget the past and move on.

E.You are romantic person. Once in relationship, you mind will be full of fantasy and unreal imagination about this new love.

F.You can always keep your brain awake when fall in love. You do not want to stay with your partener all the time,and you do not want your partner to be so aggressive, but you are looking for a stable relationship that can last forever.

G.You are waiting for a romatic relationship,but you are not good at expressing yourself. As a result, you missed some good opportunites.(Note:this fingerprint can be more round, but it is different from E)

H.This kind fingerprint dose not have some rules as the ones above, so if you find your fingerprint is not belonging to any situation above,you can check this one. You have experienced several failed relationships, probably because you always follow your mind and do not consider the feelings of others. 

Wednesday, December 7, 2011

Knitting Poodle dog

   Finally I finished my new work, which is also the birthday gift this year for my Mom.There are two reasons to knit a poodle dog: dog is my mother's Chinese Zodiac; I had a poodle dog during the period of high school, and it was given to others after I entered university because no one had time to take care of him.

 

    His name is "猜猜", which is "Guess" in English. He was just a 2 months baby when came to my home. The original owner said he would become a cute toy Poodle up to 7 inches, but he grew to a 15 inches middle size dog, which made us a little bit disappointed at the beginning. I love dog, and missed him so much.

Pictures from the side

    This work took me about 1 month. The most difficult part is the shape, the proportion of the head, body and feet. Here are some tips when knitting a toy that using four feet to stand:(1) The length of the body is twice as the head; (2) The height of the head, the height of body and the length of the feet should be similar.(3) The size of the eyes should be a little bit smaller than the nose.

Family photo

    This will be the only family photo for them, next year, the dog will be in China. 
    It is strange, every time when I finished one work, I want to give it away soon. Maybe I will never be the person that cherish them the most.

    Mom, happy birthday!

Saturday, October 29, 2011

Handcraft course

Finally, I have chance to be a handcraft course teacher, which I was looking forward for long time. It is a volunteer opportunity in an elementary school to teach children making jewelries. I have 8 students.

Bracelet

The job that can bring others happiness will bring you happiness as well. The job that only can generate the profits will only bring you the money.
Honestly, I do not like children, but I find you can make them happy easily, and get happiness as well.   


Accessories

Student's work (right)

Ten minutes before class ending, the parents of all the other 7 girls came, and made jewelries with their children together, only one girl sit there alone and said her parents never came to pick her up on time. When other girls stay around me to learn the patterns, she always sit far away. So every time when the class was over, I noticed she had not learned it. She made me think of my childhood. 

I always believe the personality is formed when people are young. When you can not get enough love, you are disappointed, then tell yourself that you don't need it, you become independent so that no one can make you disappointed, you try hard to make yourself shining to prove you can live on you own...
But finally, you find you are already incompatible with the world, because people in this world are always pursuing love, happiness and beautiful things. But you are already far away from them.

I will teach this girl first next class.          

Tuesday, August 9, 2011

Knitting bunny

Here is my new work, a knit bunny. It cost me one month to finish. I took it apart and remade it several times, though it is still not ideal. I put too much cotton in her body, so she looks a little fat.


Bunny front under sunshine

Bunny side photo


I put it into a small bathtub, does she look cute?
I filled the tip of her feet and the bottom of her body with small glass ball, so she can sit steadily.
Below is a flash animation shows 360 degree of the bunny:



Have to say, the stop motion effect is not very good. I want to make it like the news paper in Harry Potter.




Wednesday, July 13, 2011

Knitting Hamster


I planed to knit a hamster because I just got one. But it more looks like a mouse.

Hamster front picture

I made it as a key chain


 This is a picture they stay together.

Ha, they play together
My hamster is called Cherry, this is her three layer house and activity center.
                
                                  She looks scared!

Thursday, March 31, 2011

Flash frame-by-frame animation "fighting"

Simulate my first work in 2003... Of course the drawing is much better than 8 years ago.
Animation is really a time consuming work, especially "frame by frame animation".

Finally finished this work,not perfect because it is so so so time consuming!
I need to go outside to breath fresh air!
Hope you like it.
(if your browser does not support flash, please click following link to check its video version:
http://www.youtube.com/watch?v=b0715KROQPg&feature=plcp






I would like to recommend a Flash MV, made by Chinese students majored in Computer Animation. Really fabulous: