f(n) = O(g(n))
g(n)
is the asymptotic upper bound off(n)
.
f(n) = Θ(g(n))
g(n)
is the asymptotic tight bound off(n)
.
f(n) = Ω(g(n))
g(n)
is the asymptotic lower bound off(n)
.
O(1)
: ConstantO(log n)
: LogarithmicO(n)
: LinearO(n log n)
: LoglinearO(n^2)
: QuadraticO(n^c)
: PolynomialO(c^n)
: ExponentialO(n!)
: Factorial
2^(n + 1) - 1
: Sum of powers of two from 1 thoughn
.(n (n + 1)) / 2
: Sum of integers from 1 throughn
.(n (n - 1)) / 2
: No. of handshakes in a group.n - 1
: No. of matches in a knockout tournament.2^k
: No. of binary strings of lengthk
.n! / ((n - k)!)
: Permutations ofn
items takenk
at a time.n! / (k! (n - k)!)
: Combinations ofn
items takenk
at a time.
P(A and B) = P(B | A) P(A)
P(A or B) = P(A) + P(B) - P(A and B)
P(A and B) = P(A) P(B) // if A & B are independent
P(A or B) = P(A) + P(B) // if A & B are mutually exclusive
P(A | B) = (P(B | A) P(A)) / P(B)
GET
: Used to retrieve data, no other effect on the data.POST
: Used to send data to the server (e.g. form).PUT
: Replaces current representation of resource (idempotent).DELETE
: Removes current representation resource.
200 OK
: Success400 Bad Request
: Syntax could not be understood.401 Unauthorized
: Request not fulfilled due to lack of authorization.403 Forbidden
: Request understood but not fulfilled, authorization will not help.404 Not Found
: URI could not be matched.408 Request Timeout
: Server did not receive a timely response from client.500 Internal Server Error
: Server exception.503 Service Unavailable
: Server unable to handle the request (temporary).504 Gateway Timeout
: Server did not receive a timely response from an upstream server.
The brute force way to search for a substring of length b
in a larger string of length S
takes O(b (S - b))
time, since the first S - b + 1
characters are searched in the larger string and for each, the next b
characters are checked.
The Rabin-Karp algorithm takes advantage of the fact that two identical strings will have the same hash value. Note that two different strings may also have the same hash value.
Therefore, using this trick can reduce the search time (in the best case) to O(S)
since we just need to compute the hash value for every sequence of b
characters in the larger string and subsequently validate those substrings.