Bubble, fast, merge sort

A: Bubble sort: Save sort rule
II: Quick Sort: Divide and Conquer Algorithm
steps:
1. Find a reference value to be sorted in the entire space
2. The traverse the entire interval to be sorted, all the data and a reference value, to achieve a final
larger than the reference value (which may comprise equal to) the reference value to the right
than the reference value is smaller (may comprise equal to) the reference value to the left
by approximately the same two small policy processing section 3 to be sorted until
a : there is no inter-cell data within the (size == 0)
B: inter-cell has been ordered (size == 1)
focused on the first step, in order to avoid taking the most edge reference value which, if data has been ordered, reverse worst case scenario is
1) most edge
2) randomly
3) take the majority (three in number taken)
Step four ways:
1) approximately to the middle by: a: hover b: digging
2) before and after traversing a: before and after traversal B: the individual processing and the reference value equal to
how to calculate the time complexity:
. 1) partition process, time complexity is O (n-)
2) determines how many layers partition do:
can the process of partition See into a binary tree, its height is the number of layers of
two Height of the tree: O (log (n)) - O (n))
How to calculate the spatial complexity:
1) determining the recursive method call stack takes up to how many layers:
requires a highly level binary tree, it is O (log (n) ) -O (n)
III:: merge sort (merge sort)
the process of merging two sorted array
0. segmentation to be sorted average interval between the left and right if the two cells to be sorted has been ordered,
the ordered array in accordance with the combined manner, the final section ordered
1. The first find an intermediate position, between the left and right two divided cells, until the length between the cell == 1 <1
Thought the partition 2, to the left and right between the two cell sorting
3. combined ordered array

Guess you like

Origin blog.51cto.com/14232274/2438964