-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
510 changed files
with
12,125 additions
and
41,302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,7 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# CS10 – Intro to Computer Science | ||
|
||
{{<section>}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,7 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# CS13 – Programming Concepts and Methods II | ||
|
||
{{<section>}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,7 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# CS130 – Data Structures and Algorithms | ||
|
||
{{<section>}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# CS131 – Software Engineering | ||
|
||
{{<section>}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# CS133 – Object Oriented Computer Graphics | ||
|
||
{{<section>}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,4 +197,3 @@ Finally check if the stack is empty, step 4: | |
|
||
We can only get to the accept state if the stack is empty. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
--- | ||
title: "CS135-lecture-20210311" | ||
# date: 2021-03-11T12:36:03-08:00 | ||
draft: false | ||
bookToc: true | ||
tags: ["push-down automata"] | ||
--- | ||
|
||
## Introduction to push-down automata | ||
|
||
A push-down automata is a finite automata with memory, more than what state its currently in. | ||
It is a non-deterministic finite automata with a stack for memory. | ||
Since it is drawn very similarly to drawing finite automata, we will just notate how the stack is being manipulated on the transitions. | ||
|
||
### Drawing transitions for PDAs | ||
|
||
Each arrow has a triple: `a,b,c`, where | ||
- `a` is the char to consume from input (or {{<k>}} \lambda {{</k>}}) | ||
- `b` is the char to pop from the top of the stack, `b` is always popped when following this transition | ||
- `c` is a string to push onto the stack (from right to left) | ||
|
||
An arrow can be followed if and only if: | ||
- `a` matches next input char (or {{<k>}} \lambda {{</k>}}), and | ||
- `b` matches top of the stack | ||
|
||
Following the arrow: consumes `a`, pops `b`, pushes `c` | ||
|
||
Convention: when drawing the PDAs, {{<k>}} \emptyset {{</k>}} signifies the bottom of the stack at start. | ||
|
||
### Steps to follow when creating a PDA | ||
|
||
1. Think of a stack-based algorithm | ||
2. Try to implement the algorithm with a PDA | ||
|
||
### Example 1 | ||
|
||
The language {{<k>}} L = \{a^n b^n: n \geq 0\} {{</k>}} represents the strings {{<k>}} \{\lambda, ab, aabb, aaabbb, \ldots\} {{</k>}}. | ||
|
||
We saw earlier that we cannot represent this language using finite automata, proving it wasn't a regular language. | ||
Let's think of an algorithm to accomplish this language: | ||
|
||
1. Consume an {{<k>}} a {{</k>}} and push it onto the stack | ||
2. When we start to see {{<k>}} b {{</k>}}'s we pop an {{<k>}} a {{</k>}} | ||
|
||
We can start with the first {{<k>}} a {{</k>}} seen: | ||
|
||
![image_2021-03-11-13-26-12](/notes/image_2021-03-11-13-26-12.png) | ||
|
||
Then we can self loop for the next {{<k>}} a {{</k>}} when there is already one on the stack: | ||
|
||
![image_2021-03-11-13-27-04](/notes/image_2021-03-11-13-27-04.png) | ||
|
||
We can think of the first state as "pushing {{<k>}} a {{</k>}}'s onto the stack." | ||
After this phase we will move onto "matching {{<k>}} b {{</k>}}'s", this will be our second state. | ||
|
||
The first self loop consumes the {{<k>}} b {{</k>}}, and pops the {{<k>}} a {{</k>}}, and pushes the empty string back to the stack ({{<k>}} \lambda {{</k>}}). | ||
|
||
![image_2021-03-11-13-30-19](/notes/image_2021-03-11-13-30-19.png) | ||
|
||
The arrow transitioning from the first to the second state will be {{<k>}} b,a,\lambda {{</k>}}: | ||
|
||
![image_2021-03-11-13-32-50](/notes/image_2021-03-11-13-32-50.png) | ||
|
||
{{< hint info >}} | ||
Note: This arrow could also be labeled \\( \lambda,a,a \\) | ||
{{< /hint >}} | ||
|
||
At this point the PDA will work with all of the good strings in the language. | ||
To decide where the accept state is we need to think of what the stack should look like once the string is consumed. | ||
When we no input and the bottom of the stack, we can accept, {{<k>}} \lambda, \emptyset, \emptyset {{</k>}}: | ||
|
||
![image_2021-03-11-13-36-47](/notes/image_2021-03-11-13-36-47.png) | ||
|
||
String is accepted if and only if {{<k>}} a^n b^n {{</k>}} seen and all input is consumed. | ||
The last thing to take care of is accepting the empty string {{<k>}} \lambda {{</k>}}. | ||
To do this, we can add {{<k>}} \lambda, \emptyset, \emptyset {{</k>}} on the middle arrow: | ||
|
||
![image_2021-03-11-13-41-01](/notes/image_2021-03-11-13-41-01.png) | ||
|
||
### Example 2 | ||
|
||
Consider the language {{<k>}} L= \{w \mid w \in \{a,b\} \text{ and } w \text{ has equal number of } a \text{'s and } b \text{'s} \} {{</k>}}. | ||
|
||
To accomplish: | ||
- Use the stack to keep match of excess | ||
|
||
![image_2021-03-11-13-50-26](/notes/image_2021-03-11-13-50-26.png) | ||
|
||
Input is accepted if and only if all input is consumed with an equal amount of {{<k>}} a {{</k>}}'s and {{<k>}} b {{</k>}}'s (stack is empty). | ||
|
||
## Relative power of PDA | ||
|
||
Recall, we showed that any NFA can be expressed as a DFA, therefore they have the same expressive power. | ||
Every NFA can be turned into an equivalent PDA. | ||
|
||
Any arrow labeled {{<k>}} x {{</k>}} in a NFA can be expressed as an arrow triple {{<k>}} x, \emptyset, \emptyset {{</k>}} in a PDA. | ||
|
||
Therefore, the power a PDA has is greater than or equal to an NFA's power. | ||
|
||
PDA's can recognize {{<k>}} a^nb^n {{</k>}}, and no NFA can recognize this language. | ||
|
||
So a PDA is not equal in power to a NFA, so therefore it must mean that a PDA is greater than a NFA in expressive ability. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# CS135 – Computer Theory and Programming Languages | ||
|
||
{{<section>}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# CS137 – Computer Organization | ||
|
||
{{<section>}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
title: "CS138-lecture-20210311" | ||
# date: 2021-03-11T08:53:51-08:00 | ||
draft: false | ||
bookToc: true | ||
tags: ["UDP"] | ||
--- | ||
|
||
## UDP cont. | ||
|
||
![image_2021-03-11-09-01-20](/notes/image_2021-03-11-09-01-20.png) | ||
![image_2021-03-11-09-01-54](/notes/image_2021-03-11-09-01-54.png) | ||
![image_2021-03-11-09-02-50](/notes/image_2021-03-11-09-02-50.png) | ||
![image_2021-03-11-09-03-06](/notes/image_2021-03-11-09-03-06.png) | ||
![image_2021-03-11-09-07-34](/notes/image_2021-03-11-09-07-34.png) | ||
|
||
## Principles of reliable data transfer | ||
|
||
![image_2021-03-11-09-11-07](/notes/image_2021-03-11-09-11-07.png) | ||
![image_2021-03-11-09-12-50](/notes/image_2021-03-11-09-12-50.png) | ||
![image_2021-03-11-09-15-32](/notes/image_2021-03-11-09-15-32.png) | ||
![image_2021-03-11-09-17-24](/notes/image_2021-03-11-09-17-24.png) | ||
![image_2021-03-11-09-17-28](/notes/image_2021-03-11-09-17-28.png) | ||
|
||
{{< columns >}} | ||
Expected features | ||
- No bit errors | ||
- No loss of data | ||
|
||
<---> | ||
|
||
Problems | ||
- Bit error | ||
- Data loss | ||
|
||
<---> | ||
|
||
Solutions | ||
1. Error detection (checksum) | ||
2. Data recovery | ||
{{< /columns >}} | ||
|
||
![image_2021-03-11-09-21-00](/notes/image_2021-03-11-09-21-00.png) | ||
![image_2021-03-11-09-24-20](/notes/image_2021-03-11-09-24-20.png) | ||
|
||
So how do we do recovery? | ||
We learn from human to human conversation, *"pardon?"* to recover data loss in the conversation. | ||
|
||
Feedback: ACK for positive, NAK for negative. | ||
|
||
So the receiver will send an ACK if the packet was received without loss, otherwise it'll send NAK. | ||
Then, from the sender's perspective it will move on to the next data transmission if ACK is received from receiver. | ||
Otherwise, (NAK from receiver) it will retransmit the last data until an ACK is received. | ||
|
||
![image_2021-03-11-09-37-13](/notes/image_2021-03-11-09-37-13.png) | ||
|
||
So we have a new problem, what if ACK/NAK is corrupted on the way back? | ||
|
||
The sender has no way to find out whether the current packet was successful or not. | ||
We can allow the sender to retransmit the data, but it can cause duplicates on the receiver's side. | ||
To avoid and handle duplicates, the sender adds a sequence number to each packet, this way the receiver can discard duplicates. | ||
|
||
![image_2021-03-11-09-41-53](/notes/image_2021-03-11-09-41-53.png) | ||
|
||
We have to stop and wait, each time we only transmit one single packet. | ||
If we're only sending 1 packet at a time, when we wait until its successful each time we give it a sequence number, so we actually only need 2 different sequence numbers. | ||
|
||
pkt 0... pkt 1... pkt 0... pkt 1... etc | ||
|
||
![image_2021-03-11-09-48-26](/notes/image_2021-03-11-09-48-26.png) | ||
|
||
What if the ACK response is corrupted? | ||
|
||
![image_2021-03-11-09-50-06](/notes/image_2021-03-11-09-50-06.png) | ||
![image_2021-03-11-09-50-45](/notes/image_2021-03-11-09-50-45.png) | ||
![image_2021-03-11-09-51-34](/notes/image_2021-03-11-09-51-34.png) | ||
![image_2021-03-11-09-55-53](/notes/image_2021-03-11-09-55-53.png) | ||
|
||
If the sender receives the same ACK for the same packet, then that must mean that the last packet was corrupted during transmission. | ||
Instead of sending NAK for the current packet, it is equivalent of sending the ACK for the last packet. | ||
This tells the sender that the current packet wasn't successful, and the sender should retransmit. | ||
|
||
![image_2021-03-11-10-00-24](/notes/image_2021-03-11-10-00-24.png) | ||
|
||
NAK 1 -> ACK 0; | ||
|
||
NAK 0 -> ACK 1; | ||
|
||
If the first packet has a problem, then simply no response shows that it had a problem. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# CS138 – Computer Networking and Internet | ||
|
||
{{<section>}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# CS26 – Discrete Structures | ||
|
||
{{<section>}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# CS39 – Intro to Computer Architecture | ||
|
||
{{<section>}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# CS46 – System Programming with C | ||
|
||
{{<section>}} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# MATH100 – Applied Linear Algebra | ||
|
||
{{<section>}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ bookCollapseSection: true | |
weight: 1 | ||
--- | ||
|
||
# MATH31 – Calculus II | ||
|
||
{{<section>}} |
Oops, something went wrong.