Last updated:
0 purchases
linear search uzimizniki
Linear Search Package #
Overview #
The linear_search_uzimizniki package provides a utility for performing linear search operations on lists in Dart. This package includes a method to search for a target value within a list and returns the index of the target value along with the time taken to perform the search.
Features #
Perform linear search on a list
Return the index of the target value if found
Return -1 if the target value is not found
Measure and return the time taken for the search operation
Installation #
Add the following dependency to your pubspec.yaml file:
dependencies:
linear_search_uzimizniki: ^1.0.0
copied to clipboard
Usage #
import 'package:linear_search_uzimizniki/linear_search_uzimizniki.dart';
void main() {
// Define a list of integers to search within
List<int> list = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20];
// Specify the target value that you want to search for in the list
int targetValue = 10;
// Perform a linear search on the list to find the target value
// The search function returns a LinearSearchResult object
var result = LinearSearch.search(list, targetValue);
// Check if the target value was found in the list
if (result.index != -1) {
// If the target value is found, print its index
print('Value found at index: ${result.index}');
} else {
// If the target value is not found, print a message indicating this
print('Value not found.');
}
// Print the time taken to perform the search in milliseconds
print('Time taken: ${result.timeTaken.inMilliseconds} milliseconds');
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.