VIP 👤
🏠 Trang chủ
Benchmark
📊 Tất cả benchmark 🦖 Khủng long v1 🦖 Khủng long v2 ✅ Ứng dụng To-Do List 🎨 Trang tự do sáng tạo 🎯 FSACB - Trình diễn cuối cùng 🌍 Benchmark dịch thuật
Mô hình
🏆 Top 10 mô hình 🆓 Mô hình miễn phí 📋 Tất cả mô hình ⚙️ Kilo Code
Tài nguyên
💬 Thư viện prompt 📖 Thuật ngữ AI 🔗 Liên kết hữu ích 🔌 API và bộ định tuyến AI
Advanced

Recursive Algorithm Optimization

#algorithms #optimization #coding #logic

Optimize a naive recursive implementation of a dynamic programming problem.

You are an Algorithm Expert. I will provide a naive recursive implementation of the 'Matrix Chain Multiplication' problem. Analyze the time complexity and identify overlapping subproblems. Rewrite the solution using memoization (top-down) and then transform it into a tabulation (bottom-up) approach. Finally, optimize the space complexity of the bottom-up approach to O(1) if possible, or explain why it is not feasible. Provide the code in Python.