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]
3 years ago
10

Enum Digits {0, 1};

Computers and Technology
1 answer:
Arisa [49]3 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
Drew is creating a game that stops the timer when the hourglass
Lana71 [14]
Stops the hourglass then unstop
6 0
3 years ago
The IT department at Piggy Parts BBQ has recently learned of phishing attempts that rely on social engineering to break into its
Katen [24]

Answer:

all personnel

Explanation:

According to my research on information technology and cyber security, I can say that based on the information provided within the question this information should be communicated to all personnel. This should be done as a safety precaution, by making all personnel aware of they would know to speak up if they see anything suspicious otherwise they might think an attack is just part of something that the organization is implementing.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

6 0
3 years ago
you have a column of dog breeds that are in all capital letters. what function would you use to convert those dog breeds so that
topjm [15]

The function  that would help you use to convert those dog breeds so that only the first letter of each word is capitalized is  upper() function.

<h3>What are Excel functions for changing text case?</h3>

There are some 3 main functions which are:

  • UPPER
  • LOWER
  • PROPER.

Note that the upper() function helps one to to convert all lowercase letters in a text string to a case that is uppercase and as such, The function  that would help you use to convert those dog breeds so that only the first letter of each word is capitalized is  upper() function.

Learn more about   function from

brainly.com/question/23459086

#SPJ2

3 0
2 years ago
. <br> It matters if you capitalize your search words in a search engine<br> True<br> False
Natasha2012 [34]

Answer:

false

Explanation:

search engines really don't care. they'll find the answer almost always whether or not you capitalize things

5 0
3 years ago
What two solutions address lack of human access to clean water
Marina86 [1]

Answer:

THREE strategies which local municipality is implementing in addressing the issue of lack of clean water caused by human factors include:

1) Increasing the amount of tax for those companies which are opening their wastes into water sources which can help built better water cleaning and recycle system.

2) Tree plantation is another strategy to help secure the water sources and naturally keep cleaning it.

3) Running awareness campaigns for general people to keep the water sources clean as well as use the only amount of water which they need and not waste it.

Explanation:

i hope this helps you

5 0
3 years ago
Other questions:
  • File formats are linked to certain programs.<br><br> True<br> False
    12·2 answers
  • What is the difference between a learner’s license and a driver’s license?
    12·1 answer
  • What are two methods for playing a slide show from the first slide?
    9·2 answers
  • PLZZZZZ NEED HELP!!!!!!
    5·1 answer
  • Which of the following is considered part of the process in the systems thinking example of a TPS?
    6·1 answer
  • All of the following are aspects of the search process except
    15·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    12·1 answer
  • Which of the following does not use a Graphic User Interface?
    14·1 answer
  • (e) Give the output of the following:
    15·2 answers
  • What is MS-Word? Write some versions of MS-Word.
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!