Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. computer science

computer science

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structuresannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_14910948
    wrote on last edited by
    #1

    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.

    D L 2 Replies Last reply
    0
    • M Member_14910948

      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.

      D Offline
      D Offline
      Daniel Pfeffer
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M Member_14910948

        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.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        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 and void; all lower case. Also the class definition is incorrect. You have Class bit queue, but class names are only one word. You also name the constructor Bitqueue, 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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups