```r knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
--- ```r knitr::opts_chunk$set( collapse = TRUE, comment = "#>", echo = TRUE )
library(parallel) library(AdvRLab6)
Answer:
We will use the function system.time
to measure the time that it takes to evaluate this function:
system.time(brute_force_knapsack(x = knapsack_objects[1:16,], W = 3500))
Answer:
system.time(knapsack_dynamic(x = knapsack_objects[1:500,], W = 3500))
system.time(greedy_knapsack(x = knapsack_objects[1:1000000,], W = 3500))
Answer:
NOTE: Package lineprof
is not available for R version 3.6.1, so we will use package profvis
instead.
#profvis::profvis(brute_force_knapsack(x = knapsack_objects[1:100,], W = 3500))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.