int knapSack(int W, int wt[], int val[], int n) 
   if(W==0 || n==0) return 0;
       return max(
         val[n-1] + knapSack(W-wt[n-1], wt, val, n-1), 
         knapSack(W, wt, val, n-1)
   else {
       return knapSack(W, wt, val, n-1);
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter