Skip to content

The search problem

Content summary

This lesson introduces the search problem.

Motivation

People need information constantly, yet the amount of data stored in systems is enormous.

How can we quickly find the exact piece of information we need in such a vast sea of data?


Problem definition

In general, the search problem involves finding one or more items that satisfy a given condition within a collection.

In this lesson, we focus on a specific version of the search problem:

  • The data is stored in a one-dimensional array.
  • We are looking for exactly one element with a given value k.

Formal problem statement

Input Output
- A one-dimensional array A containing n integers.
- A target value k to search for.
- The index (position) of the element equal to k in array A or -1 if k is not found.

Search algorithms

Some search algorithms

  • Sequential search
  • Binary search

Benefits and applications

Searching is a fundamental way of interacting with data and brings many important benefits. It helps discover relevant information, deepens understanding of the world from existing data, and supports better decision-making.

Common real-world applications of search algorithms include:

  1. Searching for specific information

    Words in a document, a phone number in a contact list, a file on a computer, or a book in a library.

  2. Database queries

    Customers searching for products, prices, or promotions on e-commerce platforms.

  3. Information retrieval

    Search engines helping users find relevant documents or websites on the internet.

  4. Optimization problems

    Finding the best solution among many possibilities — e.g., the shortest path or the cheapest option.

  5. Data analysis

    Identifying patterns, trends, or correlations in large datasets to gain insights and draw conclusions.

  6. Anomaly detection

    Helping systems spot potential problems, trigger alerts, or take appropriate actions.


Summary mindmap


Some English words

Vietnamese Tiếng Anh
bài toán tìm kiếm search problem