Static block can be used to check conditions before execution of main begin, Suppose we have...
-
Upload
neil-harrington -
Category
Documents
-
view
215 -
download
0
description
Transcript of Static block can be used to check conditions before execution of main begin, Suppose we have...
Static block can be used to check conditions before execution of main begin, Suppose we have developed an application which runs only on Windows operating system then we need to check what operating system is installed on user machine. In our java code we check what operating system user is using if user is using operating system other than "Windows" then the program terminates.
Bubble sort
Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed
Although the algorithm is simple, it is too slow and impractical for most problems even when compared to insertion sort.[1] It can be practical if the input is usually in sort order but may occasionally have some out-of-order elements nearly in position.
Insertion Sort
Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort. However, insertion sort provides several advantages:
• Simple implementation and efficient for (quite) small data sets•More efficient in practice than most other algorithms sort
such as selection sort or bubble sort•Adaptive, i.e., efficient for data sets that are already
substantially sorted• Stable; i.e., does not change the relative order of elements
with equal keys• In-place; i.e., only requires a constant amount of additional
memory space•Online; i.e., can sort a list as it receives it