Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import timeit start = timeit.default_timer() # do whatever you are doing that you need to time taken = (timeit.default_timer() - start Above used as reference.

import timeit
start = timeit.default_timer()
# do whatever you are doing that you need to time taken = (timeit.default_timer() - start
Above used as reference. Need help with Task 3. Thank you :)
image text in transcribed
Task 3 1. Implement a brute force algorithm to solve the Knapsack problem discussed in the lectures, and compare the performance to the Dynamic Programming solution studied in the lectures. Do this by using the technique used in Task 2 of the week 6 workshop, ie, using the timeit module and generating random instances of the problem 2. Implement a greedy algorithm to solve the Knapsack problem discussed in the lectures. Using random instance of the problem try to answer the following question: How likely is it that the greedy algorithm will produce the optimal solution for different problem sizes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genomes Browsers And Databases Data Mining Tools For Integrated Genomic Databases

Authors: Peter Schattner

1st Edition

0521711320, 978-0521711326

More Books

Students also viewed these Databases questions