Jump to content

zak100

Senior Members
  • Posts

    233
  • Joined

  • Last visited

Posts posted by zak100

  1. I want to use cobertura for coverage. I followed the following link:

     

    https://electric-cloud.com/plugins/directory/p/cobertura/

     

    That link provides a EC-Cobertura.jar file through download. I think it creates a parameter for passing arguments to cobertura. I am trying to run EC-Cobertura.jar but its giving me error:

    Quote

     

    :~/cobertura$ ls -l EC-Cobertura.jar

    -rw-rw-r-- 1 zulfi zulfi 165174 Mar  8 17:53 EC-Cobertura.jar

    :~/cobertura$ java -jar EC-Cobertura.jar

    no main manifest attribute, in EC-Cobertura.jar

    :~/cobertura$ sudo apt-get install binfmt-support

    [sudo] password for zulfi:

    Reading package lists... Done

    Building dependency tree      

    Reading state information... Done

    binfmt-support is already the newest version (2.1.8-2).

    binfmt-support set to manually installed.

    0 upgraded, 0 newly installed, 0 to remove and 258 not upgraded.

    ~/cobertura$ ./EC-Cobertura.jar

    bash: ./EC-Cobertura.jar: Permission denied

    :~/cobertura$ chmod a+rx EC-Cobertura.jar

    :~/cobertura$ ./EC-Cobertura.jar

    no main manifest attribute, in /home/zulfi/cobertura/EC-Cobertura.jar

    :~/cobertura$

     

     

    I have already downloaded the cobertura and its installed on my ubuntu 18.04.

    Quote

     

    :~$ whereis cobertura-instrument

    cobertura-instrument: /usr/bin/cobertura-instrument /usr/share/man/man1/cobertura-instrument.1.gz

    :~$

     

    And it has the same version as the tar file provides whose link is :

     

    https://sourceforge.net/projects/cobertura/

     

     provided in the link of the associated help button page:

    Quote

     

    :~$ cobertura-instrument -version

    Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file

    [INFO] Cobertura: Saved information on 0 classes.

    [INFO] Cobertura: Saved information on 0 classes.

    :~$

     

     

     

    But the help file does not say anything about the jar file. I still don't know how to execute the jar file and how to display the form shown on the link:

     

    http://downloads.electric-cloud.com/plugins/EC-Cobertura/EC-Cobertura_help.xhtml

     

     

    Somebody please guide me how to display the form? What is the purpose of EC-Cobertura.jar in this connection.

     

    Zulfi.

  2. Hi,

    This is not a HW.

    Algorithm for prime number x 2<=I <= x -1, test whether x is divisable by i,

     

    Can we say that the running time is O(log^2 x) time, for large values of x can we say that the algorithm is a psedudo-polynimial time algorithm.

     

    From the internet, I found that the running time of algorithm to find prime number is O(sqrt(N)).

    I have 3 questions: Can we say that the running time is O(log^2N) for detection of Prime number? For large values of N, can we say that its a pseudo-polynomial algorithm? Is this true for Sorting algorithms also?

     

    Zulfi.

  3. Hi,

     

    I want to frame a Probability question for computer science students. I have got a simple idea but I want to refine it so that it becomes a more comprehensive real world problem.

     

    Let’s suppose there are 3 persons and each one is rewarded a gift but when he sees the gift he has got two options, he can either accept the gift or reject the gift. What is the probability that a person can reject the gift?

    Formula= number of successful outcomes/ Total number of equally likely outcomes

                  = 1/2

     

    At this point this is very simple. How the above can be converted into a more complex problem?

     

    Somebody please guide me.

  4. Hi,

    Thanks for your reply.

    <Advice: Wouldn't it be better to try to understand how the algorithm works rather than to try to untangle some specific example out of the many available on the net?>

     

    Actually I chose this example because I saw the attached graph.

    The following is very useful:

     

    Quote

     

    To allow for the discussion to take place here, without having to follow links, the two choices (selecting or not selecting an item i) can be stated* as:

    
    if weight[i] > j //too heavy
        Table[i][j] := Table[i-1][j]
    else // can be carried
    	w := weight[i]
    	v := value[i]
        Table[i][j] := max(v + Table[i][j-w], Table[i-1][j]) 
    end if
    

    Where i is the item, 1<= i <= number of items

    j is the capacity of (current, dynamic) knapsack, 1<= j <= max capacity of knapsack

    weight[] and value[] holds weights and values of the items

     table[][] holds the calculated values of the knapsacks

     

    When you are saying  "can be carried" why are we not increasing the value and weight of knapsack. I mean in the else part, do we not need variables to hold the collective values of weight and values. Where are variables representing the total weight and value of knapsack?

     

    Kindly guide me.

    Zulfi.

    graph.jpg

  5. Hi,

    Thanks for your response.

    Okay lets start with row2 which is Table[1][*]. I am just concentrating on riptutorial

    Quote

    Moving on, for Table[1][1], we are asking ourselves, if we had item 1 and 2 and if the maximum capacity of our knapsack was 1, what is the maximum value we can get? If we take both item 1 and 2, the total weight will be 4, which will exceed our current knapsack capacity. So item 2 can't be selected.

     Okay I understand this. But still I would add on for future reference: Table [1][1] = 2nd row. item 1 above means weight '1' item and item 2 means weight '3' item. Total weight for both item 1 & item 2 = 3 +1 =4 correct (as above) and exceeds the knapsack capacity because capacity was 1 in case of Table[1][1].

     

    Quote

    For Table[1][2], since 2 is less than weight[2], that is the weight of the second item, we can't take the item. So we can establish that, if the weight of the current item is greater than our maximum capacity, we can't take that item. In this case, we'll simply take the value from top, which represents the maximum value we can take excluding the item.

    For Table[1][2], capacity =2. weight[2], if we are starting from 0 it should be weight[1] but they later clarified it that they mean second item. weight of current item = weight of 2nd item i.e. 3. At this point for Table[1][2] maximum capacity is 2 and current item i.e. the item with weight 3 is greater than the capacity 2. value from top =1 , correct, so they filled 1 in the table[1][2] which is correct. Now we would go ahead.

     

    Quote

    Now for Table[1][3] since our maximum capacity is equal to our current weight, we have two choices.

    capacity is 3 and current weight is 3, so they are correct.

    Quote

    Among the two choices, we'll pick the one from which we can get maximum value. If we select the item, we get: value for this item + maximum value from rest of the items after taking this item = 4 + 0 = 4. 

    What are the 2 choices they are talking about?

    Quote

    if we select the item, we get:

    Which item are they talking about?

     

    Can you please explain me the rest of the stuff also i.e.

    Quote

    value for this item + maximum value from rest of the items after taking this item = 4 + 0 = 4. 

     Please guide me.

     

    Thanks for your cooperation.

     

    Zulfi.

  6. Hi,

    I am trying to understand knapsack problem from the following site:

     

    https://riptutorial.com/dynamic-programming/example/25787/0-1-knapsack-problem

    +----------+---+---+---+---+

    |   Item   | 1 | 2 | 3 | 4 |

    +----------+---+---+---+---+

    |  Weight  | 1 | 3 | 4 | 5 |

    +----------+---+---+---+---+

    |   Value  | 1 | 4 | 5 | 7 |

    +----------+---+---+---+---+

     

    n represents the number of items and w represents weight units. There should be n+1 rows and w+1 columns as discussed in the link:

    https://medium.com/@fabianterh/how-to-solve-the-knapsack-problem-with-dynamic-programming-eb88c706d3cf

    In the example we w = 7 and n= 4, therefore there should be 5 rows and 8 columns. There are 8 columns but only 4 rows. I can’t understand why they have 4 rows?

    Then the started filling the first column: Table[0][0], Table[1][0], Table[2][0], Table[3][0]. This will all be zeros, this is because capacity is zero in all the above cases.

    But for first row, I am confused:

    Table[0][0]: capacity is 0, so its 0 (OK)

    Table [0][1]: capacity is 1, so its 1 (OK)

     Table[0][2]: capacity is 2, but no item with weight 2, so 1 is fine

    Table[0][3]: capacity is 3, we have an item of weight 3 so we can write 3, but they wrote 1, I cn’t understand

    Some body please guide me.

     Zulfi.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.