You are on page 1of 4

Alorithm and Complexity . Your answer is in the form of Document Type.

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    

Write the Algorithm/ Code of this Problem.


2. Biconnected Graph. An undirected graph is said to be a biconnected graph, if there
are two vertex-disjoint paths between any two vertices are present. In other words, we
can say that there is a cycle between any two vertices.

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.

Write the Algorithm and the code is C++.

3. Activity Selection Problem Greedy Algorithm


There are n different activities are given with their starting time and ending time. Select the
maximum number of activities to solve by a single person. We will use the greedy approach
to find the next activity whose finish time is minimum among rest activities, and the start time
is more than or equal with the finish time of the last selected activity.

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).

Input and Output


Input:
A list of different activities with starting and ending times.
{(5,9), (1,2), (3,4), (0,6), (5,7), (8,9)}
Output:
Selected Activities are:
Activity: 0 , Start: 1 End: 2
Activity: 1 , Start: 3 End: 4
Activity: 3 , Start: 5 End: 7
Activity: 5 , Start: 8 End: 9

Write the algorithm and the Code in C++.

4. Job Sequencing Problem with Deadlines

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

Write the algorithm and the Code in C++.

5. Exponential Search

Exponential search is also known as doubling or galloping search. This mechanism is


used to find the range where the search key may present. If L and U are the upper and
lower bound of the list, then L and U both are the power of 2. For the last section, the U is
the last position of the list. For that reason, it is known as exponential.
After finding the specific range, it uses the binary search technique to find the exact
location of the search key.
The complexity of Exponential Search Technique

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)

Input and Output


Input:
A sorted list of data:
10 13 15 26 28 50 56 88 94 127 159 356 480 567 689 699 780 850 956 995
The search key 780
Output:
Item found at location: 16

Write the algorithm and the Code in C++.

You might also like