The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Use the Scheme Programming language ! https://en.wikipedia.org/wiki/Scheme_(programming_language)
You can (and probably should!) create helper functions.
You don’t need to do much error checking: you can assume that valid data is passed to the functions you write.
6. Write a function called (all-bit-seqs n) that returns a list of all the bit sequences of length n. The order of the sequences doesn’t matter. If n is less than 1, then return an empty list. You can assume that n is an integer.
For example:
1 ]=> (all-bit-seqs 0)
;Value: ()
1 ]=> (all-bit-seqs 1)
;Value 14: ((0) (1))
1 ]=> (all-bit-seqs 2)
;Value 15: ((0 0) (0 1) (1 0) (1 1))
1 ]=> (all-bit-seqs 3)
;Value 16: ((0 0 0) (0 0 1) (0 1 0) (0 1 1)
(1 0 0) (1 0 1) (1 1 0) (1 1 1))
Note: MIT Scheme has a special built-in syntax, and some special functions, for bit strings. Don’t use any of those for these questions!