Where can I learn algorithms for programming(java etc) because when ever I search for programs such as permutations,derangements,sortings etc I always find math algorithms.
Example: Counting Derangement
From this, the following relation is derived:
!n = (n - 1) (!(n-1) + !(n-2)).\,
where !n, known as the subfactorial, represents the number of derangements, with the starting values !0 = 1 and !1 = 0.
Notice that this same recurrence formula also works for factorials with different starting values. That is 0! = 1, 1! = 1 and
n! = (n - 1) ((n-1)! + (n-2)!)\,
which is helpful in proving the limit relationship with e below.
Also, the following formulae are known:[4]
!n = n! \sum_{i=0}^n \frac{(-1)^i}{i!},
!n = \left\lfloor\frac{n!}{e}+\frac{1}{2}\right\rfloor , \quad n\geq 1,
!n = \left[ \frac{n!}{e} \right] , \quad n\geq 1
Also another example I find is when I look up sorting in java I see O(n log n) or O(log n) terminology which I don't understand at all. I am not very good at math but at the same time I am very much interested in programming. Please help me in finding a book or a site to understand sorting algorithms required in programming languages