If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

To log in and use all the features of Khan Academy, please enable JavaScript in your browser.

Computer science theory

Course: computer science theory   >   unit 1, binary search.

  • Implementing binary search of an array
  • Challenge: Binary search
  • Running time of binary search

research on binary search algorithms

Describing binary search

  • Let m i n = 1 ‍   and m a x = n ‍   .
  • Guess the average of  m a x ‍    and m i n ‍   , rounded down so that it is an integer.
  • If you guessed the number, stop. You found it!
  • If the guess was too low, set m i n ‍   to be one larger than the guess.
  • If the guess was too high, set m a x ‍   to be one smaller than the guess.
  • Go back to step two.

Want to join the conversation?

  • Upvote Button navigates to signup page
  • Downvote Button navigates to signup page
  • Flag Button navigates to signup page

Incredible Answer

research on binary search algorithms

Extra, Extra - Read All About It: Nearly All Binary Searches and Mergesorts are Broken

June 2, 2006

Posted by Joshua Bloch, Software Engineer

  • Programming Pearls - Highly recommended. Get a copy today!
  • The Sun bug report describing this bug in the JDK
  • A 2003 paper by Salvatore Ruggieri discussing a related problem - The problem is a bit more general but perhaps less interesting: the average of two numbers of arbitrary sign. The paper does not discuss performance, and its solution is not fast enough for use in the inner loop of a mergesort.

Understanding Binary Search: Data Structure and Algorithm

Understanding Binary Search: Data Structure and Algorithm

Binary search is a searching algorithm that finds the position of a target value within a sorted array. It works by repeatedly dividing the search interval in half. If the value of the search key is less than the item in the middle of the interval, the algorithm continues the search on the lower half.

Continue to delete post?

Algogenz logo

4m · 5 min read

Binary search is a fundamental algorithm in computer science that operates on sorted arrays or lists. It is a divide-and-conquer strategy that significantly reduces the time complexity compared to linear search methods, making it highly efficient for large datasets.

What Is Binary Search?

Binary search is a searching algorithm that finds the position of a target value within a sorted array.

It works by repeatedly dividing the search interval in half. If the value of the search key is less than the item in the middle of the interval, the algorithm continues the search on the lower half. Otherwise, it continues on the upper half. This process continues until the value is found or the interval is empty.

Scenario to Understand Binary Search

To grasp binary search, let's consider a simple analogy. Imagine flipping through a phone book to find a specific company's phone number. The pages are organized alphabetically, and instead of starting from the first page and reading each entry until you find the one you need, you could use a more intelligent strategy:

  • Open the middle of the phone book.
  • If the company you're looking for is listed after the middle page, discard the lower half of the book.
  • If it's listed before, discard the upper half.
  • Repeat steps 1-3 on the remaining half of the book.

This process is similar to binary search, where you continually halve the search space until you find the target or determine that it's not present.

How Does Binary Search Work?

Here's a step-by-step breakdown of how binary search works:

  • Define the Search Interval: Start with the entire array or list as the search interval.
  • Calculate the Midpoint: Divide the search interval into two halves by finding the midpoint.
  • Compare the Middle Element: Check if the target value matches the middle element of the current search interval.
  • Narrow Down the Search Space:
  • If the target matches the middle element, the search is complete, and the index of the value is returned.
  • If the target is less than the middle element, continue the search on the left half of the current interval.
  • If the target is greater than the middle element, continue the search on the right half of the current interval.
  • Iterate Until Found or Exhausted: Repeat steps 2–4 until the target value is found or the search interval is empty.

Implementing Binary Search

The implementation of binary search varies slightly depending on the programming language being used. Some languages provide built-in functions for binary search, which can simplify the task considerably. For example, Python has the bisect module that offers functions like  bisect_left ,  bisect_right, and bisect for searching and inserting elements into sorted lists.

The Binary Search Algorithm can be implemented in two ways

  • Iterative Binary Search Algorithm
  • Recursive Binary Search Algorithm

Iterative Approach

An iterative implementation of binary search uses a while loop to keep reducing the search space.

Here's how it looks in pseudocode:

Here is the breakdown for this function:.

  • arr  is the sorted array to search.
  • item  is the target value to find.
  • low  and  high  are the start and end indices of the search interval.
  • midIndex  is the index of the middle element of the current search interval.
  • The loop continues until  low  is greater than  high , which means the search interval is empty.
  • If the target  item  is found at index  midIndex , the index is returned.
  • If  item  is greater than the middle element, the search continues on the right half of the array ( low = midIndex + 1 ).
  • If  item  is less than the middle element, the search continues on the left half of the array ( high = midIndex - 1 ).
  • If the item is not found, the function returns -1.

Recursive Approach

A recursive version of binary search breaks down the problem into smaller subproblems by calling itself with a reduced interval. Here's the recursive pseudocode:

Here is the breakdown:

  • The base case for the recursion is when  low  is greater than  high , which means the search interval is empty and the function returns -1.
  • If  item  is less than the middle element, the function calls itself with the left half of the array ( low  to  midIndex - 1 ).
  • If  item  is greater than the middle element, the function calls itself with the right half of the array ( midIndex + 1  to  high ).

When to Use Binary Search

Binary search should be used when the data is sorted, as it relies on repeatedly dividing the search space in half. It's essential for applications like database indexing, file system searches, and many other areas where speed is crucial.

Advantages of Binary Search

  • Efficiency : Binary search has a logarithmic time complexity, which makes it very efficient even for large datasets.
  • Optimization : It reduces the search space by half in each iteration, leading to fewer comparisons overall. 
  • Usability : It is applicable to any sorted dataset, whether stored in arrays, linked lists, or other data structures.

Time Complexity and Efficiency

  • One of the main advantages of binary search over linear search (which scans through the entire list) is its efficiency. Binary search has a time complexity of  O(log n) , where n is the number of elements in the list. This makes it significantly faster for large datasets, especially when compared to linear search, which has a time complexity of O(n)

Practical Applications

Binary search is widely used in practical applications such as:

  • Database Systems : To quickly locate records.
  • File Systems : For finding files in directories.
  • Compiler Design : In lexical analysis to match keywords.
  • Digital Electronics: In digital search machines.

Binary Search Trees

While binary search is typically applied to simple arrays, it forms the basis of binary search trees (BSTs), which are a type of self-balancing tree data structure. BSTs are used extensively in computer science, particularly in database management systems. They maintain an ordered collection of items, allowing for fast lookup, addition, and removal operations

Binary search is a powerful algorithm that stands as a cornerstone in the field of data structures and algorithms. Its ability to efficiently locate elements within a sorted list makes it indispensable in various applications where quick retrieval is critical. As a developer, understanding binary search and knowing how to implement it effectively can significantly enhance the performance of your software.

  • Programming Languages
  • Web Development
  • Data Structures

Get the best experience on this app by signing in.

Continue with Google

Learn Python practically and Get Certified .

Popular Tutorials

Popular examples, reference materials, learn python interactively, dsa introduction.

  • What is an algorithm?
  • Data Structure and Types
  • Why learn DSA?
  • Asymptotic Notations
  • Master Theorem
  • Divide and Conquer Algorithm

Data Structures (I)

  • Types of Queue
  • Circular Queue
  • Priority Queue

Data Structures (II)

  • Linked List
  • Linked List Operations
  • Types of Linked List
  • Heap Data Structure
  • Fibonacci Heap
  • Decrease Key and Delete Node Operations on a Fibonacci Heap

Tree based DSA (I)

  • Tree Data Structure
  • Tree Traversal
  • Binary Tree
  • Full Binary Tree
  • Perfect Binary Tree
  • Complete Binary Tree
  • Balanced Binary Tree
  • Binary Search Tree

Tree based DSA (II)

  • Insertion in a B-tree
  • Deletion from a B-tree
  • Insertion on a B+ Tree
  • Deletion from a B+ Tree
  • Red-Black Tree
  • Red-Black Tree Insertion
  • Red-Black Tree Deletion

Graph based DSA

  • Graph Data Structure
  • Spanning Tree
  • Strongly Connected Components
  • Adjacency Matrix
  • Adjacency List
  • DFS Algorithm
  • Breadth-first Search
  • Bellman Ford's Algorithm

Sorting and Searching Algorithms

  • Bubble Sort
  • Selection Sort
  • Insertion Sort
  • Counting Sort
  • Bucket Sort

Linear Search

Binary Search

Greedy algorithms.

  • Greedy Algorithm
  • Ford-Fulkerson Algorithm
  • Dijkstra's Algorithm
  • Kruskal's Algorithm
  • Prim's Algorithm
  • Huffman Coding
  • Dynamic Programming
  • Floyd-Warshall Algorithm
  • Longest Common Sequence

Other Algorithms

  • Backtracking Algorithm
  • Rabin-Karp Algorithm

DSA Tutorials

Quicksort Algorithm

Binary Search Tree(BST)

Insertion Sort Algorithm

  • Counting Sort Algorithm

Binary Search is a searching algorithm for finding an element's position in a sorted array.

In this approach, the element is always searched in the middle of a portion of an array.

Binary search can be implemented only on a sorted list of items. If the elements are not sorted already, we need to sort them first.

  • Binary Search Working

Binary Search Algorithm can be implemented in two ways which are discussed below.

  • Iterative Method

Recursive Method

The recursive method follows the divide and conquer approach.

The general steps for both methods are discussed below.

initial array Binary Search

  • If x == mid, then return mid.Else, compare the element to be searched with m.
  • If x > mid , compare x with the middle element of the elements on the right side of mid . This is done by setting low to low = mid + 1 .

finding mid element Binary Search

  • Binary Search Algorithm

Iteration Method

  • Python, Java, C/C++ Examples (Iterative Method)
  • Python, Java, C/C++ Examples (Recursive Method)
  • Binary Search Complexity

Time Complexities

  • Best case complexity : O(1)
  • Average case complexity : O(log n)
  • Worst case complexity : O(log n)

Space Complexity

The space complexity of the binary search is O(1) .

  • Binary Search Applications
  • In libraries of Java, .Net, C++ STL
  • While debugging, the binary search is used to pinpoint the place where the error happens.

Table of Contents

Sorry about that.

Related Tutorials

DS & Algorithms

binary search algorithm Recently Published Documents

Total documents.

  • Latest Documents
  • Most Cited Documents
  • Contributed Authors
  • Related Sources
  • Related Keywords

A Low-Jitter Harmonic-Free All-Digital Delay-Locked Loop for Multi-Channel Vernier TDC

This paper presents a low jitter All-Digital Delay-Locked Loop (ADDLL) with fast lock time and process immunity. A coarse locking algorithm is proposed to prevent harmonic locking with just a small increase in hardware resources. In order to effectively solve the dithering phenomenon after locking, a replica delay line and a modified binary search algorithm with two modes were introduced in our ADDLL, which can significantly reduce the peak-to-peak jitter of the replica delay line. In addition, digital codes for a replica delay line can be conveniently applied to the delay line of multi-channel Vernier TDC while maintaining consistency between channels. The proposed ADDLL has been designed in 55 nm CMOS technology. In addition, the post-layout simulation results show that when operated at 1.2 V, the proposed ADDLL locks within 37 cycles and has a closed-loop characteristic, the peak-to-peak and root-mean-square jitter at 800 MHz are 6.5 ps and 1.18 ps, respectively. The active area is 0.024 mm2 and the power consumption at 800 MHz is 6.92 mW. In order to verify the performance of the proposed ADDLL, an architecture of dual ADDLL is applied to Vernier TDC to stabilize the Vernier delay lines against the process, voltage, and temperature (PVT) variations. With a 600 MHz operating frequency, the TDC achieves a 10.7 ps resolution, and the proposed ADDLL can keep the resolution stable even if PVT varies.

Inverse design of multifunctional metamaterial based on modified direct binary search algorithm

Runtime compensation coefficient estimation techniques using binary search algorithm for low-power active noise cancelling systems, aplikasi belajar tajwid menggunakan binary search.

ABSTRAK Tajwid dapat diartikan sebagai aturan atau tata cara untuk membaca Al-Quran dengan benar. seorang muslim biasanya mulai belajar tajwid sejak usianya masih dini, namun dewasa ini motivasi untuk mempelajarinya makin turun. Salah satu penyebabnya adalah cara pembelajaran yang konvensional dan kurang begitu memanfaatkan teknologi. Oleh karena itu, penelitian ini bertujuan untuk membangun aplikasi pembelajaran tajwid berbasis website dan menerapkan algoritma binary search untuk memperoleh hasil yang lebih optimal. Pencarian biner atau binary search adalah suatu algoritma yang bekerja dengan mencari posisi elemen dalam array yang telah diurutkan sebelumnya dan kemudian membandingkan nilainya. Ruang pencarian dibagi menjadi dua, kemudian nilai yang dicari dibandingkan dengan elemen tengah array. Operasi ini diulang terus sampai ada kecocokan diantara dua nilai tersebut. Aplikasi pembelajaran tajwid yang dibuat terdiri dari tiga menu yaitu materi, latihan, dan info. Menu materi berisi mata kuliah yang berkaitan dengan hukum membaca Al-Quran. Menu latihan memungkinkan pengguna untuk melatih pemahaman yang telah mereka pelajari di menu teori, sedangkan menu info berisi instruksi manual penggunaan aplikasi. ABSTRACT Tajweed is set of rules for reciting Al-Quran properly. Muslim start learning tajweed from their early age, but currently motivation to learn tajweed is decreasing. One of the reason is the conventional learning and less use digital technology. Therefore, the aim of this study is to construct tajweed learning application based on website and applied binary search algorithm for better result. Binary search is a search algorithm that works by finding the position of elements in a sorted array and comparing their values. The search space is divided into half, then compared the value searched with the middle element of the Array.  This operation is repeated until they match. Tajweed learning application consist of three menus: theory, exercise, and info. Theory menu contains courses related to the law of reciting Al-Quran. Exercise menu allows user to train the understanding they has learned in theory menu, while info menu contains user instruction manual.

COMPARISON OF SOFTWARE COMPLEXITY OF SEARCH ALGORITHM USING CODE BASED COMPLEXITY METRICS

Measures of software complexity are essential part of software engineering. Complexity metrics can be used to forecast key information regarding the testability, reliability, and manageability of software systems from study of the source code. This paper presents the results of three distinct software complexity metrics that were applied to two searching algorithms (Linear and Binary search algorithm). The goal is to compare the complexity of linear and binary search algorithms implemented in (Python, Java, and C++ languages) and measure the sample algorithms using line of code, McCabe and Halstead metrics. The findings indicate that the program difficulty of Halstead metrics has minimal value for both linear and binary search when implemented in python. Analysis of Variance (ANOVA) was adopted to determine whether there is any statistically significant differences between the search algorithms when implemented in the three programming languages and it was revealed that the three (3) programming languages do not vary considerably for both linear and binary search techniques which implies that any of the (3) programming languages is suitable for coding linear and binary search algorithms.

A binary search algorithm for univariate data approximation and estimation of extrema by piecewise monotonic constraints

Error estimation for the methods of correlated colour temperature calculation.

To date, a lot of methods have been developed for calculating correlated colour temperature (CCT). There are both numerical solutions (Robertson’s method, Yoshi Ohno method, binary search algorithm) and analytical (Javier Hernandez-Andres’s method, McCamy’s method). At the same time, the information about their accuracy is of a segmental fragmentary nature, therefore, it is very difficult to develop recommendations for the application of methods for certain radiators. In this connection, it seems extremely interesting to compare the error of the most well-known CCT calculating methods, using a single universal approach. The paper proposes an algorithm for researching the error of the methods for calculating correlated colour temperature, based on the method for plotting lines of constant CCT of a given length. Temperatures corresponding to these lines are taken as true, and the chromaticity lying on them are used as input data for the researched method. The paper proposes an approach when first the distribution of the error in the entire range of determination of CCT is determined, followed by bilinear interpolation for the required chromaticity. Using this approach, the absolute errors of the following methods for calculating CCT: McCamy, Javier Hernandez, Robertson, and Yoshi Ohno were estimated. The error was estimated in the range occupied by quadrangles of possible values from ANSI C78.377 chromaticity standard, developed by American National Standards Institute for LED lamps for indoor lightning. The tabular and graphical distribution of the absolute error for each investigated method was presented in the range of (2000–7000) K. In addition, to clarify the applicability of the methods for calculating CCT of the sky, the calculation of the distribution of the relative error up to 100000 K was performed. The results of the study can be useful for developers of standards and measurement procedures and for software developers of measuring equipment.

Pencarian Data Barang Produk Atribut Sekolah Menggunakan Algoritma Binary Search

ABSTRACTTechnology and information that is growing and sophisticated must be balanced according to the needs. For it was made the application of binary algorithms for the search data goods production of school attributes. Many methods in search with the goal of making it easier to search, e.g. search data of production items of school attributes with binary search method. Convection in the search of production goods using the manual way by looking for the archive data written in the notebook, the purpose of this research is to create a data retrieval system of goods that will be applied as a data retrieval tool of goods, as well as change the system manual to the computing system. In this research using Binary Search algorithm. Binary search algorithm is a technique applied only on the sorted element (sorted). This research using method of binary search algorithm with analysis stage, system design, coding/construction, testing, and implementation. In the analysis stage, the collection of data conducted is observation and literature study. At the system design stage using Unified Modelling Language (UML) include the use case diagram, activity diagram, Sequence diagram, and Diagram class. At the construction stage using the Java programming language using Netbeans and MySQL Server tools while the implementation of this system is the application of data retrieval of goods. To know the eligibility of a system, it is necessary to test against the search time of 210 data each time duration, 0.0004 seconds, 0.0005 seconds, 0.0006 seconds, 0.0007 seconds, 0.0008 seconds, 0.0009 seconds, 0.0010 seconds, 0.0012 seconds, 0.0014 seconds, 0.00117 seconds. The final result of this study is the application of search for production goods with Binary Search Algorithm Method.

Bayesian direct-binary-search algorithm for the efficient design of mosaic-based power splitters

A binary search algorithm based optimal sizing of photovoltaic and energy storage systems, export citation format, share document.

research on binary search algorithms

  • Continuous search
  • Search with powers of 2
  • Practice Problems
  • Ternary Search
  • Newton's method for finding roots

Binary search ¶

Binary search is a method that allows for quicker search of something by splitting the search interval into two. Its most common application is searching values in sorted arrays, however the splitting idea is crucial in many other typical tasks.

Search in sorted arrays ¶

The most typical problem that leads to the binary search is as follows. You're given a sorted array $A_0 \leq A_1 \leq \dots \leq A_{n-1}$ , check if $k$ is present within the sequence. The simplest solution would be to check every element one by one and compare it with $k$ (a so-called linear search). This approach works in $O(n)$ , but doesn't utilize the fact that the array is sorted.

Now assume that we know two indices $L < R$ such that $A_L \leq k \leq A_R$ . Because the array is sorted, we can deduce that $k$ either occurs among $A_L, A_{L+1}, \dots, A_R$ or doesn't occur in the array at all. If we pick an arbitrary index $M$ such that $L < M < R$ and check whether $k$ is less or greater than $A_M$ . We have two possible cases:

  • $A_L \leq k \leq A_M$ . In this case, we reduce the problem from $[L, R]$ to $[L, M]$ ;
  • $A_M \leq k \leq A_R$ . In this case, we reduce the problem from $[L, R]$ to $[M, R]$ .

When it is impossible to pick $M$ , that is, when $R = L + 1$ , we directly compare $k$ with $A_L$ and $A_R$ . Otherwise we would want to pick $M$ in such manner that it reduces the active segment to a single element as quickly as possible in the worst case .

Since in the worst case we will always reduce to larger segment of $[L, M]$ and $[M, R]$ . Thus, in the worst case scenario the reduction would be from $R-L$ to $\max(M-L, R-M)$ . To minimize this value, we should pick $M \approx \frac{L+R}{2}$ , then

In other words, from the worst-case scenario perspective it is optimal to always pick $M$ in the middle of $[L, R]$ and split it in half. Thus, the active segment halves on each step until it becomes of size $1$ . So, if the process needs $h$ steps, in the end it reduces the difference between $R$ and $L$ from $R-L$ to $\frac{R-L}{2^h} \approx 1$ , giving us the equation $2^h \approx R-L$ .

Taking $\log_2$ on both sides, we get $h \approx \log_2(R-L) \in O(\log n)$ .

Logarithmic number of steps is drastically better than that of linear search. For example, for $n \approx 2^{20} \approx 10^6$ you'd need to make approximately a million operations for linear search, but only around $20$ operations with the binary search.

Lower bound and upper bound ¶

It is often convenient to find the position of the first element that is not less than $k$ (called the lower bound of $k$ in the array) or the position of the first element that is greater than $k$ (called the upper bound of $k$ ) rather than the exact position of the element.

Together, lower and upper bounds produce a possibly empty half-interval of the array elements that are equal to $k$ . To check whether $k$ is present in the array it's enough to find its lower bound and check if the corresponding element equates to $k$ .

Implementation ¶

The explanation above provides a rough description of the algorithm. For the implementation details, we'd need to be more precise.

We will maintain a pair $L < R$ such that $A_L \leq k < A_R$ . Meaning that the active search interval is $[L, R)$ . We use half-interval here instead of a segment $[L, R]$ as it turns out to require less corner case work.

When $R = L+1$ , we can deduce from definitions above that $R$ is the upper bound of $k$ . It is convenient to initialize $R$ with past-the-end index, that is $R=n$ and $L$ with before-the-beginning index, that is $L=-1$ . It is fine as long as we never evaluate $A_L$ and $A_R$ in our algorithm directly, formally treating it as $A_L = -\infty$ and $A_R = +\infty$ .

Finally, to be specific about the value of $M$ we pick, we will stick with $M = \lfloor \frac{L+R}{2} \rfloor$ .

Then the implementation could look like this:

During the execution of the algorithm, we never evaluate neither $A_L$ nor $A_R$ , as $L < M < R$ . In the end, $L$ will be the index of the last element that is not greater than $k$ (or $-1$ if there is no such element) and $R$ will be the index of the first element larger than $k$ (or $n$ if there is no such element).

Note. Calculating m as m = (r + l) / 2 can lead to overflow if l and r are two positive integers, and this error lived about 9 years in JDK as described in the blogpost . Some alternative approaches include e.g. writing m = l + (r - l) / 2 which always works for positive integer l and r , but might still overflow if l is a negative number. If you use C++20, it offers an alternative solution in the form of m = std::midpoint(l, r) which always works correctly.

Search on arbitrary predicate ¶

Let $f : \{0,1,\dots, n-1\} \to \{0, 1\}$ be a boolean function defined on $0,1,\dots,n-1$ such that it is monotonously increasing, that is

The binary search, the way it is described above, finds the partition of the array by the predicate $f(M)$ , holding the boolean value of $k < A_M$ expression. It is possible to use arbitrary monotonous predicate instead of $k < A_M$ . It is particularly useful when the computation of $f(k)$ is requires too much time to actually compute it for every possible value. In other words, binary search finds the unique index $L$ such that $f(L) = 0$ and $f(R)=f(L+1)=1$ if such a transition point exists, or gives us $L = n-1$ if $f(0) = \dots = f(n-1) = 0$ or $L = -1$ if $f(0) = \dots = f(n-1) = 1$ .

Proof of correctness supposing a transition point exists, that is $f(0)=0$ and $f(n-1)=1$ : The implementation maintaints the loop invariant $f(l)=0, f(r)=1$ . When $r - l > 1$ , the choice of $m$ means $r-l$ will always decrease. The loop terminates when $r - l = 1$ , giving us our desired transition point.

Binary search on the answer ¶

Such situation often occurs when we're asked to compute some value, but we're only capable of checking whether this value is at least $i$ . For example, you're given an array $a_1,\dots,a_n$ and you're asked to find the maximum floored average sum

among all possible pairs of $l,r$ such that $r-l \geq x$ . One of simple ways to solve this problem is to check whether the answer is at least $\lambda$ , that is if there is a pair $l, r$ such that the following is true:

Equivalently, it rewrites as

so now we need to check whether there is a subarray of a new array $a_i - \lambda$ of length at least $x+1$ with non-negative sum, which is doable with some prefix sums.

Continuous search ¶

Let $f : \mathbb R \to \mathbb R$ be a real-valued function that is continuous on a segment $[L, R]$ .

Without loss of generality assume that $f(L) \leq f(R)$ . From intermediate value theorem it follows that for any $y \in [f(L), f(R)]$ there is $x \in [L, R]$ such that $f(x) = y$ . Note that, unlike previous paragraphs, the function is not required to be monotonous.

The value $x$ could be approximated up to $\pm\delta$ in $O\left(\log \frac{R-L}{\delta}\right)$ time for any specific value of $\delta$ . The idea is essentially the same, if we take $M \in (L, R)$ then we would be able to reduce the search interval to either $[L, M]$ or $[M, R]$ depending on whether $f(M)$ is larger than $y$ . One common example here would be finding roots of odd-degree polynomials.

For example, let $f(x)=x^3 + ax^2 + bx + c$ . Then $f(L) \to -\infty$ and $f(R) \to +\infty$ with $L \to -\infty$ and $R \to +\infty$ . Which means that it is always possible to find sufficiently small $L$ and sufficiently large $R$ such that $f(L) < 0$ and $f(R) > 0$ . Then, it is possible to find with binary search arbitrarily small interval containing $x$ such that $f(x)=0$ .

Search with powers of 2 ¶

Another noteworthy way to do binary search is, instead of maintaining an active segment, to maintain the current pointer $i$ and the current power $k$ . The pointer starts at $i=L$ and then on each iteration one tests the predicate at point $i+2^k$ . If the predicate is still $0$ , the pointer is advanced from $i$ to $i+2^k$ , otherwise it stays the same, then the power $k$ is decreased by $1$ .

This paradigm is widely used in tasks around trees, such as finding lowest common ancestor of two vertices or finding an ancestor of a specific vertex that has a certain height. It could also be adapted to e.g. find the $k$ -th non-zero element in a Fenwick tree.

Practice Problems ¶

  • LeetCode - Find First and Last Position of Element in Sorted Array
  • LeetCode - Search Insert Position
  • LeetCode - First Bad Version
  • LeetCode - Valid Perfect Square
  • LeetCode - Find Peak Element
  • LeetCode - Search in Rotated Sorted Array
  • LeetCode - Find Right Interval
  • Codeforces - Interesting Drink
  • Codeforces - Magic Powder - 1
  • Codeforces - Another Problem on Strings
  • Codeforces - Frodo and pillows
  • Codeforces - GukiZ hates Boxes
  • Codeforces - Enduring Exodus
  • Codeforces - Chip 'n Dale Rescue Rangers
  • Oleksandr Kulkov (81.41%)
  • Jakob Kogler (7.69%)
  • Roman Steinberg (3.21%)
  • jxu (2.56%)
  • 100GODMOON (1.92%)
  • Angkur Mondal (1.92%)
  • Manan Bordia (0.64%)
  • Toufiq Shishir (0.64%)

A Fast Parallelizable Algorithm for Constructing Balanced Binary Search Trees

  • Original Research
  • Published: 14 July 2022
  • Volume 3 , article number  367 , ( 2022 )

Cite this article

research on binary search algorithms

  • Pavel S. Ruzankin   ORCID: orcid.org/0000-0002-5262-3037 1  

112 Accesses

1 Altmetric

Explore all metrics

We suggest a new non-recursive algorithm for constructing a balanced binary search tree given an array of numbers. The algorithm has O ( N ) time and O (1) auxiliary memory complexity if the given array of N numbers is sorted. The resulting tree is of minimal height and can be transformed into a complete binary search tree while retaining minimal height with \(O(\log N)\) time and O (1) auxiliary memory. The algorithm allows simple and effective parallelization resulting in time complexity \(O((N/s)+s+\log N)\) , where s is the number of parallel threads.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price includes VAT (Russian Federation)

Instant access to the full article PDF.

Rent this article via DeepDyve

Institutional subscriptions

research on binary search algorithms

Similar content being viewed by others

research on binary search algorithms

Parallelization of butterfly counting on hierarchical memory

A brief introduction to distributed systems, parallelizing the dual revised simplex method.

Aghaieabiane N, Koppelaar H, Nasehpour P. An improved algorithm to reconstruct a binary tree from its inorder and postorder traversals. J Algorithms Comput. 2017;49(1):93–113.

Google Scholar  

Das VV. A new non-recursive algorithm for reconstructing a binary tree from its traversals. In: 2010 International Conference on Advances in Recent Technologies in Communication and Computing, Kottayam, 2010; pp 261–263. https://doi.org/10.1109/ARTCom.2010.88 .

Find first set. Wikipedia article. https://en.wikipedia.org/wiki/Find_first_set . Retrieved 1 Jun 2022.

Gagie T. New ways to construct binary search trees. In: Ibaraki T, Katoh N, Ono H (eds) Algorithms and computation. ISAAC 2003. Lecture Notes in Computer Science, vol. 2906, Springer, Berlin, Heidelberg, 2003.

Knuth DE. The art of computer programming: sorting and searching, vol. 3. Reading: Addison-Wesley Pub. Co; 1973.

MATH   Google Scholar  

Other built-in functions provided by GCC. https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html . Retrieved 27 Aug 2021.

Stephenson CJ. A method for constructing binary search trees by making insertions at the root. Int J Comput Inf Sci. 1980;9:15–29.

Article   Google Scholar  

Vaucher JG. Building optimal binary search trees from sorted values in O(N) time. In: Essays in Memory of Ole-Johan Dahl, 2004; pp 376–388.

Wirth N. Algorithms + data structures = programs. Englewood Cliffs: Prentice-Hall; 1976.

Download references

The study was supported by the program for fundamental scientific research of the Siberian Branch of the Russian Academy of Sciences, project FWNF-2022-0009.

Author information

Authors and affiliations.

Sobolev Institute of Mathematics, Novosibirsk, Russia

Pavel S. Ruzankin

You can also search for this author in PubMed   Google Scholar

Corresponding author

Correspondence to Pavel S. Ruzankin .

Ethics declarations

Conflict of interest.

The author declares that has no conflict of interest.

Additional information

Publisher's note.

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Reprints and permissions

About this article

Ruzankin, P.S. A Fast Parallelizable Algorithm for Constructing Balanced Binary Search Trees. SN COMPUT. SCI. 3 , 367 (2022). https://doi.org/10.1007/s42979-022-01285-9

Download citation

Received : 28 August 2021

Accepted : 01 July 2022

Published : 14 July 2022

DOI : https://doi.org/10.1007/s42979-022-01285-9

Share this article

Anyone you share the following link with will be able to read this content:

Sorry, a shareable link is not currently available for this article.

Provided by the Springer Nature SharedIt content-sharing initiative

  • Binary search tree
  • Parallel algorithm
  • Find a journal
  • Publish with us
  • Track your research
  • Practice Searching Algorithms
  • MCQs on Searching Algorithms
  • Tutorial on Searching Algorithms
  • Linear Search
  • Binary Search
  • Ternary Search
  • Jump Search
  • Sentinel Linear Search
  • Interpolation Search
  • Exponential Search
  • Fibonacci Search
  • Ubiquitous Binary Search
  • Linear Search Vs Binary Search
  • Interpolation Search Vs Binary Search
  • Binary Search Vs Ternary Search
  • Sentinel Linear Search Vs Linear Search
  • Searching Algorithms

Most Common Searching Algorithms

  • Introduction to Linear Search Algorithm
  • Binary Search Algorithm - Iterative and Recursive Implementation

Other Searching Algorithms

  • Meta Binary Search | One-Sided Binary Search
  • The Ubiquitous Binary Search | Set 1

Comparisons between Searching Algorithms

Linear search vs binary search.

  • Interpolation search vs Binary search
  • Why is Binary Search preferred over Ternary Search?
  • Is Sentinel Linear Search better than normal Linear Search?

Library implementations of Searching algorithms

  • Binary Search functions in C++ STL (binary_search, lower_bound and upper_bound)
  • Arrays.binarySearch() in Java with examples | Set 1
  • Arrays.binarySearch() in Java with examples | Set 2 (Search in subarray)
  • Collections.binarySearch() in Java with Examples

Easy problems on Searching algorithms

  • Find the Missing Number
  • Find the first repeating element in an array of integers
  • Find the missing and repeating number
  • Count 1's in a sorted binary array
  • Sum of two elements whose sum is closest to zero
  • Find a pair with the given difference
  • Kth smallest element in a row-wise and column-wise sorted 2D array
  • Find common elements in three sorted arrays
  • Ceiling in a sorted array
  • Floor in a Sorted Array
  • Find the maximum element in an array which is first increasing and then decreasing
  • Given Array of size n and a number k, find all elements that appear more than n/k times

Medium problems on Searching algorithms

  • Find all triplets with zero sum
  • Find the element before which all the elements are smaller than it, and after which all are greater
  • Find the largest pair sum in an unsorted array
  • K’th Smallest/Largest Element in Unsorted Array
  • Search an element in a sorted and rotated Array
  • Find the Minimum element in a Sorted and Rotated Array
  • Find a Fixed Point (Value equal to index) in a given array
  • Find the k most frequent words from a file
  • Find k closest elements to a given value
  • Given a sorted array and a number x, find the pair in array whose sum is closest to x
  • Find the closest pair from two sorted arrays
  • Find three closest elements from given three sorted arrays
  • Binary Search for Rational Numbers without using floating point arithmetic

Hard problems on Searching algorithms

  • Median of two sorted arrays of same size
  • Search in an almost sorted array
  • Find position of an element in a sorted array of infinite numbers
  • Find if there is a pair with a given sum in the rotated sorted Array
  • K’th Smallest/Largest Element in Unsorted Array | Worst case Linear Time
  • K'th largest element in a stream
  • Best First Search (Informed Search)

Prerequisite:

LINEAR SEARCH

Assume that item is in an array in random order and we have to find an item. Then the only way to search for a target item is, to begin with, the first position and compare it to the target. If the item is at the same, we will return the position of the current item. Otherwise, we will move to the next position. If we arrive at the last position of an array and still can not find the target, we return -1. This is called the Linear search or Sequential search.

Below is the code syntax for the linear search.

   

BINARY SEARCH

In a binary search, however, cut down your search to half as soon as you find the middle of a sorted list. The middle element is looked at to check if it is greater than or less than the value to be searched. Accordingly, a search is done to either half of the given list

Below is the code syntax for the binary search.

   
   

Important Differences  

In linear search input data need not to be in sorted. In binary search input data need to be in sorted order.
It is also called sequential search. It is also called half-interval search.
The time complexity of linear search The time complexity of binary search .
Multidimensional array can be used. Only single dimensional array is used.
Linear search performs equality comparisons Binary search performs ordering comparisons
It is less complex. It is more complex.
It is very slow process. It is very fast process.

Let us look at an example to compare the two:

Linear Search to find the element “J” in a given sorted list from A-X

linear-search

Binary Search to find the element “J” in a given sorted list from A-X

binary-search

LINEAR SEARCHING EXAMPLE:

 
     

Time Complexity: O(n), where n is the size of the input array. The worst-case scenario is when the target element is not present in the array, and the function has to go through the entire array to figure that out. Auxiliary Space: O(1), the function uses only a constant amount of extra space to store variables. The amount of extra space used does not depend on the size of the input array.

BINARY SEARCHING EXAMPLE:

     

Time Complexity: O(log n) – Binary search algorithm divides the input array in half at every step, reducing the search space by half, and hence has a time complexity of logarithmic order. Auxiliary Space: O(1) – Binary search algorithm requires only constant space for storing the low, high, and mid indices, and does not require any additional data structures, so its auxiliary space complexity is O(1).

Please Login to comment...

Similar reads, improve your coding skills with practice.

 alt=

What kind of Experience do you want to share?

IEEE Account

  • Change Username/Password
  • Update Address

Purchase Details

  • Payment Options
  • Order History
  • View Purchased Documents

Profile Information

  • Communications Preferences
  • Profession and Education
  • Technical Interests
  • US & Canada: +1 800 678 4333
  • Worldwide: +1 732 981 0060
  • Contact & Support
  • About IEEE Xplore
  • Accessibility
  • Terms of Use
  • Nondiscrimination Policy
  • Privacy & Opting Out of Cookies

A not-for-profit organization, IEEE is the world's largest technical professional organization dedicated to advancing technology for the benefit of humanity. © Copyright 2024 IEEE - All rights reserved. Use of this web site signifies your agreement to the terms and conditions.

Binary Search in Python – How to Code the Algorithm with Examples

Tantoluwa Heritage Alabi

In our daily lives, we're constantly searching for information or trying to find solutions to problems we encounter.

When going through search results on the web, we pick the most relevant articles or resources that we think will help us.

Search is such a part of our lives because we cannot always have the answers. And there are various algorithms that help programs run more efficiently and deal with data more effectively.

What We'll Cover in This Tutorial

What is a search algorithm.

  • What is a Binary Search algorithm?

How Binary Search Works – Divide and Conquer

  • Processes involved in Binary Search Algorithms
  • Methods Used in Binary Search Algorithms
  • Real-life examples of Binary Search

A search algorithm works to retrieve items from any data structure. It compares the data that comes in as input to the information stored in its database and brings out the result. An example is finding your best friend’s number in your contact list of 1,000 numbers.

There are different types of search algorithms. Some of them are:

Linear search algorithms

Linear search algorithms are the simplest of all the search algorithms. As the name implies, they operate in a sequence.

Linear search checks elements in a list one after the other to find a particular key value. This key value is among other items in the list and the algorithm returns the position by going through the check.

Dijkstra's algorithm

Dijkstra's shortest path algorithm is used in more advanced searches. Dijkstra’s algorithm maps out the shortest distance between two nodes. These nodes are often route networks.

This type of search is useful when you're trying to find routes on maps. It gives you options based on finding the shortest path possible.

Binary Search Algorithm

Binary search algorithms are also known as half interval search. They return the position of a target value in a sorted list.

These algorithms use the “divide and conquer” technique to find the value's position.

Binary search algorithms and linear search algorithms are examples of simple search algorithms.

In binary search, the middle element in the list is found before comparing with the key value you are searching for. But in linear search, the elements are taken one by one in the list by looping through and comparing with the key value.

differences-1

‌During Binary search, the list is split into two parts to get the middle element: there is the left side, the middle element, and the right side.

The left side contains values smaller than the middle element and the right side contains values that are greater than the middle element. This method uses a sorted list to work.

A sorted list has its items arranged in a particular order. To make search efficient for binary search, the values in the list have to be arranged in the right order to satisfy the process of search. If a list has its values mixed up, it has to be sorted by a sorting algorithm before you perform the search.

Sorting algorithms

Sorting algorithms accept an unsorted list as an input and return a list with the elements arranged in a particular order (mostly ascending order).

There are different types of sorting algorithms , like insertion sort, quick sort, bubble sort, and merge sort.

A binary search algorithm uses a technique called “divide and conquer” to tackle its task. The merge sort algorithm employs the same technique to sort items in a list.

In binary search algorithms, the “divide and conquer” method works this way:

  • The algorithm splits the list into two parts: the left side and right side, separated by the middle element
  • It creates a variable to store the value of the item to be searched for
  • It picks out the middle element and compares it with the item to be searched
  • If the items compared are equal, then process ends
  • If not, the middle element is either greater or lesser than the item you're searching for. If the middle element is greater, the algorithm splits the list and searches for the element on the left side. If the middle element is smaller, it splits the list and searches for the element on the right side of the list.

You can implement this method using recursion or iteration in the binary search process.

How the Binary Search Algorithm Works – Step by Step

First, before performing the search, you need to sort the list.

Then you create a variable that stores the value to be searched for.

Next, the list is divided into two parts. We sum up the first and last indexes to find the index of the middle element in the list.

When the calculated value of the middle element index is a float (like 3.45), we take the whole part as the index.

Then we compare the value we're searching for and the middle element.

process1--2-

Binary Search Use Case

Condition 1.

If the middle element is equal to the value to be searched, the position where the value is will be returned and the process is terminated.

Using the Image above as an example:

The middle element = 23, the target value/to_search = 23. Comparing the two values, we see that they are equal on both sides. 23 appears at index 2 in the list. That is the output of the code and the process ends.

Condition 2

If the middle element is not equal to "to_search", then we check the following scenarios:

Scenario 1 : if the middle element is greater than the value to be searched:

if middle element > to_search

  • the search moves to the left side because the values are less than the middle element
  • the position of the middle element shifts to the left by 1
  • new_position = index(middle element) - 1
  • a new search begins and the search ends at that new position and it takes all the values before it.

Using the image above as an example:

  • we move to the left side because all numbers less than 23 are stored there. index (23) = 2
  • new_position = index(23) - 1 = 2-1 = 1
  • The search will end at index 1 and take all other value(s) before index 1                

leftside

Comparing the new middle element (4) to the target value (4), we see they are equal. So the search is terminated and the output is the position  "4" occupies in the list (which is index 0).

Scenario 2 : if the middle element is less than the value to be searched:

if middle element < to_search

  • the search moves to the right side because the values are greater than the middle element
  • the position of the middle element shifts to the right by 1
  • new_position = index(middle element) + 1
  • a new search begins at the new position and ends at the last index in the list
  • all values are taken from the new position to the end of the list

Using the first Image as an example:

  • we move to the right side because all numbers greater than 23 are stored there. index(23) = 2 ,
  • new_position = index(23) + 1 = 2+1 = 3
  • The search will begin at index 3 and take all other value(s) after index 3

rightside

Comparing the middle element (32) to the target value (32), we see they are equal. So the search is terminated and the output is the position  "4" occupies in the list (index 4).

‌‌Methods Used in Binary Search Algorithms

There are two methods that can implement the “divide and conquer” technique in the search. They are iteration and recursion.

What is Iteration?

In order to get elements from a tuple, list, or dictionary, you iterate through the items with loops.

Iteration is a repeated sequence of statements during execution and it has a countable number of values. For example, when looping through random lists, we loop through the actual variable containing the lists to get the values.

Code implementation for binary search with iteration

Here's the code:

Now let's see what's going on here:

  • First, we pass in a list and a value to be searched (to_search) as an input to a function.
  • In the function, we create a variable name of first index and assign it to "0". The first index in a list is always "0".
  • Then we create four variable names: "size" to store the length of the list, "last_index" to store the index of the last element, "mid_index" to store the operation of finding the middle element index, and "mid_element" to store the middle element gotten from the list using the mid index as position.
  • Afterwards, we introduce a while loop to make the conditions run on repeat. Above the while loop we create a variable name "is_found" and set it to "True". This condition checks if the "item to be searched" is found or not.
  • In the while loop, we check all the conditions. The first condition is to check if the middle element and the variable "to_search" are equal. If they are equal, the position of the item will be returned.
  • Then we check for the second condition (if middle element != item to be searched) which leads us to the two scenarios: – if the middle element is greater than the item to be searched, the new position will shift to the left once. The search will begin from the first index and end at the new position which is the new last index. – If the middle element is less than the item to be searched, the new position will shift to the right once. The search will begin from the new position as the new first index and end at the last index.

At the end of these scenarios, we check if the new middle element is the same as the item to be searched. If it is the same, the position of the item will be returned. If not, the conditions are checked until the values are equal.

For error handling, let's say we want to search for a value that does not appear in the list. If we end at the two conditions, the loop will keep running and may eventually crash the system.

To catch the error, we set a condition to check if the first index equals the last index. Then we check if the middle element is equal to the item to be searched. If it is not equal," is found" will be "False". When you run this, it shows an empty array. In my code, the output is a statement.

The final step is to call the function and the result is displayed.

And here are the results:

If the element is in the list, the output is the position.

image-194

If the element is not in the list, the output is a statement like this:

image-195

What is ‌‌Recursion?

A function is said to be recursive if it makes reference to itself or previous term(s) to solve a task.

A recursive function is repetitive and it is executed in sequence. It starts from a complex problem and breaks things down into a simpler form.

Code implementation for binary search with recursion

With recursion, it is a bit simpler and requires less code. Here's what it looks like:

  • First, a function accepts four inputs: the first index, last index, list, and to_search (item to be searched).
  • Then we check if the value of the last index is greater than or equal to the value of the first index. If the condition is true, we assign the operation of finding the middle element index to the variable name "mid_index". Then the middle element is gotten from the list using the mid index as position.
  • We create an "if" statement under the first "if" block to check if the middle element and the variable "to_search" are equal. If they are equal, the position of the item will be returned.
  • Then we check for the second condition, (if middle element != item to be searched) which leads us to two scenarios: – if the middle element is greater than the item to be searched, the new position will shift to the left once. The search will begin from the first index and end at the new position. We return the function and pass in the new position as the last index value. – if the middle element is less than the item to be searched, the new position will shift to the right once. The search will begin from the new position and end at the last index. We return the function and pass in the new position as the first index value.
  • The last condition will be on the same indent as the first "if" statement. If the to_search is not in the list, it will return a statement

If the element is in the list, the output is the position:

image-196

If the element is not in the list, the output is a statement:

image-197

Real-life Examples of Binary Search‌

You might not realize it, but we perform binary search all the time. Here are a few examples of how you might use or encounter it in your daily life or work:

  • Searching for a word in a dictionary
  • searching for a literature text book in a literature section in a library
  • searching for an element in a sorted list
  • searching for students taller than 5 feet 3 inches in a line of students arranged according to their heights.

At the end of this article, you should be familiar with how binary search algorithms work and how to implement them in code.

It's fine if you could not grasp everything at once – just give yourself some time and practice. If you encounter any errors or have questions, you can reach out to me on Twitter .

Read more posts .

If you read this far, thank the author to show them you care. Say Thanks

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

ACM Digital Library home

  • Advanced Search

Efficient Propagation Techniques for Handling Cyclic Symmetries in Binary Programs

New citation alert added.

This alert has been successfully added and will be sent to:

You will be notified whenever a record that you have chosen has been cited.

To manage your alert preferences, click on the button below.

New Citation Alert!

Please log in to your account

Information & Contributors

Bibliometrics & citations, view options, recommendations, handling symmetries in mixed-integer semidefinite programs.

Symmetry handling is a key technique for reducing the running time of branch-and-bound methods for solving mixed-integer linear programs. In this paper, we generalize the notion of (permutation) symmetries to mixed-integer semidefinite programs (...

Normal cirulant graphs with noncyclic regular subroups

We prove that any circulant graph of order n with connection set S such that n and the order of ℤ n * ( S ), the subgroup of ℤ n * that fixes S set-wise, are relatively prime, is also a Cayley graph on some noncyclic group, and shows that the converse does not ...

Classifying Arc-Transitive Circulants of Square-Free Order

A i>circulant is a Cayley graph of a cyclic group. Arc-transitive circulants of square-free order are classified. It is shown that an arc-transitive circulant ý of square-free order i>n is one of the following: the lexicographic product \Sigma[\bar{K}_b]...

Information

Published in.

Linthicum, MD, United States

Publication History

Author tags.

  • symmetry handling
  • cyclic group
  • propagation
  • branch-and-bound
  • Research-article

Contributors

Other metrics, bibliometrics, article metrics.

  • 0 Total Citations
  • 0 Total Downloads
  • Downloads (Last 12 months) 0
  • Downloads (Last 6 weeks) 0

View options

Login options.

Check if you have access through your login credentials or your institution to get full access on this article.

Full Access

Share this publication link.

Copying failed.

Share on social media

Affiliations, export citations.

  • Please download or close your previous search result export first before starting a new bulk export. Preview is not available. By clicking download, a status dialog will open to start the export process. The process may take a few minutes but once it finishes a file will be downloadable from your browser. You may continue to browse the DL while the export process is in progress. Download
  • Download citation
  • Copy citation

We are preparing your search results for download ...

We will inform you here when the file is ready.

Your file of search results citations is now ready.

Your search export query has expired. Please try again.

YouTube's algorithm more likely to recommend users right-wing and religious content, research finds

A hand holding a cell phone with the YouTube logo displayed on the screen

YouTube has a pattern of recommending right-leaning and Christian videos, even to users who haven’t previously interacted with that kind of content, according to a recent study of the platform’s suggestions to users.

The four-part research project, conducted by a London-based nonprofit organization that researches extremism called the Institute for Strategic Dialogue , explored video recommendations served to accounts designed to mimic users interested in four topic areas: gaming, male lifestyle gurus, mommy vloggers and Spanish-language news. 

“We wanted to, for the most part, look at topics that don’t generally direct people into extremist worlds or anything along those lines,” said Aoife Gallagher, the project’s lead analyst.

Researchers created accounts and built mock user personas by searching for content, subscribing to channels and watching videos using those accounts. After having built personas for five days, researchers recorded the video recommendations displayed on each account’s homepage for a month.

The study noted that YouTube’s recommendation algorithm “drives 70% of all video views.”

In one investigation, the most frequently recommended news channel for both child and adult accounts interested in “male lifestyle guru” content was Fox News, even though neither account had watched Fox News during the persona-building stage. Instead, the accounts watched Joe Rogan and Jordan Peterson and searched for the term “alpha male.” 

“This suggests that YouTube associated male lifestyle videos and creators with conservative topics,” the study said.

In another experiment, researchers created two accounts interested in mommy vloggers — mothers who make video diaries about parenting — that they trained to have different political biases. One of the accounts watched Fox News, and the other watched MSNBC. Despite having watched their respective channels for equal amounts of time, the right-leaning account was later more frequently recommended Fox News than the left-leaning account was recommended MSNBC.

A mommy vlogger account that the left-leaning user had already subscribed to was the most recommended channel.

“These results suggest that right-leaning news content is more frequently recommended than left-leaning,” the study said. Both accounts were also recommended videos by an anti-vaccine influencer.

Jessie Daniels, a professor of sociology at Hunter College, part of the City University of New York, and the author of a 2018 article titled “The Algorithmic Rise of the ‘Alt-Right,’” said the project’s main findings were in line with her previous research. She has examined the rise of the internet in the 1990s and how the far right saw an opening to share its beliefs with larger audiences by bypassing the traditional media gatekeepers.

Daniels said she believes the findings suggest that YouTube has made continued engagement and profits its top priorities rather than concerns around reinforcing existing political biases or echo chambers. 

Videos with religious themes — primarily Christianity — were also recommended to all the accounts, even though none of them had watched religious content during the persona-building stage. The accounts interested in mommy vloggers, for example, were shown videos with Bible verses. 

The researchers also found that YouTube recommended videos including sexually explicit content to the child account and videos featuring influencer Andrew Tate, who has been charged with human trafficking and rape (allegations that he has denied) in Romania, even though he is banned from the platform.

Heading into this year’s presidential race, concerns about the spread of election misinformation on social media are only growing. In 2022, a study by researchers at New York University found that after the last presidential election, YouTube recommended videos that pushed voter fraud claims to Donald Trump supporters.

“One of the main issues that we’re seeing is polarization across society, and I think that social media is contributing an awful lot to that kind of polarization,” Gallagher said.

This isn’t the first time YouTube has faced scrutiny for its algorithm. Researchers have repeatedly found that YouTube has recommended extremist and conspiracy theory videos to users. 

“We welcome research on our recommendation system, but it’s difficult to draw conclusions based on the test accounts created by the researchers, which may not be consistent with the behavior of real people,” YouTube spokesperson Elena Hernandez said in a statement to NBC News. “YouTube’s recommendation system is trained to raise high-quality content on the home page, in search results, and the Watch Next panel for viewers of all ages across the platform. We continue to invest significantly in the policies, products, and practices to protect people from harmful content, especially younger viewers.” 

For years, there have also been concerns that social media platforms may create echo chambers where users engage only in content that reinforces their beliefs. However, other recent research has also suggested that users’ own preferences, not the YouTube recommendation system, play the primary role in what they decide to watch and that YouTube may even have a moderating influence.

“This goes back to a lack of transparency and a lack of access that we have to data on YouTube,” Gallagher said. “YouTube is one of the most cloaked of the platforms. It’s very, very difficult to analyze YouTube at scale.”

Victoria Feng is an intern on the NBC News technology desk.

Texas A&M Leads Nation In Engineering Research Expenditures

an aerospace engineering researcher at Texas A&M

The College of Engineering at Texas A&M University has secured the No. 1 spot in fiscal year 2023 engineering research expenditures with $444.7 million in spending, according to the rankings released this week by U.S. News & World Report  2024-2025 Best Engineering Graduate Schools Rankings .

“This accomplishment solidifies our position as a premier hub for cutting-edge research and reinforces our commitment to excellence in engineering education and innovation,” said John Sharp, chancellor of The Texas A&M University System. “It is a testament to the dedication and ingenuity of our faculty and students, who continue to advance engineering research and make significant contributions to the state, country and world.”

Since 2013, the Chancellor’s Research Initiative has provided one-time funds to recruit and hire faculty who will have a transformational impact. The active faculty at Texas A&M Engineering holds 35 memberships in national academies — 32 in the National Academy of Engineering, two in the National Academy of Sciences and one in the National Academy of Medicine.

“We were able to achieve this due to an increase in our National Academy members, thanks in part to the Chancellor’s Research Initiative,” said Dr. Robert H. Bishop, vice chancellor and dean of engineering and director of the Texas A&M Engineering Experiment Station. “Attracting top-tier faculty members leads directly to conducting high-quality research. When you bring in leading experts in their fields, they not only contribute groundbreaking ideas and innovations but also elevate the overall research standards of the institution. This initiative has proven to be a catalyst for enhancing our research capabilities and reputation.”

Leading In Engineering Research And Education

The college also ranked 12th nationally and eighth among public institutions for its graduate engineering program, solidifying its reputation as a leader in engineering education and research. The college’s performance underscores its pivotal role in advancing global cutting-edge research and technological developments.

“These rankings underscore why Texas A&M attracts world-class faculty and researchers and some of the best and brightest students from around the state, the country and the world,” Bishop said. “We prepare students to be leaders and innovators in their fields, and we invest deeply in supporting their work and advancing high-impact research.”

Eight departments secured positions in the top 10 among public institutions. Four departments clinched the No. 1 spot in Texas, including biological and agricultural, industrial, materials and nuclear engineering. Materials science climbed three places to claim a spot in the top 10 among public institutions at No. 9.

College of Engineering No. 12 (No. 8 public)

Aerospace No. 10 (No. 7 public)

Biological and Agricultural No. 8 (No. 7 public, No. 1 in Texas)

Biomedical No. 34 (No. 17 public)

Chemical No. 21 (No. 12 public)

Civil and Environmental No. 12 (No. 9 public)

Computer Engineering No. 24 (No. 12 public)

Computer Science No. 45 (No. 26 public)

Electrical No. 20 (No. 12 public)

Industrial No. 11 (No. 7 public, No. 1 in Texas)

Materials Science No. 16 (No. 9 public, No. 1 in Texas)

Mechanical  No. 16   (No. 8 public)

Nuclear No. 6 (No. 5 public, No. 1 in Texas)

Petroleum No. 2 (No. 2 public)

Read more about the  U.S. News  2024 Best Graduate Schools rankings.

Media contact:  Alyson Chapman, [email protected]

Related Stories

electrical towers with a graphic representation of digital connections between them

Keeping The Lights On With The Help Of AI

Researchers are exploring the use of generative AI to help electrical and power engineers with daily tasks.

A weather radar sits in a parking lot outside the 0&M Building on the Texas A&M campus.

Texas A&M Partners With Climavision To Install New Weather Radar On Campus

The new system will give faculty and students in the Department of Atmospheric Sciences access to more comprehensive, high-resolution weather data.

a drawn depiction of an eye with outer space reflected in it

Researchers Learning More About Eyes Thanks To Astronauts

Texas A&M researchers are investigating the impacts of space travel on eye health in hopes of counteracting the effects of fluid shifts.

Recent Stories

Doctor listening breath of baby in pregnant female abdomen

UTMB, Texas A&M University To Establish Center For Women’s And Pregnancy Health Research

A five-year, $7.5 million grant will fund an initiative to use technology to create reliable tools to advance the development of drugs.

a photo from above shows several partially-opened books standing up on a table

Texas A&M University Press Turns 50

Established in 1974 by Texas A&M President Jack K. Williams, the press has published nearly 2,000 peer-reviewed books during its first half-century of operation.

Decorative photo of the Academic Building

Subscribe to the Texas A&M Today newsletter for the latest news and stories every week.

News Center

Professor earns nsf career award for work in algorithms.

jan.jpg

Assistant Professor Jan van den Brand was recently awarded a National Science Foundation (NSF) CAREER Award for his groundbreaking work developing more efficient algorithms.

Van den Brand’s research focuses on dynamic algorithms and optimization algorithms.

Optimization algorithms support decision-making functionality in airline scheduling, automotive manufacturing, financial services, and other business processes.

Dynamic algorithms solve dynamic problems such as traffic congestion. When a GPS navigation app finds a route affected by construction or traffic congestion, it uses dynamic algorithms to quickly find new routes for the user.

“My research comes up with new techniques for how computers can maintain solutions for a problem that changes over time,” he said.

His proposal focuses on dynamic algorithms and linear programs, a type of optimization algorithm, and the relation between the two.

Although studied extensively, researchers know little about dynamic linear programs from a theoretical perspective. Van den Brand’s proposal explores the synergy between dynamic and optimization algorithms to build a theory for dynamic optimization problems.

Through this, van den Brand hopes to develop more general algorithm techniques that researchers can apply to many problems.

“It’s foundational research constructing tools and techniques for other engineers or scientists to solve their problems more efficiently,” van den Brand said.

As part of his proposal, he is launching a summer school program. The program will be a platform to introduce Ph.D. students to dynamic and optimization algorithms. Van den Brand says he hopes to introduce a new generation of students to theoretical computer science.

“I'm excited about the award and the new projects that it will fund. I want to thank NSF for the award and my colleagues for helpful advice during the proposal process,” van den Brand said.

Morgan Usry Communications Officer School of Computer Science

COMMENTS

  1. Binary search

    Binary search Visualization of the binary search algorithm where 7 is the target value Class Search algorithm Data structure Array Worst-case performance O (log n) Best-case performance O (1) Average performance O (log n) Worst-case space complexity O (1) Optimal Yes In computer science, binary search, also known as half-interval search, logarithmic search, or binary chop, is a search ...

  2. Binary Search Algorithm

    Binary search is a search algorithm used to find the position of a target value within a sorted array. It works by repeatedly dividing the search interval in half until the target value is found or the interval is empty. The search interval is halved by comparing the target element with the middle value of the search space.

  3. Binary search (article)

    Binary search is an efficient algorithm for finding an item from a sorted list of items. It works by repeatedly dividing in half the portion of the list that could contain the item, until you've narrowed down the possible locations to just one. We used binary search in the guessing game in the introductory tutorial.

  4. Extra, Extra

    The binary-search bug applies equally to mergesort, and to other divide-and-conquer algorithms. If you have any code that implements one of these algorithms, fix it now before it blows up. The general lesson that I take away from this bug is humility: It is hard to write even the smallest piece of code correctly, and our whole world runs on big ...

  5. Binary Search

    Here's how the binary search algorithm works: Check if nums [mid] is equal to the target. If so, we've already found a match—in the very first step—and the search terminates. If nums [mid] > target, you only need to search the left half of the array. Even when you search through the left subarray you can use the same binary search ...

  6. Search Algorithms

    Linear or Sequential Search. This algorithm works by sequentially iterating through the whole array or list from one end until the target element is found. If the element is found, it returns its index, else -1. Now let's look at an example and try to understand how it works: arr = [2, 12, 15, 11, 7, 19, 45] Suppose the target element we want ...

  7. Understanding Binary Search: Data Structure and Algorithm

    Binary search is a searching algorithm that finds the position of a target value within a sorted array. It works by repeatedly dividing the search interval in half. If the value of the search key is less than the item in the middle of the interval, the algorithm continues the search on the lower half.

  8. Binary Search (With Code)

    Binary Search is a searching algorithm for finding an element's position in a sorted array. In this approach, the element is always searched in the middle of a portion of an array. Binary search can be implemented only on a sorted list of items. If the elements are not sorted already, we need to sort them first.

  9. What is Binary Search?

    Binary search is a search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array. The course was developed by Harsha and Animesh from MyCodeSchool. MyCodeSchool is one of the oldest software channels on YouTube. Animesh currently works as an engineer ...

  10. Binary Search in Graphs Revisited

    The classical binary search algorithm detects an unknown target (or "treasure") t on a path with n vertices by asking at most \(\log n\) queries to an oracle which always returns the direction from the queried vertex to t.To achieve this upper bound on the number of queries, the algorithm maintains a set of candidates for the place of t; this set is always a sub-path, and initially it is ...

  11. binary search algorithm Latest Research Papers

    Binary search algorithm is a technique applied only on the sorted element (sorted). This research using method of binary search algorithm with analysis stage, system design, coding/construction, testing, and implementation. In the analysis stage, the collection of data conducted is observation and literature study.

  12. PDF An Optimised Binary Search Algorithm

    The binary search algorithm, which is used in searching a linear collection of sorted items, ... (i.e. outside the range of values in the list). This research presents an optimized Binary Search algorithm that ensures that search is performed if and only if the search key is within the feasible search space, thus exhibiting a ...

  13. Binary Search

    f ( 0) ≤ f ( 1) ≤ ⋯ ≤ f ( n − 1). The binary search, the way it is described above, finds the partition of the array by the predicate f ( M) , holding the boolean value of k < A M expression. It is possible to use arbitrary monotonous predicate instead of k < A M . It is particularly useful when the computation of f ( k) is requires ...

  14. (PDF) Modified Binary Search Algorithm

    Binary search algorithm used in the search process of binary search algoritm. Binary search algoritm search is applied to word search in this digital dictionary, because this algoritm is intended ...

  15. C++ Program For Binary Search

    Binary Search is a search algorithm that is faster than the linear search algorithm. Binary Search is used to search the position of the target element in a sorted array by repeatedly dividing the search space in half. Binary search eliminates half portion of the array with each comparison. It works in a time complexity of O (log n) where n is ...

  16. Efficient algorithms to globally balance a binary search tree

    A global tree balancing algorithm generally runs search trees. A comparison of various algorithms s in linear time and consists of two parts: first, a traversal presented. to determine the order ofall nodes, then restructuring pointers based on that order. 1.INTRODUCTION Martin and Ness [7]developed an algorithm that re- A binary search tree is ...

  17. (PDF) ASH Search: Binary Search Optimization

    10. ASH Search: Binary Search Optimization. Ashar Mehmood. School of Electrical Engineeri n g and Compute r Science ( SEECS) National University of Science and Techno logy (NUST) Islamabad, 44000 ...

  18. PDF A Fast Parallelizable Algorithm for Constructing Balanced Binary Search

    We present a new non-recursive algorithm for construct-ing a binary search tree. The algorithm has O(N) time and O(1) auxiliary memory complexity if the given array of N numbers is sorted. We use an array-based representation of the BST. The O(1) auxiliary memory complexity means that, except for the resulting arrays used to store the tree, we.

  19. Linear Search vs Binary Search

    Meta binary search (also called one-sided binary search by Steven Skiena in The Algorithm Design Manual on page 134) is a modified form of binary search that incrementally constructs the index of the target value in the array. Like normal binary search, meta binary search takes O(log n) time. Meta Binary Search, also known as One-Sided Binary Searc

  20. A Brief Study and Analysis of Different Searching Algorithms

    TRADITIONAL SEARCH ALGORITHMS. In this section , we have made an co mparison study on the. four tr aditional search algorithms namely linear search , binary search ,interpolatio n and jump search ...

  21. Interpolated binary search: An efficient hybrid search algorithm on

    The results showed that the interpolational search is the fastest algorithm among the three algorithms tested. The authors explained that the results of this test are not absolute for all cases. A hybrid search algorithm was presented by [12], which works on a sorted or unsorted array. The algorithm combined linear and binary search techniques.

  22. A Survey on Balanced Binary Search Trees methods

    Binary Search Trees (BSTs) are fundamental data structures in computer science; because of their implicit key sorting and linked node structure, they provide effective sorting and simple update operations. They achieve their highest performance when they are balanced. A non-balanced Binary Search Tree is no more efficient than a regular linked list. In the present literature, multiple methods ...

  23. Binary Search in Python

    Binary Search Algorithm. Binary search algorithms are also known as half interval search. They return the position of a target value in a sorted list. These algorithms use the "divide and conquer" technique to find the value's position. Binary search algorithms and linear search algorithms are examples of simple search algorithms.

  24. Efficient Propagation Techniques for Handling Cyclic Symmetries in

    The presence of symmetries in binary programs typically degrades the performance of branch-and-bound solvers. In this article, we derive efficient variable fixing algorithms to discard symmetric solutions from the search space based on propagation techniques for cyclic groups.

  25. NSF Award Search: Award # 2411625

    The project explicitly exploits the unique characteristics of both immersive VR applications and wireless networks, and propose the following four interdependent research thrusts: (I) Dealing with network and prediction uncertainties: This thrust will investigate algorithm designs to optimize personalized user experience given both network and ...

  26. YouTube's algorithm recommends users right-wing and religious content

    YouTube's algorithm more likely to recommend users right-wing and religious content, research finds. ... in search results, and the Watch Next panel for viewers of all ages across the platform. ...

  27. A Siamese network optimization using genetic algorithm for brain

    This paper introduces an innovative approach to Siamese Network Genetic Algorithm (SN-GA) leveraging Siamese contrastive learning for classifying brain images across diverse diseases. Our core architecture is a Bi-Convolutional Neural Network (Bi-CNN) optimized by a genetic algorithm to enhance brain image classification.

  28. Texas A&M Leads Nation In Engineering Research Expenditures

    The College of Engineering at Texas A&M University has secured the No. 1 spot in fiscal year 2023 engineering research expenditures with $444.7 million in spending, according to the rankings released this week by U.S. News & World Report 2024-2025 Best Engineering Graduate Schools Rankings. "This accomplishment solidifies our position as a premier hub for cutting-edge research and reinforces ...

  29. Professor Earns NSF CAREER Award for Work in Algorithms

    Assistant Professor Jan van den Brand was recently awarded a National Science Foundation (NSF) CAREER Award for his groundbreaking work developing more efficient algorithms.. Van den Brand's research focuses on dynamic algorithms and optimization algorithms. Optimization algorithms support decision-making functionality in airline scheduling, automotive manufacturing, financial services, and ...