Acsl 16-17 Contest 3 Notes - Boolean Data Structures Regex Prev Boolean Graph Theory Bit String
Acsl 16-17 Contest 3 Notes - Boolean Data Structures Regex Prev Boolean Graph Theory Bit String
H ow
ACSL
Contest #3
Contest 3 Topics
Intermediate Senior
Boolean (no XOR) - 2 Boolean (inc. XOR) - 2
Data structures (no Data structures (inc.
heaps/path lengths) - 2 heaps/path len) -2
Regex (No FSA) - 1 Regex and FSAs -1
Boolean Algebra
Boolean algebra notation can be used to represent digital
electronic circuits
Uses letters and operands to represent circuit operations
* equals AND, + equals OR
To solve:
Use properties on following slide
Use order of operations: NOT; AND and NAND;
XOR and EQUIV; OR and NOR
Boolean Algebra Properties
Commutative: A+B=B+A A*B=B*A
Associative: A+(B+C)=(A+B)+C A*(B*C)=(A*B)*C
Distributive: A*(B+C)=A*B+A*C
DeMorgans
Law
Boolean Algebra Properties
DeMorgans Law
Boolean Algebra Properties
Many of these later complex properties are derived from the earlier
simpler properties
So if you dont remember these properties, you can derive them or
work out the solution using other methods
However, memorizing these will save you time and effort on the test
Boolean Algebra
Boolean Algebra
Data Structures
- Algorithms and data structures are at the heart of every
computer program
- There are four basic structures tested in ACSL:
Stacks, Queues, Binary Search Trees, and Priority Queues
Data Structures
- Stacks: (Literally think like a stack of books)
- Follows last in, first out or LIFO order
- Has two operations PUSH and POP
- PUSH(A) puts key A at top of stack
- POP(X) removes top item from stack and stores in variable X (if the
stack is empty, NIL is stored to X)
Data Structures
- Queues: Think of coin machines. Coins are added to the
top, and removed from the bottom.
- First-in, First-out or FIFO stack
- The element that was placed in first is the next one to be
retrieved
- Same set of operation names as a stack
Data Structures
- E.g. PUSH(A), PUSH(M), PUSH(E), POP(X), PUSH(R),
POP(X), PUSH(I), POP(X), POP(X), POP(X),POP(X),
PUSH(C), PUSH(A), PUSH(N)
- Stacks have pop values of E,R,I,M,A, and NIL , with three
items left in the stack N at top (next to be popped), C at
bottom
- Queues have pop values of A,M,E,R,I, and NIL , with three
elements left N at top and C at bottom (next to be popped)
Data Structures
- Binary Search Trees - These trees have nodes with two
children, a left and right node
- Property: Key is less than keys of left child and
descendants, and greater than keys of right child and
descendants
Supplement:
https://www.cheatography.com/davechild/cheat-sheets/regular-expression
s/
https://regexone.com/
FSAs
- Basically a more complicated version of regex
- Four components:
- Input alphabet (defined legal input)
- Transition rules (how to get to next state)
- Start (marked by incoming arrow)
- End (double circle)
RULES
END
START
REGEX
Regex/FSA
- Rules for reg expression (RE):
- Null string = RE
- If string A is in input alpha, its an RE
- If both strings A and B are REs, follow the
following
- Concatenation: ab = a then b
- Union: aUb = a or b
- Closure: a* = zero or more times
Regex/FSA
- Order of operations
- Closure Concatenation Union
- Star goes right to left; everything else is left to right
- Problem types:
- Convert FSA to regex
- Simplify FSA
- Create FSA/regex to accept strings
Regex/FSA
Regex/FSA
Regex/FSA
Regex/FSA
Regex/FSA
Regex/FSA
Regex/FSA