sets all cells of row i and column j to 0

Given a matrix of 1s and 0s. Implement an algorithm that sets all cells of row i and column j to 0 if the original matrix has a 0 in cell (i,j). Would the algo change if you have to set it to 1 instead of 0?


  1. I cant understand, is it something like following,



    here i am traversing the matrix from left to right.

  2. I have solved it somehow, goto this link

    Matrix Problem 01

    Leave your valuable comment there.

  3. @tanmay there is nothing wrong in this code but for each value mat(i,j) you are changing the value of all rows and cols corresponding to this value.Instead of that you can take the product of particular rows and cols and then evaluate each element.

  4. for any array[i][j]; perform the following calc:

    for (col = 0; col < NUMCOLS; ++col)
    array[i][j] &&= array[i][col];
    for (row = 0; row < NUMROWS; ++row)
    array[i][j] &&= array[row][j];

    OR you can store the value of inner loop in some array instead of repeating it.

  5. I failed to solve one of your problem's "Merge two sorted arrays without redundancy" in the first attempt. I will try it again. Because I liked the problem.

    However, I also have posted two problems which will seem easy to you as I think you are a very good programmer. But still you can check them out through the following links....

    Matrix Problem 02
    Problem: In a given matrix all the cells will contain a value of 1 or 0. Change the value of a cell to 1 if the summation of its 8 adjacent cells are 3 or greater than 3, otherwise change the value to 0. Boundary cells can have 3 or 5 or less adjacent cells depending on the size of the matrix, so for boundary cells you will have to calculate over them. The number of rows and columns will be equal. For example, you might be given a 8x8 matrix. The values will be given by the user. You can keep the number of cells 8x8 or you can make it variable or user inputted.

    Tic-Tac-Toe Game
    Problem: We hope we are all known with the game Tic-Tac-Toe. Well..if we are not, we will be soon. You will not have to build any artificial intelligence for the game as the game will be played by two human, I mean users. Lets get into it.....

    Visit the links for explanations with required images and download links of the EXEs of the solutions I made.

  6. I dont know why I am not becoming able to comment anywhere, The Comment As option box is not showing anything and preventing from commenting...!! Thats why commenting here from email link.

    I think I solve a problem of yours: Binary Tree is Sum Tree or Not

    However, I used complete binary tree and another limitation is that you will have to use distinct element only. I tried a lot. But it is still creating problem when it is visiting the root array, it is adding redundant entries. So dont use redundant entries.

    [The Solution is Here]

    Please leave your comment there at my post. Thank you.


Post a Comment

Popular posts from this blog