# Data Structure Questions and Answers-Decimal to Binary using Stacks

BUY PDF <<CLICK HERE>>

## Data Structure Questions and Answers-Decimal to Binary using Stacks

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

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]
Express -15 as a 6-bit signed binary number.
 A 1111 B 101111 C 101110 D 1110
Civics Test Questions answers
Question 1 Explanation:
The first 4 1s from the right represent the number 15, 2 more bits are padded to make it 6 digits and the leftmost bit is a 1 to represent that it is -15.

 Question 2 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Which of the following code snippet is used to convert decimal to binary numbers?
 A public void convertBinary(int num) { int bin[] = new int; int index = 0; while(num > 0)  B public void convertBinary(int num) { int bin[] = new int; int index = 0; while(num > 0)  C public void convertBinary(int num) { int bin[] = new int; int index = 0; while(num > 0)  D public void convertBinary(int num) { int bin[] = new int; int index = 0; while(num > 0)
Crack any exam
Question 2 Explanation:
Take the modulus by 2 of the number and store in an array while halving the number during each iteration and then display the contents of the array.

 Question 3 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Which is the predefined method available in Java to convert decimal to binary numbers?
 A toBinaryInteger(int) B toBinaryValue(int) C toBinaryNumber(int) D toBinaryString(int)
Crack any exam
Question 3 Explanation:
The method toBinaryString() takes an integer argument and is defined in java.lang package. Usage is java.lang.Integer.toBinaryString(int) this returns the string representation of the unsigned integer value.

 Question 4 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Using stacks, how to obtain the binary representation of the number?

public void convertBinary(int num) { Stack<Integer> stack = new Stack<Integer>(); while (num != 0) { int digit = num /

public void convertBinary(int num) { Stack<Integer> stack = new Stack<Integer>(); while (num != 0) { int digit = num %
correctchoice

public void convertBinary(int num) { Stack<Integer> stack = new Stack<Integer>(); while (num != 0) { int digit = num Computer science (GATE/NET) Questions answers Question 4 Explanation:  Here instead of adding the digits to an array, you push it into a stack and while printing, pop it from the stack.Question 5 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]What is the time complexity for converting decimal to binary numbers?AO(1)BO(n)CO(logn)DO(nlogn)GK (GENERAL KNOWLEDGE) Questions answers Question 5 Explanation:  Since each time you are halving the number, it can be related to that of a binary search algorithm, hence the complexity 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.

BUY PDF <<CLICK HERE>>