Professional Documents
Culture Documents
Alorithm and Complexity - Your Answer Is in The Form of Document Type. Submission Is On The First Day of Resume of Classes
Alorithm and Complexity - Your Answer Is in The Form of Document Type. Submission Is On The First Day of Resume of Classes
Submission
is on the first day of resume of classes.
Research about the following:
1. Sudoku-Solving-algorithms
try to solve the famous number maze problem called Sudoku. Sudoku is a 9 x 9 number grid,
and the whole grid are also divided into 3 x 3 boxes There are some rules to solve the
Sudoku.
We have to use digits 1 to 9 for solving this problem.
One digit cannot be repeated in one row, one column or in one 3 x 3 box.
Using the backtracking algorithm, we will try to solve the Sudoku problem. When some cell is
filled with a digit, it checks whether it is valid or not. When it is not valid, it checks for other
numbers. If all numbers are checked from 1-9, and no valid digit found to place, it backtracks
to the previous option.
Input and Output
Input:
This will take a 9 x 9 matrix as Sudoku grid. Some values are placed in the grid. The blank
spaces are denoted by 0.
Output:
The final matrix (Sudoku grid) filled with numbers. If the solution does not exist, it will return
false.
3 1 6 | 5 7 8 | 4 9 2
5 2 9 | 1 3 4 | 7 6 8
4 8 7 | 6 2 9 | 5 3 1
------------------------
2 6 3 | 4 1 5 | 9 8 7
9 7 4 | 8 6 3 | 1 2 5
8 5 1 | 7 9 2 | 6 4 3
------------------------
1 3 8 | 9 4 7 | 2 5 6
6 9 2 | 3 5 1 | 8 7 4
7 4 5 | 2 8 6 | 3 1 9
We can say that a graph G is a bi-connected graph if it is connected, and there are no
articulation points or cut vertex are present in the graph.
To solve this problem, we will use the DFS traversal. Using DFS, we will try to find if there is
any articulation point is present or not. We also check whether all vertices are visited by the
DFS or not, if not we can say that the graph is not connected.
Input and Output
Input:
The adjacency matrix of the graph.
01110
10100
11001
10001
00110
Output:
The Graph is a biconnected graph.
1. The complexity of this problem is O(n log n) when the list is not sorted.
2. When the sorted list is provided the complexity will be O(n).
In this problem, there is a list of jobs given. In the list, the deadline and the profits are also
given for each job. Every job will take a single unit of time, so the minimum deadline for a job
is 1. If only one job can be scheduled at a time, then maximize the profit.
To solve this problem, all subset of the set of jobs are generated to check whether the
individual subset is feasible or not. Also, keep track on maximum profit for all feasible subset
that has generated.
The time complexity of this algorithm is O(n^2)
Input and Output
Input:
A list of jobs with job id, deadline and profit. And the number of jobs n.
{('a', 2, 100), ('b', 1, 19), ('c', 2, 27), ('d', 1, 25), ('e', 3, 15)}
n=5
Output:
Following is maximum profit sequence of job sequence: c a e
5. Exponential Search
1. Time Complexity: O(1) for the best case. O(log2 i) for average or worst case. Where i is the
location where search key is present.
2. Space Complexity: O(1)