IN C++ PLEASE You are asked to write a program that takes an arbitrary sequence of binary digits (integer values 0 and 1

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

IN C++ PLEASE You are asked to write a program that takes an arbitrary sequence of binary digits (integer values 0 and 1

Post by answerhappygod »

IN C++ PLEASE
You are asked to write a program that takes an arbitrarysequence of binary digits (integer values 0 and 1) from keyboardand stores them into a STL container vector. When receiving avalue differentfrom 0 or 1 from cin stop reading.Now, you should have a vector storing a sequence of 0’sand 1’s. After finishing the read-process, apply a "bit-stuffing"algorithm to the vector. Bit-stuffing is used by many networkand communication protocols to prevent data being interpreted ascontrol information. To avoid bit sequences in the data, whichwould erroneously be interpreted as the stop flag (here: 01111110),it is necessary to ensure that six consecutive 1’s in the data aresplit by inserting a 0 after each consecutivefive 1’s. On the receiving end, thestuffed bits must be discarded.For example: to transmit raw data:011111110111110101010 directlywon't work; transmit 0111110110111110101010… won't work either(miss inserting a 0 after the second" consecutive five 1's");but this should transmit: 01111101101111100101010…Your programshould do the following.
For example, when you execute your program the prompt shouldlike the following
Insert values 0 and 1, which are separated by a space ornewline, another value to stop input...
then if you type the digits as follows:1 1 1 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 0 3
the output should be:Original bit sequence:11100011111110111110Bit-stuffed bit sequence:1110001111101101111100Relative expansion: 10%Absolute expansion: 2 bit
(Bonus part)
After bit-unstuffing: sequences are equalPress any key to continue
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply