(a)
To show the number of possible seams grows exponential.
(a)
Explanation of Solution
Consider an array A for the compressing the picture so it requires to remove the pixels in the two adjacent rows in the same or adjacent column and the pixels are removed forms a seam from the top row to the bottom row.
Suppose
The total area enclosed by the seams is order of m and it has two choices for every area of m so the total probability of the total number of seams can be varies from 2m to 2m -1.
Hence, the total number of possibilities of seams is bounded by
(b)
To give an algorithm that finds a seam with lowest disruption measure.
(b)
Explanation of Solution
The algorithm to find a seam with the lowest disruption is given below:
Seam(A)
Initialize tables
For
End for.
for
for
If
If
End if.
Else
End if.
Else if(
If() then
End if.
End if.
End for.
End for.
For
If
End if.
End for.
Print the list
End.
The algorithm compressing the picture so it requires to removes the pixels in the two adjacent rows in the same or adjacent column and the pixels are removed forms a seam from the top row to the bottom row.
This algorithm takes the array A as input and the cases to insert pixel according to the defined condition and return the list of seam as
Want to see more full solutions like this?
Chapter 15 Solutions
Introduction to Algorithms
- Imagine you have a square matrix, where each cell (pixel) is either black or white. Design an algorithm to find the maximum subsquare such that all four borders are filled with black pixels.arrow_forwardDesign a brute-force algorithm for computing the value of a polynomial (in the image below) at a given point x0 and determine its worst-case efficiency class. Algorithm BruteForcePolynomialEvaluation(P[0..n], x) //The algorithm computes the value of polynomial P at a given point x //by the “highest-to-lowest term” brute-force algorithm //Input: Array P[0..n] of the coefficients of a polynomial of degree n, // stored from the lowest to the highest and a number x //Output: The value of the polynomial at the point x If the algorithm you designed is in O(n^2), design a linear algorithm for this problem. Is it possible to design an algorithm with a better than linear efficiency for this problem? Why?arrow_forwardThis question is related to computer graphics. 1) a.Given two triangles P with vertices P1(4,9,5), P2(7,5,4), P3(1,3,5), and Q with vertices Q1(1,6,8), Q2(6,2,8), Q3(1,2,4), determine the visible surfaces using the Z-buffer method. b.Given two triangles P with vertices P1(100,100,50), P2(50,50,50), P3(150,50,50) and Q with vertices Q1(40,80,60), q2(70,70,50), Q3(10,75,70). Determine which triangle should be painted first using the scan-line method.arrow_forward
- STEP 1: forward equationsRequirements:An algorithm that calculates projections (i.e. line integrals) for an object with known attenuation coefficients must be implemented.Inputs: (to be specified by the user while the program is running.)these:* Description of the image (of the object)** Projection angle step size or projection number of*** Number of sampling points in each projectionOutputs:* Vectors containing outputs (Note that the number of output vectors must be determined by the second input mentioned above. The length of these vectors is determined by the third input. )** Output must be presented in graphical format.--------------------------------------------------------------------------------------------STEP 2: BACK PROBLEMRequirements:An algorithm (backprojection algorithm and filtering) will be applied that reconstructs the image (ie attenuation coefficient distribution) for a given set of projection data.Inputs:* Projection dataThe data will be presented in two formats:1.…arrow_forwardConsider a system with four page frames and a program that uses eight pages. Consider the reference string 0 1 7 2 0 3 1 7 0 1 7 and assume that all four page frames are initially empty. Consider the three following algorithms: a. Optimal page replacement In each cases show a diagram (ASCII art recommended) that shows which pages are in which frames throughout time, and page faults at the bottom. For instance: The first 4 steps is ALWAYS the same (i.e., just fill the four frames, with one page fault each time)arrow_forwardObserve the following two Sequential Search and Binary Search algorithms in the image. Perform a comparative analysis of the Sequential Search and Binary Search algorithms in terms of the number of basic operations executed by the two algorithms. A. Calculate and analyze the time complexity T(n) and the efficiency class of the two search algorithms in the worst case. B. Write an example case by writing down the elements for different data sizes, for example n=4, 8, ... Please specify the elements of table A and the data you are looking for, x. Write an illustration of the comparison process for every n to confirm the complexity of the algorithm in point a). C. Describe your opinion regarding the comparative analysis of the efficiency of the two algorithms! Please solve subparts A,B,C in 60 minutes ASAP can u get thank uarrow_forward
- Computer Science Let C be a black circular disk in front of a white background. The circular disk is parallel to the image plane. This disk is projected on the image plane through a pinhole. What is the shape of the disk’s projection on the image plane? [Hint: A circular disk parallel to the image plane is described algebraically as all 3D points [X,Y,Z]T with (X-X0) 2 +(Y-Y0) 2 =R2 , Z=Z0, where [X0,Y0,Z0] T is the center of the disk and R is its radius.]arrow_forward# pyspark # picture attached Given a decomposed separable filter: ⎡⎣⎢⎢121⎤⎦⎥⎥ * [−101] ⎣⎢⎡121⎦⎥⎤∗[−101] and part of an image: ⎡⎣⎢⎢115124170656067120100114103898710111075⎤⎦⎥⎥ ⎣⎢⎡115124170656067120100114103898710111075⎦⎥⎤ Apply this filter to an image (to 3 consecutive pixels with stride 1 and no padding). Find $\max(r) - \min(r)$, difference between maximum and minimum values of a filtered imagearrow_forwardComputer Science A way to avoid overfitting in Deep Neural Networks is to add an additional term R to the loss function L (for example L can be the cross entropy loss) as follows: L(w) + λR(w). (1) You know that one choice for R is the L2 norm, i.e. R(w) = ||w||2 2 . One friend of yours from the School of Maths told you however that there’s no need to use squares (i.e. powers of two) and that you can achieve the same effect by using absolute values, i.e. the L1 norm: R(w) = ||w||1. Would you agree with him? i.e. is the use of the L2 norm equivalent to using the L1 norm for regularization purposes? Justify your answerarrow_forward
- A grid must have a mechanism for numbering the tiles in order to support random-access search.A square grid, for example, contains rows and columns that provide a natural numbering for the tiles. Create designs for triangular and hexagonal grids. Define a rule for finding the neighbourhood (i.e. nearby tiles) of a particular tile in the grid using the numbering scheme. For example, if we have a four-connected square grid with indices I for rows and j for columns, we may define the neighbourhood of tile I j as neighbourhood(i, j) = I 1, j,i, j 1.arrow_forwardWrite python code to find the submatrix. Thank you in Advance. You are given a 2D matrix that is filled with 1's in almost all the cells. However, there may be at most one rectangular submatrix that is filled with 0s. Implement an algorithm to return the size of the submatrix, in terms of width and height. Examples: Input: [[1,1,1,1,1,1,1], [1,1,1,1,1,1], [1,1,0,0,0,1], [1,1,0,0,0,1], 11,1,1,1,1,1]] Output: [3,2] (Because the width of the sumbmarix 3, and highets 2 Input: [[1,1,1,1], [1,1,1,1], [1,1,1,1]] Output: [0,0] (Because the there is no submatrix that contains 0s) Input: [[1,1,1,1], [1,1,0,1] [1,1,1,1]] Output: [1,1] (Because the width of the submatrix of 0s is 1, and height is 1)arrow_forwardHippity hoppity, abolish loopity def frog_collision_time(frog1, frog2): A frog hopping along on the infinite two-dimensional lattice grid of integers is represented as a 4- tuple of the form (sx, sy, dx, dy) where (sx, sy) is its starting position at time zero, and (dx, dy) is its constant direction vector for each hop. Time advances in discrete integer steps 0, 1, 2, 3, ... so that each frog makes one hop at every tick of the clock. At time t, the position of that frog is given by the formula (sx+t*dx, sy+t*dy) that can be nimbly evaluated for any t. Given two frogs frog1 and frog2 that are guaranteed to initially stand on different squares, return the time when both frogs hop into the same square. If these two frogs never simultaneously arrive at the same square, return None. This function should not contain any loops whatsoever. The result should be calculated using conditional statements and integer arithmetic. Perhaps the best way to get cracking is to first solve a simpler…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr