Recycling and sustainability in EV Technology - Time & Space Complexity
We want to understand how the effort to recycle and sustain resources grows as more materials are involved.
How does the work needed change when the amount of waste increases?
Analyze the time complexity of the following process.
function recycleMaterials(materials) {
for (let i = 0; i < materials.length; i++) {
if (materials[i].isRecyclable) {
process(materials[i]);
}
}
}
function process(material) {
// Steps to clean and prepare material for reuse
}
This code checks each material in a list and processes it if recyclable.
- Primary operation: Looping through each material in the list.
- How many times: Once for each material, so as many times as the list length.
As the number of materials grows, the work grows in a similar way because each item is checked once.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | About 10 checks and possible processes |
| 100 | About 100 checks and possible processes |
| 1000 | About 1000 checks and possible processes |
Pattern observation: The work grows steadily and directly with the number of materials.
Time Complexity: O(n)
This means the effort increases in a straight line as more materials are added.
[X] Wrong: "Processing recyclable materials takes the same time no matter how many there are."
[OK] Correct: Each material must be checked and processed individually, so more materials mean more work.
Understanding how work grows with input size helps you explain real-world processes clearly and shows you can think about efficiency in everyday tasks.
"What if the process function also loops through a fixed set of cleaning steps for each material? How would the time complexity change?"
Practice
Solution
Step 1: Understand recycling purpose
Recycling means reusing old materials to make new things.Step 2: Connect recycling to sustainability
This reduces waste and saves resources, helping the environment.Final Answer:
To turn old materials into new products -> Option AQuick Check:
Recycling = reuse materials [OK]
- Thinking recycling creates more waste
- Believing recycling uses more energy
- Confusing recycling with waste creation
Solution
Step 1: Identify sustainable actions
Sustainable actions save resources and reduce harm to nature.Step 2: Evaluate each option
Using reusable bags reduces plastic waste, which is sustainable.Final Answer:
Using reusable bags instead of plastic bags -> Option DQuick Check:
Reusable bags = sustainable choice [OK]
- Thinking all trash in one bin is sustainable
- Believing wasting electricity is sustainable
- Ignoring tree planting importance
bins = {'plastic': 5, 'paper': 3, 'glass': 2}
recycled = {k: v*2 for k, v in bins.items() if v > 2}
print(recycled)
What will be the output?Solution
Step 1: Understand dictionary comprehension with condition
Only items with value > 2 are included and values doubled.Step 2: Apply condition to bins
'plastic' (5) and 'paper' (3) qualify; 'glass' (2) does not.Step 3: Calculate new values
'plastic': 5*2=10, 'paper': 3*2=6Final Answer:
{'plastic': 10, 'paper': 6} -> Option AQuick Check:
Filter >2 and double values = {'plastic':10,'paper':6} [OK]
- Including 'glass' which has value 2
- Not doubling the values
- Printing original dictionary
items = {'plastic': 4, 'paper': 6, 'glass': 3}
total = 0
for item in items:
total += items[item]
print(totall)
What is the error?Solution
Step 1: Check variable names used
Variable 'total' is defined, but 'totall' is printed (typo).Step 2: Identify impact of typo
Printing 'totall' causes a NameError because it is undefined.Final Answer:
Variable name typo in print statement -> Option CQuick Check:
Print typo = NameError [OK]
- Ignoring typo and assuming logic error
- Thinking dictionary syntax is wrong
- Confusing += with =
Solution
Step 1: Identify recyclable and compostable waste
Plastic (40 kg), paper (20 kg), glass (10 kg) are recycled; food scraps (30 kg) are composted.Step 2: Calculate total diverted waste
Sum recycled and composted: 40 + 20 + 10 + 30 = 100 kg.Step 3: Confirm total waste and diversion
Total waste is 100 kg; all waste is diverted from landfill.Final Answer:
100 kg -> Option BQuick Check:
All waste recycled or composted = 100 kg diverted [OK]
- Forgetting to include composted food scraps
- Adding only recycled waste
- Misreading total waste amount
Ready to prove it?
Pass the test and this pattern moves unknown
