Search Algorithms

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/57

flashcard set

Earn XP

Description and Tags

Search

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

58 Terms

1
New cards

What is a search algorithm?

An algorithm used to find specific data within a structure such as an array, graph, or tree.

2
New cards

What are the two main types of search algorithms?

Linear search and binary search.

3
New cards

What is linear search?

A simple search algorithm that checks each element sequentially until the target is found.

4
New cards

What is the time complexity of linear search?

O(n)

5
New cards

What is binary search?

A divide-and-conquer search algorithm that repeatedly divides a sorted array to find the target.

6
New cards

What is the time complexity of binary search?

O(log n)

7
New cards

What are the requirements for binary search?

The input data must be sorted.

8
New cards

What is interpolation search?

An improved variant of binary search for uniformly distributed data.

9
New cards

What is the time complexity of interpolation search?

O(log log n) on average, O(n) worst-case.

10
New cards

What is jump search?

A search algorithm that jumps ahead by fixed steps and then performs linear search backward.

11
New cards

What is the time complexity of jump search?

O(√n)

12
New cards

What is exponential search?

Searches an unbounded or large sorted array by doubling the range and then using binary search.

13
New cards

What is the time complexity of exponential search?

O(log n)

14
New cards

What is ternary search?

A search algorithm that divides the array into three parts instead of two like binary search.

15
New cards

What is the time complexity of ternary search?

O(log₃ n), similar to binary search.

16
New cards

What is depth-first search (DFS)?

A graph traversal algorithm that explores as far as possible along each branch before backtracking.

17
New cards

What is breadth-first search (BFS)?

A graph traversal algorithm that explores all neighbors at the current depth before moving to the next level.

18
New cards

What data structure is used in DFS?

Stack (or recursion).

19
New cards

What data structure is used in BFS?

Queue

20
New cards

What is the time complexity of DFS and BFS?

O(V + E), where V = vertices and E = edges.

21
New cards

Is DFS better than BFS?

It depends on the use case; DFS uses less memory, BFS guarantees shortest path.

22
New cards

Which search algorithm guarantees the shortest path in unweighted graphs?

BFS

23
New cards

What is best-first search?

A search that explores a graph based on a given heuristic.

24
New cards

What is A* search algorithm?

An informed search algorithm that uses cost and heuristic to find the shortest path.

25
New cards

What is the formula used in A* search?

f(n) = g(n) + h(n), where g = cost to reach node, h = heuristic estimate to goal.

26
New cards

What is Dijkstra’s algorithm?

A shortest path algorithm for weighted graphs with non-negative weights.

27
New cards

What is the time complexity of Dijkstra's algorithm?

O(V²) or O((V + E) log V) with a priority queue.

28
New cards

What is Greedy Best-First Search?

A search that chooses the node that appears to be closest to the goal using only the heuristic.

29
New cards

Is A* complete and optimal?

Yes, if the heuristic is admissible and consistent.

30
New cards

What is a heuristic in search algorithms?

A technique to estimate the cost or distance from a node to the goal.

31
New cards

What is an admissible heuristic?

A heuristic that never overestimates the true cost to reach the goal.

32
New cards

What is uniform cost search?

A search algorithm that expands the least-cost node first, similar to Dijkstra’s algorithm.

33
New cards

Is BFS complete and optimal?

Yes, for unweighted graphs.

34
New cards

Is DFS complete and optimal?

Complete for finite graphs but not optimal.

35
New cards

What is iterative deepening DFS?

A combination of DFS and BFS that increases depth limit step by step.

36
New cards

What is the advantage of iterative deepening DFS?

It uses less memory like DFS and finds shortest paths like BFS.

37
New cards

Which search algorithm is best for unbounded tree search?

Iterative Deepening DFS

38
New cards

What is IDA* (Iterative Deepening A*)?

A memory-efficient version of A* that combines heuristic search with iterative deepening.

39
New cards

What is bidirectional search?

A search from both the start and the goal that meets in the middle.

40
New cards

What is the time complexity of bidirectional search?

O(b^d/2), where b = branching factor and d = depth.

41
New cards

What is the benefit of bidirectional search?

It significantly reduces the search space.

42
New cards

What is hashing in search?

Using a hash function to directly access data, providing near O(1) search time.

43
New cards

What is the average time complexity of hash table search?

O(1)

44
New cards

What is the worst-case time complexity of hash table search?

O(n), due to collisions.

45
New cards

What is binary search tree (BST) search?

A search in a tree where left child < parent < right child.

46
New cards

What is the time complexity of search in a balanced BST?

O(log n)

47
New cards

What is the worst-case time for BST search?

O(n), when the tree becomes skewed.

48
New cards

What is the time complexity of search in an AVL Tree or Red-Black Tree?

O(log n)

49
New cards

What is a trie (prefix tree)?

A tree used for efficient retrieval of strings based on their prefixes.

50
New cards

What is the time complexity for search in a trie?

O(L), where L is the length of the string.

51
New cards

What is the main use of trie?

Autocomplete and spell-checking.

52
New cards

What is a linear probing in hash tables?

A collision resolution method where next available slot is checked sequentially.

53
New cards

What is binary search not suitable for?

Unsorted data or dynamic lists with frequent insertions.

54
New cards

What is a sentinel in search algorithms?

A dummy value used to simplify loop termination in linear search.

55
New cards

What is the difference between BFS and DFS in terms of completeness?

BFS is complete; DFS may not terminate in infinite-depth graphs.

56
New cards

Which search is better for memory-limited environments?

DFS or Iterative Deepening DFS.

57
New cards

Which search is better when goal is deep in the graph?

DFS

58
New cards

Which search is better when goal is close to root?

BFS