{"id":28224199,"url":"https://github.com/danishayman/simple-multiplication-algorithm","last_synced_at":"2025-06-12T03:30:38.439Z","repository":{"id":272186390,"uuid":"787477791","full_name":"danishayman/Simple-Multiplication-Algorithm","owner":"danishayman","description":"The Karatsuba algorithm is a fast multiplication algorithm that reduces the number of multiplication operations required to multiply two numbers by recursively breaking down the multiplication into smaller multiplications.","archived":false,"fork":false,"pushed_at":"2025-04-08T14:22:17.000Z","size":311,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-18T09:11:31.637Z","etag":null,"topics":["java","karatsuba","karatsuba-algorithm","karatsuba-multiplication","multiplication","multiplication-algorithm"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danishayman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-16T15:43:18.000Z","updated_at":"2025-04-08T14:22:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"de7d1612-bc8c-488b-8915-d21ea6c10e6c","html_url":"https://github.com/danishayman/Simple-Multiplication-Algorithm","commit_stats":null,"previous_names":["danishayman/simple-multiplication-algorithm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danishayman/Simple-Multiplication-Algorithm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danishayman%2FSimple-Multiplication-Algorithm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danishayman%2FSimple-Multiplication-Algorithm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danishayman%2FSimple-Multiplication-Algorithm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danishayman%2FSimple-Multiplication-Algorithm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danishayman","download_url":"https://codeload.github.com/danishayman/Simple-Multiplication-Algorithm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danishayman%2FSimple-Multiplication-Algorithm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259389536,"owners_count":22850025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","karatsuba","karatsuba-algorithm","karatsuba-multiplication","multiplication","multiplication-algorithm"],"created_at":"2025-05-18T09:11:10.938Z","updated_at":"2025-06-12T03:30:38.430Z","avatar_url":"https://github.com/danishayman.png","language":"Java","readme":"# 🧮 Simple Multiplication Algorithm vs Karatsuba Algorithm\n\n## 📋 Table of Contents\n- [Overview](#-overview)\n- [Prerequisites](#-prerequisites)\n- [Performance Analysis](#-performance-analysis)\n- [Implementation Details](#-implementation-details)\n- [Usage](#-usage)\n- [Testing](#-testing)\n- [Visual Comparison](#-visual-comparison)\n\n## 🌟 Overview\nThis project implements and compares two multiplication algorithms:\n1. Simple Multiplication Algorithm - A traditional approach with O(n²) complexity\n2. Karatsuba Algorithm - A faster divide-and-conquer approach\n\n## 🔧 Prerequisites\n- Java Development Kit (JDK) 8 or higher\n- Basic understanding of algorithm complexity\n- Familiarity with Java programming\n\n## 📊 Performance Analysis\n\n### 🔢 Simple Multiplication Algorithm\nThe simple multiplication algorithm is implemented with the following steps and their time complexities:\n\n1. **Generating Random Numbers** 🎲\n   - Time Complexity: O(n)\n   - Generates random numbers with n digits\n   - Constant time operation for each digit\n\n2. **Storing Digits in Arrays** 📦\n   - Time Complexity: O(n)\n   - Iterates once over n digits\n   - Stores each digit in separate arrays\n\n3. **Performing Multiplication** ✖️\n   - Time Complexity: O(n²)\n   - Nested loops for digit-by-digit multiplication\n   - Most significant part of the algorithm\n\n4. **Handling Carries and Partial Products** ➕\n   - Time Complexity: O(n²)\n   - Manages carries and accumulates partial products\n   - Nested within multiplication loops\n\n5. **Result Output** 📝\n   - Time Complexity: O(n)\n   - Linear iteration over result digits\n   - Formats and displays the final product\n\n**Overall Time Complexity**: O(n²) ⏱️\n\n### 🚀 Karatsuba Algorithm\nA faster multiplication algorithm that reduces the number of multiplication operations through recursive decomposition.\n\n#### 🔍 How It Works:\n1. **Base Case** ⚡\n   - If n = 1, uses simple multiplication\n   - Direct multiplication for single-digit numbers\n\n2. **Recursive Decomposition** 🔄\n   - Splits numbers into halves (a, b) and (c, d)\n   - Performs three recursive multiplications:\n     - ac\n     - bd\n     - (a+b)(c+d)\n\n3. **Final Computation** 🎯\n   - Combines results using the formula:\n   - ac * 10ⁿ + ((a+b)(c+d) - ac - bd) * 10ⁿ/² + bd\n\n#### 📈 Performance Benefits\n- Reduces multiplication operations\n- More efficient for large numbers\n- Recursive approach with three subproblems\n\n## 🛠️ Implementation Details\n- Both algorithms are implemented in Java\n- Includes performance counters for operation tracking\n- Supports random number generation for testing\n- Validates results through assertions\n\n### 📁 Project Structure\n```\n.\n├── SimpleMultiplication.java    # Simple multiplication implementation\n├── Karatsuba.java              # Karatsuba algorithm implementation\n├── Graph of Karatsuba Algorithm.xlsx    # Performance graphs\n└── Graph for Simple Multiplication.xlsx # Performance graphs\n```\n\n## 💻 Usage\n1. **Compile the Java files**:\n   ```bash\n   javac SimpleMultiplication.java\n   javac Karatsuba.java\n   ```\n\n2. **Run the algorithms**:\n   ```bash\n   java SimpleMultiplication\n   java Karatsuba\n   ```\n\n3. **Configure parameters**:\n   - Modify `numberOfDigits` in both files to change input size\n   - Adjust `MAX_VALUE` to change number of test iterations\n\n## 📊 Performance Comparison\n| Algorithm | Time Complexity | Best For | Space Complexity |\n|-----------|----------------|----------|------------------|\n| Simple    | O(n²)          | Small numbers | O(n) |\n| Karatsuba | O(n^1.585)     | Large numbers | O(n) |\n\n## 🔍 Testing\n- Both algorithms are tested with random numbers\n- Results are compared with expected values\n- Includes assertion checks for accuracy\n- Supports configurable number of digits and test iterations\n\n## 📈 Visual Comparison\nThe project includes Excel files with performance graphs:\n- `Graph of Karatsuba Algorithm.xlsx`\n- `Graph for Simple Multiplication.xlsx`\n\nThese graphs visualize:\n- Operation count vs. input size\n- Time complexity comparison\n- Performance differences between algorithms\n\n## 🤝 Contributing\nFeel free to:\n- Report issues\n- Suggest improvements\n- Submit pull requests\n\n## 📝 License\nThis project is open source and available for educational purposes.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanishayman%2Fsimple-multiplication-algorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanishayman%2Fsimple-multiplication-algorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanishayman%2Fsimple-multiplication-algorithm/lists"}