课程: Java Algorithms
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Queue algorithms: Generate binary numbers
- [Instructor] While the Java standard library has a built-in queue data structure with a few basic operations, you'll 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 and prints out the first N binary numbers in numerical order. A binary number is a number that consists of ones and zeros and it's on the base-2 numeral system. These are some examples of binary numbers. We start off with one which maps to one in the binary system. Two maps to one zero. Three maps to one one and so on. The algorithm we create should generate as many of these numbers as we specify. If the input was five, the algorithm should print out one, one zero, one one, one zero zero and one zero one. If the input is less than or equal to zero, the algorithm should print out nothing. Now you might notice a pattern to these binary numbers. We print an item, in this case one, and then print the same item with…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
(已锁定)
What is a queue?1 分钟 53 秒
-
(已锁定)
Standard queue operations in Java3 分钟 38 秒
-
(已锁定)
Queue algorithms: Generate binary numbers4 分钟 41 秒
-
(已锁定)
What is a stack?1 分钟 58 秒
-
(已锁定)
Basic stack operations in Java3 分钟 32 秒
-
(已锁定)
Stack algorithms: Theorizing an algorithm5 分钟 21 秒
-
(已锁定)
Stack algorithms: Next greater element3 分钟 57 秒
-
(已锁定)
Stack algorithms: Matching parentheses4 分钟 49 秒
-
(已锁定)
Solution: Evaluate reverse polish notation4 分钟 16 秒
-
(已锁定)
-
-
-