- All
- Engineering
- Algorithms
Powered by AI and the LinkedIn community
1
Linear search
Be the first to add your personal experience
2
Binary search
Be the first to add your personal experience
3
Hash table search
Be the first to add your personal experience
4
Breadth-first search
Be the first to add your personal experience
5
Depth-first search
Be the first to add your personal experience
6
Here’s what else to consider
Be the first to add your personal experience
Search algorithms are methods of finding a specific item or value in a collection of data. They are essential for solving many problems in computer science, such as sorting, searching, and optimization. In this article, you will learn about some of the most common search algorithms, how they work, and when to use them.
Find expert answers in this collaborative article
Experts who add quality contributions will have a chance to be featured. Learn more
Earn a Community Top Voice badge
Add to collaborative articles to get recognized for your expertise on your profile. Learn more
1 Linear search
Linear search is the simplest search algorithm. It works by checking each element of the data one by one until it finds the target or reaches the end. Linear search is easy to implement and does not require any prior sorting or ordering of the data. However, it is also very slow and inefficient, especially for large or unstructured data sets. The time complexity of linear search is O(n), where n is the number of elements in the data.
Help others by sharing more (125 characters min.)
2 Binary search
Binary search is a faster and more efficient search algorithm than linear search. It works by dividing the data into two halves and comparing the target with the middle element. If the target is equal to the middle element, the search is done. If the target is smaller than the middle element, the search continues in the left half. If the target is larger than the middle element, the search continues in the right half. This process is repeated until the target is found or the data is exhausted. Binary search requires that the data is sorted in ascending or descending order before applying the algorithm. The time complexity of binary search is O(log n), where n is the number of elements in the data.
Help others by sharing more (125 characters min.)
3 Hash table search
Hash table search is a search algorithm that uses a data structure called a hash table. A hash table is a collection of key-value pairs, where each key is mapped to a unique value by a hash function. A hash function is a mathematical function that converts any input into a fixed-length output, called a hash or a digest. Hash table search works by applying the hash function to the target and looking up the corresponding value in the hash table. If the value exists, the search is successful. If the value does not exist, the search fails. Hash table search is very fast and efficient, as it can find the target in constant time, O(1), regardless of the size of the data. However, hash table search also has some drawbacks, such as the possibility of hash collisions, where two different keys have the same hash, and the need for extra space to store the hash table.
Help others by sharing more (125 characters min.)
4 Breadth-first search
Breadth-first search is a search algorithm that explores a graph or a tree data structure. A graph is a collection of nodes and edges, where nodes represent entities and edges represent connections or relationships. A tree is a special type of graph, where there is one root node and no cycles or loops. Breadth-first search works by starting from a given node, called the source, and visiting all its adjacent nodes, called the neighbors. Then, it visits all the neighbors of the neighbors, and so on, until it reaches the target node or exhausts all the nodes. Breadth-first search can find the shortest path from the source to the target, if it exists, and can also discover all the nodes that are reachable from the source. The time complexity of breadth-first search is O(m + n), where m is the number of edges and n is the number of nodes in the graph.
Help others by sharing more (125 characters min.)
5 Depth-first search
Depth-first search is another search algorithm that explores a graph or a tree data structure. It works by starting from a given node, called the source, and following one path as deep as possible, until it reaches a dead end or the target node. Then, it backtracks and tries another path, until it visits all the nodes or finds the target. Depth-first search can find any path from the source to the target, but not necessarily the shortest one. It can also detect cycles or loops in the graph, and classify the edges as tree, forward, backward, or cross edges. The time complexity of depth-first search is O(m + n), where m is the number of edges and n is the number of nodes in the graph.
Help others by sharing more (125 characters min.)
6 Here’s what else to consider
This is a space to share examples, stories, or insights that don’t fit into any of the previous sections. What else would you like to add?
Help others by sharing more (125 characters min.)
Algorithms
Algorithms
+ Follow
Rate this article
We created this article with the help of AI. What do you think of it?
It’s great It’s not so great
Thanks for your feedback
Your feedback is private. Like or react to bring the conversation to your network.
Tell us more
Tell us why you didn’t like this article.
If you think something in this article goes against our Professional Community Policies, please let us know.
We appreciate you letting us know. Though we’re unable to respond directly, your feedback helps us improve this experience for everyone.
If you think this goes against our Professional Community Policies, please let us know.
More articles on Algorithms
No more previous content
- You want to improve your algorithm. How can you engage end-users for valuable feedback? 3 contributions
- Your algorithm results veer off course. How can you rebuild client trust effectively? 3 contributions
- You're facing a tight deadline to optimize algorithms. How can you maintain focus and motivation? 2 contributions
- You're faced with a demanding algorithmic change. How do you navigate the need for resources and time? 1 contribution
- You're refining your algorithm amidst constant feedback. How do you ensure quality isn't sacrificed? 2 contributions
- You're optimizing algorithm performance. How do you decide which feedback sources to prioritize? 2 contributions
- You're faced with algorithm issues needing immediate fixes. How can you meet a client's demands effectively? 1 contribution
- You're facing tight deadlines for algorithm adaptation. How can you guarantee precision and dependability? 1 contribution
- Balancing legacy algorithm systems and innovation challenges you. How can you ensure market competitiveness? 1 contribution
- You're overwhelmed with new tools and algorithms. How do you decide what to prioritize? 1 contribution
- You're dealing with a sudden project deadline change. How should you prioritize algorithm optimization tasks? 1 contribution
- You're navigating algorithm changes within your team. How can you ensure effective communication? 1 contribution
- You're facing scalability challenges with stakeholders. How can you make them understand the impact? 1 contribution
- You're struggling to meet project deadlines. How can you adapt algorithms without compromising timelines? 1 contribution
No more next content
Explore Other Skills
- Programming
- Web Development
- Machine Learning
- Software Development
- Computer Science
- Data Engineering
- Data Analytics
- Data Science
- Artificial Intelligence (AI)
- Cloud Computing
More relevant reading
- Algorithms Here's how you can choose the best algorithms for your project.
- Algorithms How can you determine the efficiency of a recursive algorithm?
- System Development What are the most efficient and suitable sorting and searching algorithms to use in system development?
- Algorithms You want to make a positive impact on your company. What are the best algorithms to use?