From the course: C# Algorithms

Unlock the full course today

Join today to access over 24,600 courses taught by industry experts.

Queue algorithms: Generate binary numbers

Queue algorithms: Generate binary numbers - C# Tutorial

From the course: C# Algorithms

Queue algorithms: Generate binary numbers

- [Instructor] While the C# standard library has a built-in queue data structure with a few basic operations, you need to know how to leverage this functionality in order to work with your data efficiently. Let's say we want to create an algorithm that takes in a number N as input. Then it would print out the first N binary numbers in numerical order. A binary number is a number that consists of ones and zeros, and is on the base-2 numeral system. These are some examples of binary numbers. We start off with 1, which maps to 1 in the binary system. 2 maps to one zero. 3 maps to one one; 4 maps to one zero zero, and so on. The algorithm we create should generate as many of these numbers as we specify. For example, if the input was 5, the algorithm would print out one, one zero, one one, one zero zero, and one O one. If the input is less than or equal to 0, the algorithm shouldn't do anything; nothing should be printed out. Now you might notice a pattern to these binary numbers. We print…

Contents