Explore tens of thousands of sets crafted by our community.
Search Algorithms
6
Flashcards
0/6
Breadth-First Search (BFS)
An algorithm for searching a tree or graph data structure by exploring all neighbor nodes at the present depth prior to moving on to nodes at the next depth level. Typical use cases include finding the shortest path, level order traversal of trees, and peer-to-peer networks. Complexity: O(V+E), where V = number of vertices, E = number of edges.
Exponential Search
A search algorithm that begins by checking if the first element is the one being searched for, if not, it checks successive powers of two, and when it finds an interval containing the target, it performs a binary search within that interval. Typical use cases include search operations in unbounded or infinite lists. Complexity: O(log i), where i is the index of the target value.
Linear Search
A simple search algorithm that checks every element in the list until the desired element is found or the list ends. Typical use cases include searching in small or unsorted datasets. Complexity: Worst-case and Average-case complexity O(n), Best-case complexity O(1).
Depth-First Search (DFS)
An algorithm for traversing or searching tree or graph data structures by exploring as far as possible along each branch before backtracking. Typical use cases include solving puzzles, finding connected components, and topological sorting. Complexity: O(V+E), where V = number of vertices, E = number of edges.
Interpolation Search
A search algorithm that works on the principle of divide and conquer by estimating the position of the target value within a sorted array using interpolation and may achieve better performance than binary search for uniformly distributed data. Typical use cases include searching in uniformly distributed data sets. Complexity: Average-case complexity O(log(log n)), Worst-case complexity O(n).
Binary Search
A search algorithm that finds the position of a target value within a sorted array by repeatedly dividing the search interval in half. Typical use cases include searching in large sorted arrays. Complexity: Worst-case and Average-case complexity O(log n), Best-case complexity O(1).
© Hypatia.Tech. 2024 All rights reserved.