Octal to Binary Conversion Challenge Solved

Day 27 of my #50DaysOfCode challenge is done ✅ 📌 Problem Solved Convert Octal to Binary We were given an octal number. Task was to convert it into binary. Instead of converting directly, we used a two-step process. First → Octal to Decimal. Then → Decimal to Binary. 💻 Approach Step 1: Octal to Decimal 🔹️Take each digit of the octal number. 🔹️Multiply it with (8^i). 🔹️Increase power (i) as we move left. 🔹️Add all values to get decimal number. Step 2: Decimal to Binary 🔹️Divide the decimal number by 2 repeatedly. 🔹️Store the remainders. 🔹️Continue until the number becomes 0. 🔹️Read the remainders in reverse order. That gives the binary number. 📊 Complexity Analysis Time Complexity: O(log n) Space Complexity: O(1) Only a few variables are used. 📚 What I learned today: ▫️Number system conversions can be chained. ▫️Octal to decimal uses powers of 8. ▫️Binary conversion uses repeated division by 2. ▫️Breaking the problem into steps makes it easier. Day 27 completed. Practicing number system conversions 🚀 #50DaysOfCode #CodingChallenge #Consistency #LearningInPublic

To view or add a comment, sign in

Explore content categories