Data Structure Questions and Answers-Decimal to Binary Conversion using Recursion

DOWNLOAD FREE PDF <<CLICK HERE>>

Data Structure Questions and Answers-Decimal to Binary Conversion using Recursion

Congratulations - you have completed Data Structure Questions and Answers-Decimal to Binary Conversion using Recursion.

You scored %%SCORE%% out of %%TOTAL%%.

Your performance has been rated as %%RATING%%


Your answers are highlighted below.
Question 1 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Which of the following is the binary representation of 100?
A
1010010
B
1110000
C
1100100
D
1010101
Question 1 Explanation: 
100 = 64 + 32 + 4 = 26 + 25 + 22 = 1100100.

Question 2 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Consider the following iterative code used to convert a decimal number to its equivalent binary:

#include<stdio.h> void dec....to....bin(int n) { int arr[31], len = 0, i; if(n == 0) { arr[0] = 0; len = 1; } while(n != 0) { arr[len++] = n % 2; .....; } for(i=len-1; i>=0; i--) printf("%d", arr[i]); } int main() { int n = 10; dec....to....bin(n); return 0; }

Which of the following lines should be inserted to complete the above code?

A
n-
B
n /= 2
C
n /= 10
D
n++
Question 2 Explanation: 
The line "n /= 2" should be inserted to complete the above code.

Question 3 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
What is the output of the following code?

#include<stdio.h> void dec....to....bin(int n) { int arr[31], len = 0, i; if(n == 0) { arr[0] = 0; len = 1; } while(n != 0) { arr[len++] = n % 2; n /= 2; } for(i=len-1; i>=0; i--) printf("%d", arr[i]); } int main() { int n = 63; dec....to....bin(n); return 0; }
A
111111
B
111011
C
101101
D
101010
Question 3 Explanation: 
The program prints the binary equivalent of 63, which is 111111.

Question 4 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
What is the output of the following code?

#include<stdio.h> void dec....to....bin(int n) { int arr[31], len = 0, i; if(n == 0) { arr[0] = 0; len = 1; } while(n != 0) { arr[len++] = n % 2; n /= 2; } for(i=len-1; i>=0; i--) printf("%d", arr[i]); } int main() { int n = 0; dec....to....bin(n); return 0; }
A
0
B
1
C
Runtime error
D
Garbage value
Question 4 Explanation: 
The program prints the binary equivalent of 0, which is 0.

Question 5 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
What is the time complexity of the above code used to convert a decimal number to its binary equivalent?
A
O(1)
B
O(n)
C
O(n2)
D
O(logn)
Question 5 Explanation: 
The time complexity of the above code used to convert a decimal number to its binary equivalent is O(logn).

Once you are finished, click the button below. Any items you have not completed will be marked incorrect. Get Results
There are 5 questions to complete.