Algorithm QA
Algorithm QA
1. Define Algorithm. List out the criteria's that all algorithms must satisfy.
An algorithm is a finite sequence of well-defined instructions used to solve a problem or perform a computation.
Criteria:
- Effectiveness: All operations must be basic enough to be performed exactly and in a finite time.
- Time Complexity
- Space Complexity
- Input Size
- Type of Input
3. Arrange the following functions in ascending order: n, 2^n, n!, n^3, nlogn, logn, n^2
Ascending order: logn < n < nlogn < n^2 < n^3 < 2^n < n!
4. Define Brute force method. List out the problems that can be solved using this method.
Brute Force is a straightforward method of solving a problem by trying all possible solutions.
Algorithm & Data Structures - Q&A
Problems:
- String Matching
- TSP
- Sorting
- Searching
- Matrix Multiplication
Two techniques:
1. Bubble Sort
2. Quick Sort
Steps:
- Preprocess pattern
A subset of edges that connects all vertices with minimum total weight and no cycles.
A technique to solve problems by exploring options and backtracking upon failure, e.g., N-Queens.
To find if a subset exists whose sum equals a given value. Solved using backtracking or DP.