KarateChopDomain 1.0.0
dotnet add package KarateChopDomain --version 1.0.0
NuGet\Install-Package KarateChopDomain -Version 1.0.0
<PackageReference Include="KarateChopDomain" Version="1.0.0" />
paket add KarateChopDomain --version 1.0.0
#r "nuget: KarateChopDomain, 1.0.0"
// Install KarateChopDomain as a Cake Addin #addin nuget:?package=KarateChopDomain&version=1.0.0 // Install KarateChopDomain as a Cake Tool #tool nuget:?package=KarateChopDomain&version=1.0.0
KarateChop Library
The KarateChop library provides an efficient binary search implementation for searching sorted arrays of integers.
Installation
You can install the KarateChop library via NuGet Package Manager with the following command:
Install-Package KarateChopDomain
Usage
To use the KarateChop
class in your project, follow these steps:
- Ensure you have installed the KarateChop library via NuGet.
- Include the
KarateChopDomain
namespace in your file. - Use the
Chop
method to perform a binary search on a sorted array of integers.
Example
using System;
using KarateChopDomain;
namespace KarateChopExample
{
class Program
{
static void Main(string[] args)
{
int[] sortedArray = { 1, 3, 5, 7, 9 };
int target = 5;
int result = KarateChop.Chop(target, sortedArray);
if (result != -1)
{
Console.WriteLine($"Target found at index {result}.");
}
else
{
Console.WriteLine("Target not found in the array.");
}
}
}
}
Method Details
Chop(int target, int[] array)
Parameters:
target
: The integer value to search for in the array.array
: A sorted array of integers to search within.
Returns:
- The integer index of the target value in the array, or -1 if the target is not found.
Example Scenarios
Target Present in the Array:
- For
target = 5
andarray = { 1, 3, 5, 7, 9 }
, the method returns2
(index of the target).
- For
Target Not Present in the Array:
- For
target = 6
andarray = { 1, 3, 5, 7, 9 }
, the method returns-1
(target not found).
- For
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 87 | 7/11/2024 |