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 - 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
What is a queue?2m
-
(Locked)
Standard queue operations in C#4m 24s
-
(Locked)
Queue algorithms: Generate binary numbers5m 21s
-
(Locked)
What is a stack?1m 56s
-
(Locked)
Basic stack operations in C#4m 23s
-
(Locked)
Stack algorithms: Theorizing an algorithm5m 5s
-
(Locked)
Stack algorithms: Implementing next greater element4m 41s
-
(Locked)
Stack algorithms: Matching parentheses6m 1s
-
(Locked)
Solution: evaluate reverse polish notation4m 27s
-
-
-
-