Professional Documents
Culture Documents
1. Use a more efficient data structure, such as a hash table instead of a linked list.
2. Use a faster sorting algorithm, such as quicksort instead of bubblesort.
3. Use an algorithm with a better time complexity for the problem at hand, such as using
dynamic programming instead of brute force.
4. Optimize the algorithm for the specific input by using techniques such as memorization or
precomputation.
SEARCHING
➢ Linear search is an algorithm that takes in a list of values and a target value, and searches for
the target value in the list by iterating through each element in the list until it is found. The
time complexity of this algorithm is O(n) because the running time is directly proportional to
the size of the input list.
➢ Binary search is an algorithm that takes in a sorted list of values and a target value, and
searches for the target value in the list by repeatedly dividing the search space in half. The
time complexity of this algorithm is O(logn) because the running time increases
logarithmically with the size of the input list.