Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Computer Science 101
## Way of presenting idea
- Flowcharts
- Pseudocode
- Math Model
## Complexity
Time Complexity.
Memory Complexity
## Strategy
###Heuristics
- Greed
never come back to previous choices.
Take the best choice at each step and don't question it later.
Linked List vs Array
Linked List > Array when
- need insertions/deletions in the list to be extremely fast
- no need random, unordered access to the data
- no need insert/delete item in the middle of list
- can't evaluate the exact size of the list
Array > Linked List
- frequently need random, unordered access to the data
- extreme performace to access the items
- number of items doens't change during execution.
### Distributed Database
- enormous data. Finding a single computer with much storage space is impractical
- Database system that process several thousand queryes per second.
- Mission-critical. fault-tolerated
#### Single-Master Replication
One computer is the amster and receive all queries to the db. each
slave has a replica of the db. When the master recieve write queries, it forward them to slaves.
If the master crash, the slave machines can coordiante and elect a new master.
#### Multi-Master Replication
For massive amount of simultaneous write queries.
All computer in the cluster become masters. a load balancer is used to distribue
incoming read and write quries equallt among the machines. Each propagate write
queries among themseles and each has a copy of the entire db.
#### Sharding
Partition the DB among computers. A query router forwrds queries to the relevant one.
Problem: if a machine in the cluster fails, the part of data will be unavailable.
Sharding with Replication to rescue
#### Data Consistency in Dsitributed Database
CAP (Consistency, Availalbity, Partition)
### Computer
#### Architecture
Memory: Ram
Processor: CPU
##### Memory
Memory is devied into many cells. each cell store a tiny amount of data, and
has a numerical address. Reading or writing data in that memory is done through
operation affecting only that cell.
We transmite cell address through wires as binary numbers. each wire transmits
a binary digit. High voltage -> 1, low voltage -> 0
##### CPU
Registers: internal memory cells
cpu perform simple math operations with number stored in these registers.
cpu can also move data between ram and these registers.
The collection of all operations a CPU can do is called its instruction set.
Each operation in the instruction set is assigned a number.
Compute code is essentially a sequence of numbers representing CPU operations
These operations are stored as numbers in RAM.
We store input/output data, partial calculations, and computer code all mixed in RAM.
#### Why we can't insert PS CD into destop computer and play?
It's because of CPU architectures.
x86 is the most standard nowadays
64-bit architectue means CPU coul operate binary number of up to 64 digits in a
single machine instruction.
Emulators
the intructions are decoed by the emulator program and executed within the emulatede
machine.
### Compilers
Compiler is a program to translate our Programming languages as machine instructions
a CPU can run.
### Operating Systems
Program reply on OS to execute. because a program can then work effortlessly with
different hard-ward. Program make special system calls. Compilers translate the
IO command to system calls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.