Bubble Sort

Bubble Sort Bubble Sort is a simple sorting algorithm which repeatedly compares and swaps adjacent elements in place. By swapping elements into the correct order, larger elements will be bubbled towards the end of the list. Effectively, the algorithm bubbles the current largest element to the end of the list in each phase of the algorithm. Although this algorithm is simple, it is not efficient for larger lists. Key Points Time Complexity: $O({n}^{2})$...

June 1, 2024 · 2 min · 380 words · Xavier Loera Flores

API Documentation

API Documentation Whether writing API documentation for a Web API or a Platform API, good API documentation will usually contain two key major components: Overview Reference Overview The overview section is best used to explain why or how an API should be used. This is section for providing developers with information allowing them to quickly read steps to getting started, key concepts, and other sample tutorials and use cases. The following sections may be found in an Overview section:...

May 31, 2024 · 1 min · 142 words · Xavier Loera Flores

Modular Exponentiation

You can use modular exponentiation to calculate the remainder of a number raised to a power. The trick to finding large exponentials is to break them down into smaller ones. Example: Given that $M^2 ≡ 51 (mod 59)$, what is $M^{12} (mod 59)$? M^12 = M^(4+8) M^12 = M^4 * M^8 M^12 = (M^2)^2 * (M^2)^3✅ M^2 ≡ 51 (mod 59) M^4 ≡ (M^2)^2 ≡ (51)^2 (mod 59) M^4 ≡ 2601 (mod 59) M^4 ≡ 5 (mod 59)✅ M^4 ≡ 5 (mod 59) M^8 ≡ (M^4)^2 ≡ (5)^2 (mod 59) M^8 ≡ 25 (mod 59)✅ M^12 = M^4 * M^8 M^12 ≡ [(5 mod 59) * (25 mod 59)] M^12 ≡ 5*25 (mod 59) M^12 ≡ 125 (mod 59) M^12 ≡ 7 (mod 59)✅

November 29, 2023 · 1 min · 124 words · Xavier Loera Flores

Multiplicative Inverse Mod

Multiplicative Inverse Modulo The multiplicative inverse of $x \mod y$ is a number $n ∈ Z+$ such that $xn\mod y=1$ Finding the Multiplicative Inverse Modulo: Given $x$ & $y$, to find the multiplicative inverse, $n$ of $x mod y$ you must find: $$xn \mod y = 1$$ $$or$$ $$xn ≡ 1 (mod\ y)$$ Substitute values of n to find congruence: x * A1 ≡ B1 !≡ 1 (mod 33) x * A2 ≡ B2 !...

November 29, 2023 · 1 min · 155 words · Xavier Loera Flores

Exponents Digits

Finding the ones digit of large exponents There is a trick to finding the ones place digit of a large exponentiated number. This trick involves finding the values of the small powers to find a pattern. Steps to finding the ones digit: Let A = n^x Find n^1, n^2, n^3, n^4,...,n^y Such that the values begin to repeat themselves in a pattern. Note: The ones digit of n^1 = the ones digit of n^y Use modulo arithmetic to find the remainder z z = x%y Ones digit of n^x = The ones digit n^z Example: Find Ones digit of 3^902 x = 902 3^1 = 3 | 3 3^2 = 9 | 9 3^3 = 27 | 7 3^4 = 81 | 1 Ones digit 3^4 = Ones digit 3^1 y = 4 z = 902 % 4 = 2 The ones digit of 3^902 = The ones digit 3^2 Ones digit = 9 Finding the first digits of large exponents There is a trick to finding the first few digits of a large exponentiated number....

November 28, 2023 · 2 min · 296 words · Xavier Loera Flores

Theory of Computation & Computational Models

When solving problems in computer science, it can help to abstract the problem to gain a better understanding of what we can possibly achieve. This can especially be seen when analyzing algorithms since we usually care more about how algorithms would perform on abstract computers (machines) rather than specific hardware. Computation any type of calculation that may include both arithmetical & non-arithmetical steps to provide a solution to a problem. Computational Models abstract models that allow us to reason about what can and can’t possibly be computed by a particular device....

November 27, 2023 · 3 min · 545 words · Xavier Loera Flores

Primality Testing

RSA Algorithm Rivest-Shamir-Aldeman Algorithm an asymmetric cryptography algorithm utilizes public and private generated from large prime numbers used to encrypt and decrypt data. The public key consists of two numbers where one number is a multiplication of two prime numbers. The private key is also derived from the same two prime numbers meaning if the public key primes are compromised, then so is the private key. Φ Φ(Phi) counts the number of numbers that are less than or equal to n and only share the factor of 1 with n Geeks for Geeks example: Geek For Geeks: RSA Algorithm Cryptography...

November 25, 2023 · 2 min · 406 words · Xavier Loera Flores