0% found this document useful (0 votes)
4 views3 pages

P204-Python Assignment1

Uploaded by

udayvalmiki71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

P204-Python Assignment1

Uploaded by

udayvalmiki71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Recall the concepts algorithm and flowchart, and design algorithm and flowchart for the

given five problems below.

**you can type the assignment and upload the document or you can write it in a notebook,
take the photos of it and make a pdf file and upload it.

join the google classroom to submit the assignment


**material also available for you to access, related to linux commands. Please use the material
and practice

Algorithm:
A sequence of unambiguous instructions for solving a problem, i.e., for obtaining a
required output for any legitimate input in a finite amount of time.
The word “algorithm” is derived from the ninth-century Arab mathematician, Al-Khwarizmi.

Flowchart:
A flowchart is a visual diagram that represents a process or an algorithm step-by-step
using symbols and arrows. It is used to break down complex tasks into simple,
easy-to-understand steps, helping people to understand the logic behind a process or
workflow.

Symbols:
1. The Merchant’s Dilemma
In a bustling market town, a merchant is preparing for a long journey to a distant city to
sell valuable goods. He owns a sturdy cart that can hold a maximum of 50 units of
weight. The merchant wants to maximize his profits from the trip, but he has a limited
amount of space.
Here’s the challenge: the merchant can only bring a limited number of items on his cart,
and each item has a different weight and value.

He has six items to choose from:


Golden Necklace – Weight: 10 units, Value: 60 gold coins
Silver Plate – Weight: 20 units, Value: 100 gold coins
Bronze Shield – Weight: 30 units, Value: 120 gold coins
Diamond Ring – Weight: 5 units, Value: 40 gold coins
Silk Garment – Weight: 15 units, Value: 70 gold coins
Rare Book – Weight: 25 units, Value: 80 gold coins
The merchant can only bring items whose total weight does not exceed 50 units, and he
wants to bring the combination of items that will give him the highest total value.
What is the most valuable combination of items the merchant can bring on his journey
without exceeding the cart's weight limit?

2. Apples, Oranges or Both?


You’re faced with three jars labeled “Apples”, “Oranges”, and “Both”. You cannot see
the contents of these jars, but you’re informed that each is mislabeled. The contents of the
jar are not decribed by the label.
How many times would you need to draw from a jar in order to accurately label each jar?

3. Gold Rod
An employee works for an employer for 7 days. The employer has a gold rod of 7 units.
How does the employer pay to the employee, so that the number of employee’s rod units
increases by one at the end of each day? The employer can make at most 2 cuts in the
rod.
(Hint- after the end of the day employee’s can’t spend any part of rod)
4. Contaminated Pills
You have 5 jars of pills. Each pill weighs 10 grams, except for contaminated pills
contained in one jar, where each pill weighs 9 grams. Given a scale, how could you tell
which jar had the contaminated pills in just one measurement?

5. The Bridge problem


You are a scientist in a lab who accidentally releases trapped zombies. Along with the
janitor, lab assistant, and old professor, you must escape the lab situated on an isolated
island. Time taken by each person to cross the bridge:
You - 1 minute
Lab Asst - 2 minutes
Janitor - 5 minutes
Professor - 10 minutes
An old bridge allows only two people to cross at a time, and zombies will arrive exactly
in 17 minutes. Your goal is to get everyone safely across and cut the bridge rope within
that time. How will you achieve this?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy