Skip to content

Commit

Permalink
Merge pull request #837 from noahbrenner/comp-sci
Browse files Browse the repository at this point in the history
✏️ 💬CompSci: Fix code blocks, Markdown formatting, and prose
  • Loading branch information
Liz Howard authored Jun 12, 2018
2 parents 32fc2bc + dc2e958 commit 32a7b32
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ The last function, `little-o`, satisfies `f(n)<c⋅g(n)`, for every `n>=n'`. In

Which bound is defined as:
```text
F(n) is O(f(n))
g(n) is O(f(n))
and
F(n) is not Θ(f(n))
g(n) is not Θ(f(n))
```
???

Expand Down Expand Up @@ -86,15 +86,15 @@ nˆ3 >= 3nˆ2 + 10n,
true for any n >= 5
```
In this case:
```
F(n) = 3nˆ2+10n
f(n) = nˆ3
```text
f(n) = 3nˆ2 + 10n
g(n) = nˆ3
c = 1
n' = 5
```

[2:Big Theta]
Here, the following axiom is used:
```
```text
if a>=b and b>=a, then a=b.
```
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ log n = m * log 2 = m * 1 = m
We proved that the maximum number of operations is logarithmic relative to the total number of items. Does it make sense for us to say that the algorithm takes `O(log n)` time?

Yes, it does! If you were to divide 200,000 in half 17 times, you'd end up with an astonishing total of **1.5** items you would still have to compare. In other words:
```
```text
200,000 / 2 = 100,000
100,000 / 2 = 50,000
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ What is the infix equivalent notation of the reverse polish notation `4 3 + 10

---
## Quiz
### what is the result of the following expression?
### What is the result of the following expression?

Evaluate the following expression written
using the reverse polish notation (postfix notation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ A *dynamic* bookshelf would resize itself as soon as there is no more room for a
You can declare an array using:
```
//constructed arrays of size 3
//java
//Java
int[] myArray = {1,2,3};
//c++
//C++
int myArray[] = {1,2,3};
//python
//Python
from array import array
myAr = array('i', [1,2,3,4])
//javascript
myArray = array('i', [1,2,3])
//JavaScript
var myArray = [1,2,'enki'];
```
Or empty arrays of size 3:
```
//java
//Java
int[] myArray = new int[3];
//c++
//C++
int myArray[3];
//javascript
//JavaScript
var myArray = new Array(3);
```
Expand Down
2 changes: 1 addition & 1 deletion comp-sci/networking/fundamentals-i/types-of-networks.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ A `WLAN` is a type of `LAN` that uses wireless technology (nearly always Wi-Fi)
---
## Practice

Which of the following network types describes a local area network that uses **wireless** technologies to connect its devices ?
Which of the following network types describes a local area network that uses **wireless** technologies to connect its devices?

???

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The largest and most known computer network is the **Internet**. This world-wide
---
## Revision

Within a computer network, how are devices that send, route or receive data called?
Within a computer network, what do we call devices that send, route, or receive data?

???

Expand Down
2 changes: 1 addition & 1 deletion comp-sci/networking/fundamentals-ii/what-is-a-port.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ A *web server* and a *mail server* can be hosted by the same machine, but they n
While the **IP address** identifies a single machine, the combination of **IP address** and **port number** identifies a specific service running on that machine.

If you think of the IP address as the equivalent of a postcode, then the port number represents the house number
A building located at *249 Oak St.* might have a café at *249 Oak **#1***, a bookshop at *249 Oak **#2***, and a so on.
A building located at *249 Oak St.* might have a café at *249 Oak* ***#1***, a bookshop at *249 Oak* ***#2***, and a so on.

The syntax used to specify ports is `ip:port`. If our machine is located at `13.0.0.0`, we can have a *mail server* running at:
```
Expand Down
4 changes: 2 additions & 2 deletions comp-sci/networking/intro-to-http/what-are-status-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ parent: what-is-an-url

---

# What are status codes
# What are status codes?

---
## Content
Expand All @@ -50,7 +50,7 @@ The *status code* indicates whether the request has been successfully processed
---
## Practice

What first digit in the status code does imply a **successfully processed request**?
What is the first digit of the status code for a **successfully processed request**?

???

Expand Down
20 changes: 11 additions & 9 deletions comp-sci/networking/intro-to-http/what-is-an-url.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ parent: what-is-http
An URL can be broken down into several key components:
```
http://www.enki.com:80/path/res?q=x
|___| |_______________||______||___|
protocol host path query
|__| |_____________||_______||__|
protocol host path query
```

- the **protocol**, usually `http` or `https`. This part states how the data pointed at by the whole URL should be processed
- the **host** address contains a *subdomain* (`www`), a *domain* (`enki.com`) and a *port* number (`80`), usually hidden in modern browsers
- the resource **path** represents the resource's location on the server
- a **query string**, beginning with `?`, that contains different `field=value&` pairs[1] (more on this in a later insight)
- The **protocol**, usually `http` or `https`, defines how the data that is exchanged using this URL should be processed.
- The **host** address can contain a *subdomain* (`www`), a *domain* (`enki.com`) and a *port* number (`80`). In modern browsers, the port number is usually hidden when using the default port for the given protocol.
- The resource **path** generally represents the resource's location in the server's file system.
- A **query string**, beginning with `?`, contains `key=value` pairs[1]. These pairs are separated by `&` characters if there is more than one of them (more on this in a later insight).

A **URL** is not specific to the `HTTP` protocol, but is a generic and standardised way of locating resources on a network.

In fact, a **URL** is subtype of **URI** (Uniform Resource Identifier), but accompanied by a "access mechanism" or "network locator" (`http://`).
In fact, a **URL** is subtype of **URI** (Uniform Resource Identifier), but accompanied by an "access mechanism" or "network locator" (`http://`).
While all **URL**s are **URI**s, not all **URI**s are **URL**s.

---
Expand Down Expand Up @@ -82,8 +82,10 @@ The substring of an URL containing a subdomain, a domain and a port number is ca
---
## Footnotes
[1: Query string]
This is usually used for additional operations that should be done server-side: filtering, searching etc. :
The information in a query string is usually used for additional operations that are done on the server-side, such as filtering or searching:

```
www.myapp.com/users?name=John
```
Would make sense to return the users whose name is *John*.

It would make sense for the above URL to return any users with the name *John*.
2 changes: 1 addition & 1 deletion comp-sci/networking/intro-to-http/what-is-http.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ parent: test-connectivity
---
## Content

Standing for **Hypertext Transfer Protocol**, *HTTP* is an application-layer protocol that enables communication between two entities in a network.
**HTTP**, which is short for **Hypertext Transfer Protocol**, is an application-layer protocol that enables communication between two entities in a network.

**HTTP** is considered the foundation of the modern web and it works on top of *TCP/IP* communication protocol. While other ports may be used, the reserved **HTTP** port is `80`.

Expand Down
10 changes: 4 additions & 6 deletions comp-sci/networking/metrics/what-are-latency-and-ping.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,20 @@ Keep in mind that processing and decoding time of the `packet` is not taken into

To calculate **RTT**, one can use the `ping` command line utility, available on most systems, including **Windows**:

```
```bash
ping enki.com
```

A general output would be:
```
```text
64 bytes from 52.85.178.222:
icmp_seq=1 ttl=55 time=55.9 ms
64 bytes from 52.85.178.222:
icmp_seq=2 ttl=55 time=55.6 ms
64 bytes from 52.85.178.222:
icmp_seq=3 ttl=55 time=56.2 ms
icmp_seq=3 ttl=55 time=56.2 ms
```
You can see that the average time is around `55 -56` ms.
You can see that the average time is around `55-56` ms.

In the majority of cases the **ping rate** is equivalent to the **effective latency** between a device and a server, but factors such as throttling and congestion[4] might affect the results.
The terms are roughly synonymous and many games and applications report the **latency** as **ping rate**.
Expand Down
2 changes: 1 addition & 1 deletion comp-sci/networking/metrics/what-is-packet-loss.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The causes of packet loss vary, yet the most common ones are:
---
## Revision

_Packet loss_ is measured
### *Packet loss* is measured

???

Expand Down
17 changes: 9 additions & 8 deletions comp-sci/networking/requests-responses/a-request-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Content-Length: 62
```

This is a line-by-line analysis of the request header:

1. The request line states that this is a `POST` request, which targets the relative path `/api/auth/login` on the server. The request makes use of the the `HTTP/1.1` standard.
2. The `Host` contains the server's address: `enkipro.com`.
3. The `Connection` field ensures that the connection won't be closed after the first request/response exchange (which speeds up the process by not having to reconnect for each new request).
Expand All @@ -62,9 +63,9 @@ This is a line-by-line analysis of the request header:
9. `Content-Type` field tells the server the payload content's type and how to decode it.
10. Our last field in this example, `Content-length` represents the length, in octets (1 octet = 1 byte = 8 bits), of the message payload. A character requires one octet to be represented, making the value the actual length of the message.

The payload contains the data specified by the **client**. In this case, the login input fields, formatted as a *JSON* file were added. By reading the header, the server will be able to also understand the payload and return an appropriate response.
The payload contains the data specified by the **client**. In this example, the login input fields are included, formatted as a *JSON* string. By reading the header, the server will be able to understand the payload and return an appropriate response.

Most modern browsers like **Microsoft Edge** (*F12*), **Mozilla Firefox**(*CTRL/CMD + Shift + J*) or **Chrome** (*CTRL/CMD + Shift + i*) provide a Developer Console accompanied by a *Network* tab where you can take a detailed look on all requests and responses made by your browser.
Most modern browsers like **Microsoft Edge** (*F12*), **Mozilla Firefox** (*CTRL/CMD + Shift + J*) or **Chrome** (*CTRL/CMD + Shift + i*) provide a Developer Console accompanied by a *Network* tab where you can take a detailed look on all requests and responses made by your browser.

---
## Practice
Expand All @@ -82,15 +83,15 @@ The filetypes that the server should return are specified in the
---
## Revision

Within a **HTTP request**, details about the browser are contained inside the
Within an **HTTP request**, details about the browser are provided by which header field?

??? header field.
???


* User-Agent
* Accept
* Referer
* Connection
* `User-Agent`
* `Accept`
* `Referer`
* `Connection`

---
## Footnotes
Expand Down
17 changes: 9 additions & 8 deletions comp-sci/networking/requests-responses/a-response-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ parent: http-response

---

# A response example
# A Response Example

---
## Content
Expand All @@ -42,18 +42,19 @@ Server: nginx/1.10.1
Content-Length: 4117
Connection: keep-alive
[Body - 4117 characters long]
[Body - 4117 bytes long]
```

As you probably noticed, the request was successful, its **header** containing:

1. On the status line you can find the protocol version, `HTTP/1.1`, the status code, `200`, and the code description, `OK`.
2. The `*` in the `Access-Control-Allow-Origin` states that the request could be sent from any domain and the server would still respond.
3. The `Content-Encoding` header contains one of the accepted encodings, specified by the request (`gzip`).
4. Next, `Content-Type` specifies how the payload of the request is formatted. In this case, it has `JSON` format, with `utf-8` character encoding.
5. The `Date` field contains the moment in time when the response was generated.
6. `ETag` field contains the identifier for the cached object. In our case, a successful log in should return the user object.
6. The `ETag` field contains the identifier for the cached object. In our case, a successful login should return the user object.
7. You can see the server type (`nginx`) and its version (`1.10.1`) under the `Server` header.
8. As you may already figured out, the `Content-Length` represents the number of characters in the response's payload. Because the whole user object is returned, the data is not negligible.
8. `Content-Length` specifies the number of bytes in the response's payload. For uncompressed data, this usually corresponds to the number of characters, as long as they're all in the ASCII range. Because the whole user object is returned, the data is not negligible in this example.
9. The `Connection` field says that neither the server nor the client should close the connection.

In addition, the **payload** or **message body** can also present in this response. In this scenario, a `JSON` object was returned by the *server*, containing various user information.
Expand Down Expand Up @@ -81,8 +82,8 @@ Which of the following **HTTP response** header fields specifies the format of t
???


* Content-Type
* Content-Encoding
* Content-Length
* Content-Format
* `Content-Type`
* `Content-Encoding`
* `Content-Length`
* `Content-Format`

2 changes: 1 addition & 1 deletion comp-sci/networking/requests-responses/http-pipelining.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ parent: a-response-example

---

# Http pipelining
# HTTP pipelining

---
## Content
Expand Down

0 comments on commit 32a7b32

Please sign in to comment.