P4-M 4/28 Binary Lesson HACKS
Learn the basics of binary including truth tables, boolean expressions, binary conversions, and binary searches.
Lesson Note Taker
Fill in the blanks below during the binary presentation. You can visit our website here!^ Due to last minute deployment issues, may need to run a local server
- git clone https://github.com/TheoH32/Runtime_Terror.git
- run:
- bundle install
- bundle exec jekyll serve
1. Binary is a base 2 number system.
2. 0 represents off and 1 represents on.
3. A bit is the minimum unit of binary information stored in a computer system.
## Boolean Expressions
1. A Boolean Expression is a logical statement that is either TRUE or FALSE and compares data.
## Truth Tables
1. The logical operations shown in truth tables are AND, OR, NOT, and XOR.
# AND
5 > 3 and 5 == 3 + 2
5 < 3 and 5 == 5
5 == 5 or 5 != 5
5 < 3 or 5 != 5
age = 18
citizen = True
if age >= 18 and citizen:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")
### Binary to Decimal
1. We can count in binary by using powers of 2.
2. In binary, we read from right to left.
3. 0111 has a value of 7.
### Binary Search
1. For a binary search, the list must be sorted.
2. In a binary search, computers start at the middle.
3. The number of steps required in a binary search follows the equation: log base 2 of the number of items in the list.
4. Binary searches also work with a list of strings. We can sort them alphabetically.
5. Binary searches can be represented in flowchart diagrams.
Hacks
You will NOT be awarded any points for sections that are INCOMPLETE
Note Taker
- Fill in all of the blanks above.
Lesson Quiz
- Complete the lesson quiz
- SCREENSHOT SCORE and paste it here (or paste screenshot with submission)
Binary Game
- Complete the Binary game and reach a minimum score of 10!
- SCREENSHOT SCORE and paste it here (or with submission)
Binary Search Questions
- Make a binary search tree of different the list [1,2,4,15,25,30,31] Answer: See tree in review ticket
- Put this list of strings in a order that can be used for binary search ["Donut”,"Cake”,"Soda”,"Banana”,"Fruit”] Answer: ["Banana", "Cake", "Donut", "Fruit", "Soda"] This order would make the most sense because it is in alphabetical order
- Explain why Binary Search is more efficient than Sequential Search. Answer: Binary Search is more efficient than Sequential Search because in Binary Search, the list is divided into two halves repeatedly until the target value is found or it is determined that the value is not in the list. On the other hand, Sequential Search checks each element of the list one by one until it either finds the target value or reaches the end of the list.
Hacks Scoring
Hack | Comments | Grade |
---|---|---|
Note Taker | fill in the blanks above | 0.1 |
Lesson Quiz | under 100% = 0.1 only | 0.2 |
Binary Game | must score at least 10 points | 0.2 |
Binary Conversions Practice | if incorrect= 0.2 awarded | 0.2 |
Binary Search Questions | if incorrect= 0.2 awarded | 0.2 |
Extra Credit | MUST SHOW WORK | 0.1 |
Total | expected= 0.9/1 | 1/1 |