Skip to content

Add test case to the Exponential Search Algorithm #1040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
* [BinaryExponentiationRecursive](Maths/BinaryExponentiationRecursive.js)
* [BisectionMethod](Maths/BisectionMethod.js)
* [CheckKishnamurthyNumber](Maths/CheckKishnamurthyNumber.js)
* [CollatzSequence](Maths/CollatzSequence.js)
* [Coordinate](Maths/Coordinate.js)
* [CoPrimeCheck](Maths/CoPrimeCheck.js)
* [DecimalExpansion](Maths/DecimalExpansion.js)
Expand All @@ -159,13 +160,15 @@
* [FigurateNumber](Maths/FigurateNumber.js)
* [FindHcf](Maths/FindHcf.js)
* [FindLcm](Maths/FindLcm.js)
* [FindMaxRecursion](Maths/FindMaxRecursion.js)
* [FindMin](Maths/FindMin.js)
* [FindMinIterator](Maths/FindMinIterator.js)
* [GetEuclidGCD](Maths/GetEuclidGCD.js)
* [GridGet](Maths/GridGet.js)
* [IsDivisible](Maths/IsDivisible.js)
* [IsEven](Maths/IsEven.js)
* [IsOdd](Maths/IsOdd.js)
* [IsPronic](Maths/IsPronic.js)
* [LeapYear](Maths/LeapYear.js)
* [LinearSieve](Maths/LinearSieve.js)
* [LucasSeries](Maths/LucasSeries.js)
Expand Down Expand Up @@ -197,6 +200,7 @@
* [SquareRoot](Maths/SquareRoot.js)
* [SumOfDigits](Maths/SumOfDigits.js)
* [SumOfGeometricProgression](Maths/SumOfGeometricProgression.js)
* [TwinPrime](Maths/TwinPrime.js)
* [Volume](Maths/Volume.js)
* [WhileLoopFactorial](Maths/WhileLoopFactorial.js)
* [ZellersCongruenceAlgorithm](Maths/ZellersCongruenceAlgorithm.js)
Expand Down
15 changes: 15 additions & 0 deletions Search/test/ExponentialSearch.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { exponentialSearch } from '../ExponentialSearch'

test('The Exponential Search of the Array [2, 3, 4, 10, 40, 65, 78, 100] is 6 where the value = 78', () => {
const arr = [2, 3, 4, 10, 40, 65, 78, 100]
const value = 78
const result = exponentialSearch(arr, arr.length, value)
expect(result).toEqual(6)
})

test('The Exponential Search of the Array [2, 3, 4, 10, 40, 65, 78, 100] is -1 where the value = 178', () => {
const arr = [2, 3, 4, 10, 40, 65, 78, 100]
const value = 178
const result = exponentialSearch(arr, arr.length, value)
expect(result).toEqual(-1)
})