https://github.com/jagadeeshm007/catalog-placements-assignment-online
https://github.com/jagadeeshm007/catalog-placements-assignment-online
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jagadeeshm007/catalog-placements-assignment-online
- Owner: jagadeeshm007
- Created: 2025-01-29T06:00:06.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-01-29T07:49:28.000Z (9 months ago)
- Last Synced: 2025-01-29T08:21:40.191Z (9 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Polynomial Constant Term Calculation
This is an assigniment by catalog company. the goal is to implements a simplified version of *Shamir's Secret Sharing* algorithm.
---
## Approach
1. *Decode Values:* Convert encoded values from their respective bases into **decimal integers**.
2. *Select Points:* Sort the roots by their **x-values** and select the *first k points*.
3. *Lagrange Interpolation:* Compute the **constant term 'c'** at *x = 0* using *Lagrange interpolation*, ensuring precision with **BigInt** for large numbers.
---
## Explanation
### Lagrange Interpolation
- The polynomial is evaluated at *x = 0* using *Lagrange interpolation*.
- Each selected point contributes to the **constant term 'c', and their sum** gives the final result.
- *BigInt* ensures precision, and the *Greatest Common Divisor (GCD)* is used to simplify fractions, avoiding overflow and ensuring accuracy.
---
## Results
| Test Case | Output |
|-----------|--------|
| *Test Case 1* | 3 |
| *Test Case 2* | 79836264049851 |
> *Note*: The results might not be correct or accurate, as the actual results are not disclosed.
---
## Technologies Used
- *JavaScript* (BigInt for precision)
- *Lagrange Interpolation*
- *Shamir’s Secret Sharing (Simplified)*