Static block can be used to check conditions before execution of main begin, Suppose we have...

10

description

Bubble sort

Transcript of Static block can be used to check conditions before execution of main begin, Suppose we have...

Page 1: 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.
Page 2: 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.

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.

Page 3: 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.

Bubble sort

Page 4: 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.

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

Page 5: 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.

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.

Page 6: 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.

Insertion Sort

Page 7: 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.
Page 8: 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.
Page 9: 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.

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:

Page 10: 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.

• 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