Lecture 1 Flashcards
What is the Sieve of Erathotenes
The Sieve of Eratosthenes is an ancient algorithm for finding all prime numbers up to a given limit. It works by iteratively marking the multiples of each prime, starting from 2, up to the square root of the limit, thus efficiently identifying the primes within the specified range. O(n log log n)
What is insertion sort?
Insertion sort works by iteratively taking an unsorted element and inserting it into its correct position within the already sorted part of the array. It does this by comparing the element with its predecessors and shifting elements to make room for the insertion. O(n^2)
What is an algorithm?
Finite: Must terminate
correct: must yield correct solution
efficient: should scale polynomically
What is merge Sort?
Merge sort is a divide-and-conquer sorting algorithm that recursively divides an array into halves, sorts each half, and then merges the sorted halves to produce a fully sorted array. Its efficiency lies in its consistent O(n log n) time complexity, making it suitable for large datasets.
What is exhaustive search?
Exhaustive search, also known as brute-force search, is a problem-solving strategy that systematically explores all possible solutions to find the optimal one. It involves considering every option in a solution space, making it thorough but potentially inefficient for large or complex problems. O(n)
What is binary search?
Binary search is a divide-and-conquer algorithm for finding a target value within a sorted array. It repeatedly divides the search range in half, comparing the target value to the middle element and narrowing down the search until the target is found or the search range is empty. O(log n)
When would binary search not work?
When you have multiple answeres in the list you are searching for
What is injective?
Injective, in the context of functions or mappings, means that each distinct element in the domain is associated with a distinct element in the codomain. In simpler terms, an injective function ensures that no two different elements in the domain map to the same element in the codomain.
What is bijective?
A bijective function, also known as a bijection, is a type of function between two sets in which every element in the domain is paired with a unique element in the codomain, and vice versa. In other words, a bijective function is both injective (one-to-one) and surjective (onto), establishing a one-to-one correspondence between the elements of the domain and codomain.
What is surjective?
A surjective function, also known as onto, is a type of function where every element in the codomain has at least one pre-image in the domain. In simpler terms, the function covers the entire range of the codomain, ensuring that no element in the codomain is left unmapped.
How many bijective mappings between two sets with
|A| = |B| = n exist?
n!
How many injective mappings between two sets with |A| = n
and |B| = k, n ≤ k, exist?
C(k,n)= k! / (n!(k−n)!)
What is the Hungarian Algortihm?
The Hungarian algorithm is a combinatorial optimization algorithm used to solve the assignment problem in bipartite graphs, particularly in the context of optimizing the assignment of tasks to workers or resources. It efficiently finds the optimal assignment by iteratively augmenting the assignment along alternating paths in the bipartite graph until a maximum matching is achieved. O(n^3)
What is the Time complexity of pattern matching via Naive search?
O (m*n) m = length of pattern
What is the traveling salesman problem?
The travelling salesman problem asks the following question: “Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the city of origin?” O = (n!)