Skip to content

Jotho5/Search-Algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Search Algorithms - Binary and Linear

Introduction

This is a JavaScript program that allows users to search for a target element within an array using either linear or binary search algorithms. The program prompts the user to input an array of numbers and a target number to search for. If the user selects binary search, the program checks if the array is sorted before searching for the target element using the binary search algorithm. If the user selects linear search, the program searches for the target element using the linear search algorithm.

Dependencies

This program uses the readline-sync package to read user input from the command line. To install this package, run the following command: npm install readline-sync

Functionality

To use this program, the user will need to input an array of numbers and a target number to search for. The program will then prompt the user to select either the binary or linear search algorithm. If the user selects binary search, the program will check if the array is sorted before searching for the target element using the binary search algorithm. If the user selects linear search, the program will search for the target element using the linear search algorithm.

The program will keep track of the number of iterations each search algorithm goes through to find the target element. If the target element is not found, the program will return an error message.

Thank you for using this search algorithms program!

About

This is a JavaScript program that allows users to search for a target element within an array using either linear or binary search algorithms

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published