java data structure knowledge self-summary

Pre-class Review:
binary search time complexity (O (N))
space complexity: maximum length range of
complexity: scale (Tool) algorithm rough measure of the quality of
two dimensions: the speed of time complexity (focus)
the use of space space complexity case
time complexity: allow time measured directly unrealistic, changing the test environment, not a control variable
provided: if the specified cpu case, the number of basic instructions running in a unit time is fixed
, if an algorithm instruction is smaller than the number of instructions needed another algorithm needs, you can launch the algorithm a faster run time
premise: the speed and size of the data input algorithm there is a relationship between
the speed of a rough calculation algorithm:
the n-: data scale
F (n): the data size n, the number of basic instructions probably require
the introduction of a large O progressive notation:
1. keep only the highest-order term
highest order coefficient into 2 reserved. 1
F (n) = 2n + 10
is expressed as O (n)
the speed of the algorithm and also the best case, the mean, the best case
is generally the worst case priority, followed by the average, than the best case concerned Less

The time complexity is O (log (n-))
n-1000 1000 000 10 billion
o (n) 1000 1000 000 10 billion
o (log (n)) 10 20 30
common time complexity o (1) o (log ( n )) 0 (n) o ( n * log (n)) o (n ^ 2)

Space complexity:
maximum space case o (f (n)) in the case of n-scale input of the next, the algorithm needs
an 'open array
2. Draw call stack

Consider the relationship between the array capacity (be array.length) and the number of existing data (size) of
1. The capacity of sufficient size <be array.length
2. capacity is not enough
to move (1.5, 2 times)
int = newCapacity be array.length * 2;
1. find a new home;
int [] = newArray new new int [newCapacity]
2. moving
for (int I = 0; I <size; I ++) {
newArray [I] = Array [I];
}
3. hair circle of friends
= newArray this.array;
4. old house to return
the original array object, there is no reference point, into a garbage
spatial expansion of the smaller, less wasted space
larger spatial expansion, the smaller the desired frequency expansion
experience 1.5 or 2 times

Guess you like

Origin blog.51cto.com/14232658/2422821