1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Rufina [12.5K]
2 years ago
10

You are given a list of n positive integers a1, a2, . . . an and a positive integer t. Use dynamic programming to design an algo

rithm that examines whether a subset of these n numbers add up to exactly t, under the constraint that you use each ai at most once. If there is a solution, your program should output the subset of selected numbers. Recurrence Relation (and base cases)
Computers and Technology
1 answer:
Anna11 [10]2 years ago
6 0

Answer:

See explaination for the program code

Explanation:

The code below

Pseudo-code:

//each item ai is used at most once

isSubsetSum(A[],n,t)//takes array of items of size n, and sum t

{

boolean subset[n+1][t+1];//creating a boolean mtraix

for i=1 to n+1

subset[i][1] = true; //initially setting all first column values as true

for i = 2 to t+1

subset[1][i] = false; //initialy setting all first row values as false

for i=2 to n

{

for j=2 to t

{

if(j<A[i-1])

subset[i][j] = subset[i-1][j];

if (j >= A[i-1])

subset[i][j] = subset[i-1][j] ||

subset[i - 1][j-set[i-1]];

}

}

//returns true if there is a subset with given sum t

//other wise returns false

return subset[n][t];

}

Recurrence relation:

T(n) =T(n-1)+ t//here t is runtime of inner loop, and innner loop will run n times

T(1)=1

solving recurrence:

T(n)=T(n-1)+t

T(n)=T(n-2)+t+t

T(n)=T(n-2)+2t

T(n)=T(n-3)+3t

,,

,

T(n)=T(n-n-1)+(n-1)t

T(n)=T(1)+(n-1)t

T(n)=1+(n-1)t = O(nt)

//so complexity is :O(nt)//where n is number of element, t is given sum

You might be interested in
The ________ tier of the three-tier architecture consists of computers, phones, and other mobile devices that have browsers that
andrey2020 [161]

Answer:

It is the user tier of the 3-tier architecture that consists of computers, phones, and other mobile devices that have browsers that request and process web pages.

Explanation:

Almost if not all applications that use e-commerce for operations use the 3-tier architecture.  3-tier architecture is simply the arrangement of server tier which consists of all computers that run a web server and a database tier that consists of computers that run a DBMS to store and retrieve data. We also have the user data that consists of computers, phones, and other mobile devices that have browsers that request and process web pages.

When you make a request, for instance to Google in your local browser, the browser sends a request to the internet. This initial interaction between the user and the internet is what is known as the user tier of the 3 tier architecture. Basically, it is the phase where end users access content online through graphical interface browsers and make requests to the web servers and DBMS.

Learn more about 3-tier architecture

brainly.com/question/12627823

#LearnWithBrainly

6 0
3 years ago
Usted repetir la pregunta?<br>O A. Es<br>B. Puede<br>C. Puedes<br>O D. Está​
puteri [66]

Answer:

I believe the answer is B. Puede

5 0
2 years ago
Read 2 more answers
Can someone help: how to get binary?
xxTIMURxx [149]

Answer:

Explanation:

SENN KİMSİİİİİİİİN???

8 0
1 year ago
Read 2 more answers
Mesh networks:__________.
postnew [5]

Answer:

b. typically contain more circuits in the network than in star or ring networks

Explanation:

In mesh architecture, all computers are connected to each other. In mesh all nodes connect directly and non hierarchical to each other so as  to efficiently route data.

Mesh combines the benefits of both ring and star networks. It  usually provide relatively short routes through the network (compared to ring networks) and provide  many possible routes through the network to prevent one circuit from becoming overloaded (as compared to star network).  Mesh network uses decentralized routing with each network performing its own routing.

Mesh network typically contain more circuits in the network than in star or ring networks and are more expensive than ring networks

7 0
3 years ago
Which feature of a website takes you to a different part of the website or a totally different website when you click on it?
lesantik [10]

A hyperlink is a feature that takes you to a different page when you click on it. That page could be part of the same website or a totally different website.

Let me know if you have any questions.

3 0
3 years ago
Read 2 more answers
Other questions:
  • ________ is a command-line utility installed in the windows\system32 folder that displays information about your windows version
    9·1 answer
  • You would like to search for information about storms but not tornadoes. What type of search strategy may be useful?
    10·2 answers
  • If you were the IT manager for a large manufacturing company,what issues might you have with the use of opensource software? Wha
    10·1 answer
  • Charts are more effective in attaining attentionthen others methods of presenting data. Do you agree?
    10·1 answer
  • A service technician removed the inspection/fill plug from the differential of a rear-wheel- drive vehicle and gear lube started
    8·1 answer
  • 2.
    5·1 answer
  • Omo help me i need it now.
    12·1 answer
  • What is the effects of computer and internet attacks​
    11·2 answers
  • You text file begins with the following rows. The pattern is a description of the item to be repaired, its color, and the issue.
    14·1 answer
  • In cell b12 create a formula using max f7nction to calculate maximum value in B4:B9
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!