Search Algorithms Flashcards

1
Q

Search Algorithms

A

Search algorithms are techniques for finding specific elements within a data structure or collection. Examples include Binary Search, Depth-First Search (DFS), and Breadth-First Search (BFS).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Binary Search

A

Binary Search is an efficient search algorithm used to find a specific element in a sorted array or list. It works by repeatedly dividing the search interval in half and comparing the target element with the middle element of the interval. This process continues until the element is found or it is determined that the element is not in the list. Binary Search has a time complexity of O(log n).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Depth-First Search (DFS)

A

Depth-First Search (DFS) is a graph traversal algorithm that explores as far as possible along each branch before backtracking. It starts from a source node and explores all its adjacent nodes before moving deeper into the graph. DFS can be implemented using recursion or a stack data structure. It is often used for tasks like determining connected components and detecting cycles in graphs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Breadth-First Search (BFS)

A

Breadth-First Search (BFS) is a graph traversal algorithm that explores all the vertices at the current level before moving to the next level. It starts from a source node and explores all its neighbors before moving to the neighbors’ neighbors. BFS is commonly used to find the shortest path in unweighted graphs, and it can also be used for tasks like level-order traversal of trees and finding connected components in graphs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly