Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question in computer science 5 . 1 Insertion: You are given two 3 2 - bit numbers, N and M , and two bit positions,

Question in computer science 5.1 Insertion: You are given two 32-bit numbers, N and M , and two bit positions, i and j. Write a method to insert M into N such that M starts at bit j and ends at bit i. You can assume that the bits j through i have enough space to fit all of M. That is, if M=10011, you can assume that there are at least 5 bits between j and i. You would not, for example, have j=3 and i=2, because M could not fully fit between bit 3 and bit 2.EXAMPLEInput: N=10000000000,M=10011,quad i=2,j=6Output: N=10001001100Hints: #137, #169, #215pg 276GrackingTheCodingInterview.com 6 th Edition115Chapter 5| Bit Manipulation5.2 Binary to String: Given a real number between 0 and 1(e.g,0.72) that is passed in as a double, print the binary representation. If the number cannot be represented accurately in binary with at most 32 characters, print "ERROR."Hints: #143, #167, #173, #269, #297_pg 2775.3 Flip Bit to Win: You have an integer and you can flip exactly one bit from a 0 to a 1. Write code to find the length of the longest sequence of 1 s you could create.EXAMPLEInput: 1775(or: 11011101111)Output: 8Hints: #159, #226, #314, #3525.4 Next Number: Given a positive integer, print the next smallest and the next largest number that have the same number of 1 bits in their binary representation.Hints: #147, #175, #242, #312, #339, #358, #375, #390pg 2805.5 Debugger: Explain what the following code does: ((n&(n-1))==0).Hints: #151, #202, #261, #302, #346, #372, #383, #3985.6 Conversion: Write a function to determine the number of bits you would need to flip to convert integer A to integer B.EXAMPLEInput: quad29(or: 11101),15(or: 01111)Output: quad2Hints: #336, #3695.7 Pairwise Swap: Write a program to swap odd and even bits in an integer with as few instructions as possible (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, and so on).Hints: #145, #248,#328,#3555.8 Draw Line: A monochrome screen is stored as a single array of bytes, allowing eight consecutive pixels to be stored in one byte. The screen has width w , where w is divisible by 8(that is, no byte will be split across rows). The height of the screen, of course, can be derived from the length of the array and the width. Implement a function that draws a horizontal line from (x1,y) to (x2,y).The method signature should look something like:drawLine(byte[] screen, int width, int x 1, int x 2, int y )Hints: #366, #381, #384, #391_pg 287Additional Questions: Arrays and Strings (#1.1, #1.4, #1.8), Math and Logic Puzzles (#6.10), Recursion (#8.4, #8.14), Sorting and Searching (#10.7,#10.8), C++(#12.10), Moderate Problems (#16.1,#16.7), Hard Problems (#17.1).Hints start on page 662.116 Cracking the Coding Interview, 6th EditionMath and Logic Puzzleso-called "puzzles" (or brain teasers) are some ofthe most hotly debated questions, and many companieshave policies banning them. Unfortunately, even when these questions are banned, you still may find
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions

Question

Differentiate 3sin(9x+2x)

Answered: 1 week ago

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago

Question

7. List behaviors to improve effective leadership in meetings

Answered: 1 week ago

Question

6. Explain the six-step group decision process

Answered: 1 week ago