- First, we will generate a random array using Math.random() function.
- Different color is used to indicate which element is being traversed at current time.
- Since the algorithm performs the operation very fast, the setTimeout() function has been used to slow down the process.
- New array can be generated by pressing the “Ctrl+R” key.
- The searching is performed using LinearSearch() function.
Below is the program to visualize the Linear Search algorithm.