Linked List – Geometry – Problem #1
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
With three positive numbers as input from the user, dynamically allocate a 2D character array with rows and columns. Assign and fill up the rest of randomly with 0’s and 1’s. To control the number of 1’s in A, you need Assume that the value of lies in the interval [1,100]. Use random number generator (see w06-1) to generate random numbers in [1,100] for populating the array based on the value of t. The probability that a particular entry is should be t/100. Print the binary array on the terminal. For clarity, print 0’s as hyphens. Use the rows and columns of A as the (x,y)-coordinates of the points corresponding to the ’s in Mind that corresponds to column, whereas to row. Consider the points (0,0),(c-1,0) and the topmost points of the columns; call this set P.Traverse A in column-major order and print P in increasing order of x.Find the taut rubber band R (as a piecewise-linear poly-line) from (0,0) to (c-1,r-1), and passing from the first to the last point of P, so that no point of P lies above R. Mind that the rubber band always remains taut and so there is always a right turn at every vertex of R excepting its two endpoints. Print the vertices of R on the terminal and mark their corresponding 1’s in as ‘2’. Print the array (with 0’s as hyphens, for clarity).