Is Blockchain trustworthy?

The short answer is not really. The concept of blockchain seems perfect from the outside however like every other technology it suffers from a few drawbacks and has a few disadvantages. Scholars…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Search Algorithms In Python

Searching is the technique of selecting specific data from a collection of data based on some condition. You are familiar with this concept if you have ever performed web searches to locate pages containing some words or phrases. Searching for data stored in different data structures is a very crucial part of application development. In this article, I will discuss two Search algorithms used in python:

1. Linear Search algorithm
2. Binary search algorithm

This is the simplest solution to a sequential search problem. I will demonstrate this algorithm using the code below. This code searches for an element in a list. Imagine we have a list of numbers `(List = [1, 2, 3, 9, 7, 4])` and we are to search for a specific number:

Steps to follow:

A. Best case
In the best case analysis, we must know the case that can cause the minimum number of operations to be executed.
In Linear search, the best-case occurs when the target value is present at the first index. The number of operations in the best case is constant hence making the time complexity to be `0(1)`.

B. Worst case
This is when the algorithm takes the maximum time.
In a linear search algorithm, the worst-case occurs when we are searching for an element present at the last index of the list. The time complexity of the worst case is n which can also be written as `0(n)`.

C. Average case
The average case time can be found by dividing all possible case times by the number of…

Add a comment

Related posts:

Tummy tuck or Liposuction? Better option in Kerala

There are a few key things to consider when trying to determine whether you need a tummy tuck or just liposuction. First, take a look at your overall body composition. Are you carrying a lot of extra…

Relationships

Relationships are very important aspects of our lives. As humans, we thrive on social interaction and a lack of it can cause our own suffering. There have been numerous studies that research what…

journey of Amal Academy

I was really excited and wait of saturday and sunday when have to go in AMAL for personal session, everyday learn new concept learn new thing and improve my self. before joining the Amal my uni…