Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Pseudo-code. I need help translating pseudo-code into python code. Note: I am familiar with python but not with its pseudo code. Please help with

Python Pseudo-code.

I need help translating pseudo-code into python code. Note: I am familiar with python but not with its pseudo code. Please help with translating the following 3 questions into python code.

1. c[0...n + 1, 0...n+1] translate into python code. Also, how would you initialize it with that specification?

2. for i = 1 to n translate into python code.

3. c[i, i] = 0 translate into python code.

Below is the pseudo code in its entirety. However, I only need the 3 listed above to be translated.

image text in transcribed

1 DYNAMIC-ACTIVITY-SELECTOR (s, f, n) 2 let c[0..n 1, 0..n1] and act[0..n1, ..n for i-0 ton 1] be new tables 4 c[n + 1, n0 for 1-2 to n 1 for i 0 to n-1+1 10 while f[i] f[k] 12 13 14 15 16 17 18 19 if f[i] s s[k] and f[k] S s[j] and c[i, k] + c[k, j]+1> c[i c[k, j] + 1 c[i, jc[i, k] actli, j-k print "A maximum size set of mutually compatible activities has size" c[e print "The set contains PRINT-ACTIVITIES (c, act, 0, n+ 1)

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

Students also viewed these Databases questions