1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
wolverine [178]
2 years ago
10

Enum Digits {0, 1};

Computers and Technology
1 answer:
Arisa [49]2 years ago
3 0

Answer:

The code is given below with appropriate comments for better understanding

Explanation:

#include <bits/stdc++.h>

using namespace std;

enum Digits {

zero,

one

} ;

struct CellType

{

  Digits bit;

  CellType* next;

};

class Minimum

{

public:

  struct CellType* head,*temp; // head to point MSB

  Minimum(string s)

  {

      int sz = s.size(); // binary size as per question it indicates n.

      for(int i=0;i<sz;i++)

      {

          if(s[i] == '0') // if the bit is zero , we add zero at the end of stream

              addAtEnd(zero);

          else // if the bit is one , we one zero at the end of stream

              addAtEnd(one);

      }

      addOne();

      showlist();

  }

  CellType* create(Digits x) // to create a node of CellType*

  {

      CellType* t = new CellType();

      t->bit = x;

      t->next = NULL;

      return t;

  }

  void addAtEnd(Digits x)

  {

     

      if(head == NULL) // if list is empty , then that will be the only node

      {

          CellType* t;

          t = create(x);

          head = temp = t;

      }

      else

      { // other wise we add the node at end indicated by the temp variable

          CellType* t ;

          t = create(x);

          temp->next = t;

          temp=temp->next;

      }

  }

  void showlist()

  {

      // this is just a normla method to show the list

      CellType* t = head;

      while(t!=NULL)

      {

          cout<<t->bit;

          t=t->next;

      }

  }

  void addOne()

  {

      /*

          here since we need to add from the end and it is a singly linked list we take a stack

          and store in last in ,first out format .

          Then we keep on changing all ones to zeroes until we find a zero int he list,

          The moment a zero is found it should be changed to one.

          If everything is one in the sequence , then we add a new zero digit node at the beginning of the list.

      */

      stack<CellType*> st;

      CellType* t = head;

      while(t!=NULL)

      {

          st.push(t);

          t=t->next;

      }

      while(st.size()>0 && (st.top())->bit == one )

      {

          CellType* f = st.top();

          f->bit = zero ;

          st.pop();

      }

      if(st.size())

      {

          CellType* f = st.top();

          f->bit = one ;

      }

      else

      {

          t = create(one);

          t->next = head;

          head = t;

      }

  }

};

int main()

{

  /*

      Here i am taking an integer as input and then converting it to binary using a string varaible s

      if you want to directly take the binary stream as input , remove the comment from "cin>>s" line.

  */

  long long int n,k;

  cin>>n;

  string s;

  k = n;

  while(k>0)

  {

      s = s + (char)(k%2 +48);

      k=k/2;

  }

  reverse(s.begin(),s.end());

  //cin>>s;

  Minimum* g = new Minimum(s);

 

  return 0;

}

You might be interested in
1. What are you going to do if someone ask for your personal information online?​
Stells [14]

Answer:

Ask them why they need such information.

Explanation:

If they can't give you a good reason, please don't share your personal info. ♥

7 0
3 years ago
Read 2 more answers
Which technology keeps track of heart rate during a workout? (3 points) bathroom scale calculator pedometer wrist monitor
kramer

The technology keeps track of heart rate during a workout is pedometer. Option C is the answer

<h3>What is pedometer?</h3>

A pedometer is a device,that is used to know how many steps an individual takes during workout.

It is a good step-meter that keeps the heart rate in check especially during exercise.

Therefore, The technology keeps track of heart rate during a workout is pedometer. Option C is the answer

Learn more on pedometer below

brainly.com/question/12364238

#SPJ1

8 0
1 year ago
Categories of general purpose application software and examples each​
avanturin [10]

Answer:

These are the software that you use a lot at home and at school. They are cheap but free from the bug as they are thoroughly tested. And they are easily available as well. Various examples are:

Word processors - These are used to write the memos, letters, and reports. an example is Microsoft word.

Spreadsheet- keep track of accounts. example, Microsoft Excel, Google sheet.

Database application - Keeping track of customer's records. Example Microsoft Access etc.

Desktop publishers- for creating business cards, posters, etc. Example-Microsoft Publisher.

Presentation software - for creating presentations example, Microsoft Powerpoint

Applications for Graphics- for making changes to the images, like Corel Draw

Applications for Web design - creating business websites, and personal. example. Dreamweaver.

Explanation:

Please check the answer.

7 0
2 years ago
14. The heart of a computer is<br> a CPU<br> b. Memory<br> c. I/O Unit<br> d. Disks
NNADVOKAT [17]

Answer:

CPU

I dont know a whole ton about computers. But I'm confident this is correct. Without the CPU the other options on this list wouldnt work so the CPU would be the "heart".

3 0
2 years ago
Preciso de ajudar para resolver esse exercício, é para amanhã cedo!!<br><br> Em Dev C++
LenKa [72]
Bbbbbbbbbbbbbbbbbbbbbb
3 0
2 years ago
Read 2 more answers
Other questions:
  • All of the following are stages in the SDLC except _____.
    9·1 answer
  • Windows uses a graphical user interface (GUI), which means: a user can carry out commands by clicking, dragging, or otherwise ma
    6·1 answer
  • Explain how the principles underlying agile methods lead to accelerated development and deployment of software.
    6·1 answer
  • Which statement describes what happens if multiple users make changes simultaneously to a presentation when
    10·1 answer
  • Briefly explain five measures you have undertaken to protect your confidential
    12·1 answer
  • Which of the following statements is true? Computer disks are volatile storage devices Volatile storage is lost when a computer
    12·2 answers
  • Which federal agency enforces safety and health legislation and requires employers to be sure that adequate first-aid supplies a
    5·1 answer
  • PLEASE HURRY!!!
    11·1 answer
  • WILL MARK CORRECT ANSWER AS BRAINLIEST PLSSSS HELP!
    13·2 answers
  • David is preparing a report to show the percentage increase in population in the United States in the last five years. Which fea
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!