diff --git a/cst311/lec/lec14.md b/cst311/lec/lec14.md new file mode 100644 index 0000000..9d4f08c --- /dev/null +++ b/cst311/lec/lec14.md @@ -0,0 +1,42 @@ +# lec14 + +IP Address: 32 bit identifier for a host, router interface +The interface is that part of a router that connect between a host router and the physical link. + +## Global Addresses + +3 Types of Formats for the addresses + +Type A: + +|1-bit | 7-bits | 24-bits | +|-------|-----------|-----------| +|0 | network | host | + +Typb B: + +## Subnets + +If we split the ip address into two (parts) 16-bit portions: + +* subnet - high bits +* host part - low order bits + +### Subnet mask + +usually we'll have `x.x.x.x/mask` where the mask is also some 1-byte value. + +We can determine the class of a subnet from `mask` value, hereby referred to by subnet mask. +First we split the 32-bit mask into two portions of 1's and 0's respecctively. + +Example: `255.240.0.0` = `11111111 11110000 00000000 0000000` + +In our example the split happens at offset 12, meaning our x value from before in this case is just 12. + +## Addressing: CIDR + +Classless InterDomain Routing + +This says that any address say: `a.b.c.d./x` will tell us that x is the bit offset in the subnet portion of an address. + + diff --git a/cst337/lec/lec4.md b/cst337/lec/lec4.md index 4472cc1..0868de7 100644 --- a/cst337/lec/lec4.md +++ b/cst337/lec/lec4.md @@ -1,9 +1,39 @@ # lec4 -_this page to be updated late since i just got lazy this time_ -Topics to cover: -* add/sub -* intro to overflows -* intro to carries -* translating this to some 64 bit add/sub instructions and becoming more familiar with the flags register - * eflags won't be covered indepth yet but merely mentioned for sake of preparative clarity +## Binary Addition + +Let's say we want to add the binary numbers `0b0011` and `0b1001`. + +To do this we have to consider what happens when we do `1+1`. +If we only have 1 bit of space to work with then our answer is just `0`. +In normal terms if we only have digit of space to work with 5+5 is also 0 but with a carry of 1. +Same deal in binary: `1+1=0 {Carry=1}`. + +So now we have: + +``` + 11 <-- Carry row +0011 + +1001 +---- +1100 <-- Final answer +``` +## Binary Subtraction + +Taking the problem `0011-1001` what we're actually going to do is find the 2's complement of the second number. +This will be the negative version of that number which means its equivalent to saying `0011+(-1001)`. + +So now we have basic addition but our `1001` becomes `0111`. + +``` +111 <-- carry bits +0011 + +0111 +---- +1010 <-- Final answer +``` + +Regardless of what happens we will always produce one special number alongside our result: _the carry bit_. +This is just the bit that carries out from the computation. +In both of our examples that bit would have been 0 but sometimes you'll notice that the carry is 1. +Both scenarios are valid depending on what data your adding/subtracting. diff --git a/cst363/lec/lec13.md b/cst363/lec/lec13.md index db511a1..41f84d9 100644 --- a/cst363/lec/lec13.md +++ b/cst363/lec/lec13.md @@ -7,6 +7,11 @@ Directions are on `index-structures-lab.pdf` and `ordered-indexes-lab.pdf`. ## Indexing +To create an index we do: + +``` +create index indexName on targetTable(attrs); +``` We create an index based on some field, where we sort the entries in this index table. Each entry then contains a pointer to each record in the target table. Sorting the indexes allows us to search them _much faster_ than we could ever do on disk. @@ -26,5 +31,4 @@ This means that if we have a search that lands us inside one of the gaps we stil First let's recall that ideally our data entries in some table are physically located close to each other on disk _and_, are ordered somehow. ### Dense Clustering - ### Sparser Clustering diff --git a/cst363/lec/lec14.md b/cst363/lec/lec14.md new file mode 100644 index 0000000..9166367 --- /dev/null +++ b/cst363/lec/lec14.md @@ -0,0 +1,35 @@ +# lec14 + +Let's say we have a massive dense index, so large that we can't fit it into memory. +We can use this dense index to create a sparse index off of that target dense index. +Basically we're indexing the index to reach some data on disk that is very big. + +We can of course take this even further to index and index which is indexing an index of a table. +This concept leads us to B+ Trees. + +## B+ Trees + +This type of tree here is a self-balancing tree. +This means that as we add rows our indexes the structure will adjust as necessary, meaning the indexes are updated and the pointers in the indexes are updated so that the height of the tree remains balanced. + +The leaves on the tree will _always_ have pointers to the target data which we've built a tree upon. + +### Overhead + +> found on disk or ram? + +> whats the cost for balancing the tree everytime + +## Hashing + +### Direct Indexing + +We can create some index where each entry is an index number with a pointer to that respective entry. +If we have id numbers that aren't right next to each other then we have a problem: we also have to include every intermediate values in our table. + +### Hash Function + +Now we'll have some function that takes an input[key] and generates a value[index]. +_For now we'll assume we are dealing with collisions with chaining._ + +