10/03/2010
Exception
try
{
---------
---------
}
catch(DividebyZero a)
{
---------
}
catch(Exception e)
{
---------
}
It will work.try
{
---------
---------
}
catch(Exception e)
{
---------
}
catch(DividebyZero a)
{
---------
}
It won't work, because catch(DividebyZero a) class has never been executed, which is called 'unreachable code'. = errorAlgorithms: a well-defined procedure to solve a problem
Sort Algorithm
- Bubble sort (one by one, taking long time)
- Exchange sort (similar to bubble sort, but slightly more efficient)
- Selection sort (search and sort, one of the least efficient)
Insertion sort
two sub arrays- first sub array: sorted
- second sub array: unsorted
- first sub array: sorted
- first and efficient using with small arrays.
Quick sort- divide and conquer algorism
- very efficient
- divide and conquer algorism
Merge sort- two sorted arrays (MUST be SORTED FIRST)
- more efficient but at the same time it is more complex
- two sorted arrays (MUST be SORTED FIRST)
Bucket sort- counts array
- counts array
Search Algorism
Liner search
- best case: first element
- worst case: last element
- not efficient
- best case: first element
Binary search- required a sorted array
- array 0 to 9 (0+9)/2 = 4.5 find 4
- (5+9)/2 = 7 find 7
- (5+6)/2 = 5.5 find 5
- (6+6)/2 = 6 find 6
- more efficient
- required a sorted array
0 件のコメント:
コメントを投稿