Euclid’s GCD Algorithm: Fundamentals: gcd(N, M) = gcd(M, N mod M) gcd(N, 0) = N Implementation in C: int Euclid_gcd_recursive(int a, int b) { if (b == 0) return a; return Euclid_gcd_recursive(b, a % b); } int Euclid_gcd_iterative(int a, int b) { int t; while (b) { a = b; b = t % b; [...]
Comparison Sort Selection Sort advantages: least data movement (N – 1 exchanges). disadvantages: does not make good use of the initial order of the keys, and one pass through the keys does not give any hint to the next pass. stability: stable. operations: N2/2 comparisons, N – 1 exchanges. space: in-space sort, O(N). implementation in [...]
© Wangling. Powered by WordPress using the DePo Skinny Theme.