## Help authour, Buy PDF Ebook
>>>**Click Here**<<<

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

## Click on any option to know the CORRECT ANSWERS

Question 1 |

Which of the following is the binary representation of 100?

1010010 | |

1110000 | |

1100100 | |

1010101 |

**Computer science Questions answers**

Question 1 Explanation:

100 = 64 + 32 + 4 = 2

^{6}+ 2^{5}+ 2^{2}= 1100100.

Question 2 |

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?

n- | |

n /= 2 | |

n /= 10 | |

n++ |

**English grammar Questions answers**

Question 2 Explanation:

The line "n /= 2" should be inserted to complete the above code.

Question 3 |

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; }

111111 | |

111011 | |

101101 | |

101010 |

**HRM Questions answers**

Question 3 Explanation:

The program prints the binary equivalent of 63, which is 111111.

Question 4 |

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; }

0 | |

1 | |

Runtime error | |

Garbage value |

**EVS Questions answers**

Question 4 Explanation:

The program prints the binary equivalent of 0, which is 0.

Question 5 |

What is the time complexity of the above code used to convert a decimal number to its binary equivalent?

O(1) | |

O(n) | |

O(n ^{2}) | |

O(logn) |

**Civics Test Questions answers**

Question 5 Explanation:

The time complexity of the above code used to convert a decimal number to its binary equivalent is O(logn).

There are 5 questions to complete.