Linear Search in JavaScript

Consider the process of logging into a website. Entered email and password are searched against the existing key-value pairs in the database to validate the user. In this article, let us look at the most basic algorithm to search through a given list of elements - Linear Search.

Introduction

Searching, in the context of Computer Science, is the process of locating a particular element in the given list/array. If we pay close attention, we can find search algorithms everywhere.

Consider the process of logging into a website. Entered email and password are searched against the existing key-value pairs in the database to validate the user.

In this article, let us look at the most basic algorithm to search through a given list of elements - Linear Search.

The Linear Search algorithm is a set of instructions to traverse the given list and check every element in the list until we find whatever element we are looking for. The technical term for the element we are looking for is - key.

The algorithm goes from the leftmost (or starting) element and continues searching until it either finds the desired element or goes through all the elements in the list.

If the element is found, we will return the position (or `index`) of the element. If the element we are looking for doesn't exist in the list, we generally return `-1`.

Algorithms with JavaScript

A Day with JavaScript Algorithms.

The essential JavaScript concepts that you should understand

The essential JavaScript concepts that you should understand - For successful developing and to pass a work interview

quicksort Algorithmic in JavaScript

quicksort Algorithmic in JavaScript explain in js

Data Types In JavaScript

JavaScript data types are kept easy. While JavaScript data types are mostly similar to other programming languages; some of its data types can be unique. Here, we’ll outline the data types of JavaScript.

Binary Search Algorithm in Javascript

In this article, we will talk about binary search algorithm in Javascript. For today’s algorithm, I picked the binary search which is one of the most commonly asked topics in technical interviews. The problem named binary search from LeetCode will be used to explain this concept: