Monday, May 19, 2014

Technique: Selection Sort Animation

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


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

Selection sort code in C++:

void SelectionSort(int a[],int size)
{
       for(int i=0;i<size-1;i++)
       {
               int min=i;
               for(int j=i+1;j<size;j++)
               {
                      if(a[j]<a[min])
                      {
                             min=j;
                      }
                }

                if (min > i)
                      swap(a[i],a[min]);
        }
}

int main()
{
   int a[]={25,49,8,25,21,16,32};
   SelectionSort(a,7);

}


More technique animations:

Heap Sort
Binary Search
Merge Sort
Quick Sort
Bubble Sort

Wednesday, April 2, 2014

Technique: Bubble Sort Animation

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



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

Bubble sort code in C++:

void BubbleSort(int a[],int n)
{
    for(int i=1; i<n; i++
    {
                  for(int j=0; j<n-i; j++)
                  {
                      if(a[j] > a[j+1])
                       {
                         int temp;
                               temp = a[j];
                               a[j] = a[j+1];
                                    a[j+1] = temp;
                      }
                  }
    }
}

int main()
{
    int a[]={25,49,8,25,21,16,32};
    BubbleSort(a,7);

}


More technique animations:

Heap Sort
Binary Search
Merge Sort
Quick Sort
Selection Sort

Sunday, March 2, 2014

Knitting Painting 8" x 10”

    I always want  to try different styles of knitting works. This painting is 8" x 10". Before started, I went to the frame store to measure the size of picture I was going to make so I can pick a nice frame later. The background is simple purl needle knitting pattern. The girl, flower and butterfly are made by crochet.
   

    Actually the initial idea in my mind is to make the girl holding an umbrella in the rain. But the handle of umbrella didn't fit the girl very well. I decided to use hat instead.   


    I named this painting "Waiting for the wind". Just the first name pop up my mind. Wind is complicate, it can be good or bad. In a sunny day, a girl looked out into the field beyond view, the bird, the cloud, the butterfly and the flowers. Everything is quite and beautiful. She is waiting for something, something could be peace or challenge.


    Just moved to new place, wish I can have a new life, just like this girl