computer science
-
An engineer stores a FIFO queue of bit in an int on a platform with 32bit ints and 8-bit chars using the following C++ class
Class bit queue{
Int valid_bits; //the number of valid bits held in queue
Int queue; //least significant bits is most recent bit added
Public:
Bitqueue(): valid_bits(0), queue(0) {}
Void push(int val, int bsize);
Int pop(int bsize);
Int size();
};1.Write implementation of bitqueue::size which should return the number of bits currently held in queue
2.Write an implementation of bitqueue::push which places the bsize least significant bits from val onto queue and update valid bits. An exception should be thrown in cases where data would otherwise be lost.
3.Write an implementation of bitqueue::pop which takes bsize bits from queue, provides them as the bsize least significant bits in the return value and updated valid bits. An exception should be thrown when any requested data is unavailable. -
An engineer stores a FIFO queue of bit in an int on a platform with 32bit ints and 8-bit chars using the following C++ class
Class bit queue{
Int valid_bits; //the number of valid bits held in queue
Int queue; //least significant bits is most recent bit added
Public:
Bitqueue(): valid_bits(0), queue(0) {}
Void push(int val, int bsize);
Int pop(int bsize);
Int size();
};1.Write implementation of bitqueue::size which should return the number of bits currently held in queue
2.Write an implementation of bitqueue::push which places the bsize least significant bits from val onto queue and update valid bits. An exception should be thrown in cases where data would otherwise be lost.
3.Write an implementation of bitqueue::pop which takes bsize bits from queue, provides them as the bsize least significant bits in the return value and updated valid bits. An exception should be thrown when any requested data is unavailable.We do not do people's homework. The idea of homework is to improve your understanding and skills. Having someone else do it for you misses the point, and gives your instructor and anyone else looking at your grades a false idea of your competence. Try to solve the problem on your own. If you run into problems, come back, post your code, and ask how to solve the specific problem that you are having with your code. You will then find that people are happy to help you.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
-
An engineer stores a FIFO queue of bit in an int on a platform with 32bit ints and 8-bit chars using the following C++ class
Class bit queue{
Int valid_bits; //the number of valid bits held in queue
Int queue; //least significant bits is most recent bit added
Public:
Bitqueue(): valid_bits(0), queue(0) {}
Void push(int val, int bsize);
Int pop(int bsize);
Int size();
};1.Write implementation of bitqueue::size which should return the number of bits currently held in queue
2.Write an implementation of bitqueue::push which places the bsize least significant bits from val onto queue and update valid bits. An exception should be thrown in cases where data would otherwise be lost.
3.Write an implementation of bitqueue::pop which takes bsize bits from queue, provides them as the bsize least significant bits in the return value and updated valid bits. An exception should be thrown when any requested data is unavailable.I don't know where this came from, but it needs correcting before you start. The terms Class, Int, Public and Void are all incorrectly spelled. The correct forms are
class
,int
,public
andvoid
; all lower case. Also the class definition is incorrect. You haveClass bit queue
, but class names are only one word. You also name the constructorBitqueue
, which may or may not match the correct class name. So there is really a lot to learn before you can venture into trying to solve this question.