Results 1 to 2 of 2
  1. #1
    ofirattia is offline Member
    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Default Knapsack problem , check if matrix can fill list of smaller matrix list.

    Hi, i have a list of arrays ( of sizes , for example : 3X1 , 4X2 and so on..) i want to check if i can put all of them in one matrix.
    i need to do it in a recursive way.
    the function i need to write is get the size of the matrix and 2d array called tiles.
    tiles[][] contains for example {{1, 1}, {1, 1}, {1, 1}, {1, 1}}, and the size of the matrix 2,2.
    now i need to take those details and check if the matrix contains the list of tiles , for this example is true because {1,1} is a one place in the matrix is like 1X1 , before the X is Height and after is Width. ( you can see in the image below).
    the function is :

    public static int[][] insertIntoKnapsack(int n, int m, int[][] tiles) {
    int[][] ans = new int[n][m];

    int H,W;
    for(int ind=0;ind<tiles.length;ind++)
    {
    H = tiles[ind][0];
    W = tiles[ind][1];


    now i stuck i dont know what do to check.
    any ideas?
    thanks.
    Knapsack problem , check if matrix can fill list of smaller matrix list.-knapsack.png
    Last edited by ofirattia; 12-08-2012 at 07:31 PM. Reason: details

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

Similar Threads

  1. Replies: 1
    Last Post: 10-16-2012, 10:34 PM
  2. Java array matrix problem.. please help!
    By Asvin in forum New To Java
    Replies: 5
    Last Post: 04-11-2011, 07:35 PM
  3. how to check scalability of matrix
    By ajay kumar in forum Advanced Java
    Replies: 0
    Last Post: 12-04-2009, 12:53 PM
  4. how to check scalability of matrix
    By ajay kumar in forum Java 2D
    Replies: 0
    Last Post: 12-04-2009, 06:30 AM
  5. Help with matrix
    By susan in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 04:37 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •