Number of Bit Patterns Simulation

written by Teresa Carrigan



Top

WHAT IS IT?

This model demonstrates the different bit patterns that can be made with a fixed number of bits. This will be useful when we make truth tables (to tell us how many rows we will need), in determining the number of bits needed to address a main memory of a given size, and in the discussion of character codes.

Top

HOW IT WORKS

A random number of bits is generated, from one to ten. The first bit pattern is always that many zeroes. The bit patterns now simply count in binary, stopping with a bit pattern that is all ones.

Top

HOW TO USE IT

Click the setup button to initialize variables, then press either the go button or the step button.

The slow-motion slider is an easy way to adjust the speed of the display. Set it to zero if you want to show the final result as quickly as possible. 0.25 is a good setting for most purposes.

The step button shows the next bit pattern. It then stops so you can take notes. This is useful when you are first learning the method.

The go button shows all remaining bit patterns, at a speed determined by the slow-motion slider. This is useful when you do not need to take notes between each step, or do not wish to press the step button sixteen times to get an answer. If you want to pause the demonstration, simply click the go button a second time and it will stop after it finishes the current step. You may then click go a third time to resume.

The show-again button starts the exact same demonstration from the beginning.

The quiz button will generate a random number of digits, and ask you to determine the number of bit patterns.

Top

THINGS TO NOTICE

The number of bit patterns doubles every time we add another bit.

Top

THINGS TO TRY

Set slow-motion to 0.25, click setup, and then click go.

Click setup. Attempt one step at a time on paper, and then click the step button to check that you did that step correctly.

Top

EXTENDING THE MODEL

Allow the user to specify the number of bits.

Modify the model so that the user can specify the minimum number of bit patterns needed and the model determines the minimum number of bits needed to provide that many bit patterns.

Top

NETLOGO FEATURES

The scroll procedure asks the top row of turtles in the table to die, and then asks the rest of the turtles in the table to move one row up.

Top

RELATED MODELS

Top

CREDITS AND REFERENCES

This model was written by Teresa W. Carrigan, 2004.

Permission to use, modify or redistribute this model is hereby granted, provided that both of the following requirements are followed:

  1. this copyright notice is included.
  2. this model will not be redistributed for profit without permission from Teresa Carrigan.
Contact Teresa Carrigan for appropriate licenses for redistribution for profit.

To refer to this model in academic publications, please use: Carrigan, T. (2004). Number of Bit Patterns Simulation Blackburn College, Carlinville, IL.

In other publications, please use: Copyright 2004 by Teresa W. Carrigan. All rights reserved.

Top

FOR MORE INFORMATION

For more information about the number of bit patterns for a specific number of bits, see:
  1. Dale, N. and Lewis, J. Computer Science Illuminated, Second Edition, Jones and Bartlett, pages 57-59.
  2. Null, L. and Lobur, J. Essentials of Computer Organization and Architecture, First Edition, Jones and Bartlett, pages 154-155.


Home

Applets on this website were written by Teresa Carrigan in 2004, for use in computer science courses at Blackburn College, with the exception of the Fireworks applet. The applets made with NetLogo require Java 1.4.1 or higher to run. The applets made with NetBeans require Java 1.4.2 or higher to run. Applets might not run on Windows 95 or Mac OS 8 or 9. You may obtain the latest Java plugin from Sun's Java site.