Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use Matlab to answer this question 1. Dene a recursive function myrecdec2bin that transforms a nonnegative integer into its binary representation dened as a binary
Use Matlab to answer this question
1. Dene a recursive function myrecdec2bin that transforms a nonnegative integer into its binary representation dened as a binary vector. 2. Use myrecdec2bin to display, for X varying from 1 to 20, x, myrecdec2bin(x) and mybin2dec(myrecdec2bin(x)) (that should be equal to X). 3. Comment quickly about the number of iterations your recursive function takes to ensure its complexity is roughly the same as the iterative method. In the following, we propose experiments to compare the CPU time taken by the iterative and the recursive methods. The strategy is as follows: we will edit a random vector TEST of length 100 and integral components between 0 and 107. Then, for each of these 100 random values, we will run the two functions mydec2bin and myrecdec2bin and compare the CPU timeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started