Index of Minimum Element
Find index of minimum element.
BeginnerPhase 4 - Level 1: Basic ArraysExample 8 of 10
index-of-minimum-element.py
1# Take array2n = int(input("Enter array size: "))3arr = []4for i in range(n):5 arr.append(int(input(f"Element {i+1}: ")))67# Find index of min8min_index = 09min_value = arr[0]1011for i in range(1, len(arr)):12 if arr[i] < min_value:13 min_value = arr[i]14 min_index = i1516print(f"Index of minimum: {min_index}")
Output
Enter array size: 5 Element 1: 10 Element 2: 5 Element 3: 20 Element 4: 3 Element 5: 15 Index of minimum: 3
What's going on
Track both value and index.
Key Concepts:
Initialize with first element
Track index when updating min
Print index of minimum
🔗Related Content
- 📖
Phase 4 - Learn Concepts
Review Phase 4 concepts and explanations
- 📝
Phase 4 - Quiz
Test your Phase 4 understanding with quiz questions
- 💻
Phase 4 - All Practice Problems
Explore all practice problems for Phase 4
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum