Python List Interview Question (AI) in Hindi - Live Class-5 (Recording)
Автор: OTT Research Center
Загружено: 2026-02-01
Просмотров: 29
Описание:
Topics Covered in This Session
🔹 1. Shallow Copy vs Deep Copy
Used copy.copy() to demonstrate shallow copy
Showed that:
Top-level elements are copied
Nested objects are shared
Demonstrated how modifying:
Primitive elements affects only copied list
Nested list affects both original and copied list
🔹 2. Reference Assignment (= operator)
Assigned one list to another variable (l3 = l1)
Explained:
Both variables point to the same memory
Any modification reflects in both lists
Clarified difference between:
Copying a list
Referencing a list
🔹 3. Deep Copy
Used copy.deepcopy() to create a fully independent copy
Demonstrated:
Changes in nested elements do not affect original list
Explained when deep copy is required (nested data, ML datasets)
🔹 4. Iterating Over a List
Used for loop to:
Print all elements
Traverse list values
Explained linear traversal concept
🔹 5. Finding Sum of List Elements (Manual)
Calculated sum using loop and accumulator
Introduced reduction/aggregation logic
Linked to real-world data aggregation
🔹 6. Using sum() with List Comprehension
Calculated:
Sum of even numbers
Sum of all elements
Compared manual loop vs Pythonic approach
🔹 7. List Comprehension Basics
Created:
Squares of numbers
Filtered values
Explained syntax and readability benefits
🔹 8. Data Cleaning Using List Comprehension
Removed negative values from list
Connected to:
Data preprocessing
ML dataset cleaning
🔹 9. Conditional Transformation
Converted only even numbers to squares
Compared:
List comprehension approach
Traditional for loop with append()
🔹 10. Flattening a 2D List
Flattened nested list using:
List comprehension
Nested for loops
Explained real-world use:
Matrix to vector
Image/data preprocessing
⏱️ Time & Memory Complexity Analysis
1️⃣ Shallow Copy (copy.copy)
Time Complexity: O(n)
Memory Complexity: O(n) (references reused for nested objects)
2️⃣ Deep Copy (copy.deepcopy)
Time Complexity: O(n) (including nested elements)
Memory Complexity: O(n) (full duplication)
3️⃣ Reference Assignment (=)
Time Complexity: O(1)
Memory Complexity: O(1)
⚠️ No new list created
4️⃣ Loop Traversal / Sum
Time Complexity: O(n)
Memory Complexity: O(1)
5️⃣ List Comprehension (Filtering / Mapping)
Time Complexity: O(n)
Memory Complexity: O(n) (new list created)
6️⃣ Generator Expression with sum()
Time Complexity: O(n)
Memory Complexity: O(1) ✅ (best practice)
7️⃣ Flattening 2D List
Time Complexity: O(n × m)
Memory Complexity: O(n × m)
🎯 Interview Takeaway (One-Line)
Shallow copy shares nested objects, deep copy duplicates everything, list comprehension improves readability but doesn’t reduce time complexity.
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: