Midterms Flashcards
what monoalphabetic cipher do computers use?
ASCII
American Standard Code for Info Interchange
in ASCII, how many bytes is in 1 character?
1 byte
how many bits in 1 byte?
8 bits of 1’s or 0’s
how many diff things can 1 byte represent?
max byte is 1111 1111 = 255 + “zero” = 256 possibilities (2^8)
is ASCII enough?
for English, yes but for Chinese (>10,000 characters), Syrillic, Japanese, Korean, etc. not enough
how to create more possibilities for each character?
add more bytes
how many possibilites does 2 bytes have?
2 bytes = 16 bits
2^16 = 65,536 possibilities (1111 1111 1111 1111 + “zero”)
what code do modern documents use?
Unicode
how many bytes for each character does Unicode have?
4 bytes = 32 bits
2^32 = around 4 billion possibilities (theory)
2^31 (reality)
bit map
black & white representation of something using bits as pixels
megabyte
1 million bytes
how can a large pic be more than 1 million bytes?
color, brightness, hue, etc.
how do u add color into a picture?
1 pixel = 3 bytes and each byte represents a primary color (red, green, blue)
in each byte, there are 256 possibilities of red, green, & blue which u can mix to create a wide array of colors
how come the primary colors in comp’s r diff than normal primary colors?
comp’s use light instead of paint
megapixel
1 million pixels
pixel
3 bytes
how many megabytes r in 1 megapixel?
3 million megabytes
what r the dimensions of a 1 MP square pic? a 2 MP pic? a 4 MP pic? 10 MP? 11 MP?
1,000 x 1,000, 1400x1400, 2000x2000, 3000x3000, 3300x3300
square root of how many pixels thr r in the pic
diminishing returns
the more MP’s we have, the less they “count” as
boolean logic
system for computers to make decisions
used in microchip design
gate
a single, physical design-making unit represented by diagrams/pic
OR gate
A + B
true when @ least one is true

AND gate
AB; true when both r true

NOT gate
reverses
’

order of operations
()
’
x
+
NAND
AB’
not and

NOR
(A + B)’
not or

XOR
X (plus sign w/ circle around) B
either A/B is on, but NOT both

A + 0
A
A + 1
1
A + A
A
A + A’
1
0A
0
1A
A
AA
A
AA’
0
A + AB
A
A + A’B
A + B
DeMorgan’s Law
(A + B)’ = A’B’
(AB)’ = A’ + B’
sum of products
for every row that = 1, add a term to the expression.
’ if 0. product.
product of sums
for each line in the truth table that = 0, multiply by another term
’ if 1
sum
only use if one or two 0’s
server
a computer tht knows how to send messages to other computers
packets
small pieces of info passed b/w comp’s
addresses
’s tht uniquely identify a comp on the network
protocol
rules governing the transfer of info b/w comp’s
what r servers connected by?
telephone poles & wires on land
cables under sea
TCP/IP
Transmission Control Protocol
Internet Protocol
rules & instructions on how 2 send info over the internet
IP address
each device has one
4 #’s, each b/w 0-255 (cuz 4 bytes)
Ex: 128.244.50.1
DNS
Domain Name System/Service/Server
an Internet serivce tht translates domain names into IP addresses
how many possible IP addresses? enough?
abt 4 billion. no
IPv6
6 bytes
abt 281 trillion possibilities
man-in-the-middle attack
network packets r easily intercepted & changed
rogue server could manipulate communications b/w 2 individuals or just gather info
solution to maninmiddle attack
trust - only phone companies & qualified individuals allowed to operate major internet servers
cryptography to encode info
Dictionary Attack/Brute-Force Attack
a comp can try 1000’s of word/letter combos per second to guess ur password
bad & good passwords
bad = only words
good = 12+ random letters & symbols
phishing
type of social engineering
when an email and/or website pretends to be someone else & tries to get u to type in ur password & send it to them
social engineering
security attacks that prey on human psychology
malware
programs tht do bad things 2 ur comp/device
Ex: erase files, steal info, take pics w/ ur webcam, etc
virus
most common type of malware
most comp’s come w/ anti-virus software now
because a virus is a program, user must download & run it somehow - might be disguised as game/vid
some take advantage of vulnerabilities in computer systems (Ex: memory stick that automatically runs when u plug it into a comp)
must be created for specific operating systems
other types of malware
trojans, worms, spyware, rootkits, crimeware, zombie comp, botnet, pharming, Van Eck phreaking
input device
anything tht lets u interact w/ the PC
Ex: heyboard, mouse, microphone
output device
anything tht the PC uses to show u what u did
Ex: monitor/display, printer, speakers
peripheral
anything connected to the comp, but not inside the case
Ex: keyboard, monitor, printer
storage devices
anything that stores info for the computer
a place to put all those 1s and 0s
capacity measured in megabytes
Ex: hard disk drive, optical disc drive, USB flash drive/memory stick

hard disk drive
stores info for a comp using a series of magnetic plates
a magnetic arm can read & write the info on the plates, while the plates spin.
don’t put magnet close to one
could die out of box/last a decade
predicting failure = difficult
modern capacity = 250GB-2TB
optical disc drive
bounces a laser beam off the shiny surface of a disc to read it
the reflective surface actually has microscopic pits & grooves in it to store bits

diff b/w CD’s, DVD’s, & Blu-Ray
ability to fit more pits & grooves into less space using smaller wavelength lasers
rainow - red light > green light > blue light; each wavelength = size of each hole
Random Access Memory (RAM)
fast, temporary storage tht the PC uses for what it’s doing @ that moment
comes in “sticks”
capacity of 1 stick = 1-4GB
Ex: opening docs, running programs, mouse pointer location

expansion cards
add some kind of functionality to a PC
getting rarer, since lots of functions(network, graphics, sound) r built in2 motherboards now

on-board
built into the motherboard
network card
allows a PC to go on a network
graphics card
processes graphical info (usually 3D) for the PC
Power Supply Unit (PSU)
provides power to the internal components of the computer
diff things might require diff types of connection
PSU’s also have wattages - some things might require more watts than others

Central Processing Unit (CPU)
the part tht actually performs the instructions & calculations given by the programs
connected to all the other parts of the computer via the bus on the motherboard

motherboard (mobo)
connects everything together and lets the other parts communicate
lots of diff places for plugging things in: slots, ports, sockets, connectors
form factors
diff sizes of motherboard
bus
physical connections (wires) & protocols that allow devices to communicate on the motherboard
software
the instructions for the omputer
tells the CPU what to calculate
tells the other hardware what to do
operating system (OS)
the most basic level of software
handles the low-level hardware instructions
- translating the signals from the mouse into actual cursor movements
- displaying pixels on screen
- reading & writing from a hard drive
provides an environment for other software to work
common OS’s = Microsoft Windows, Mac OSX, Linux
software for one OS won’t work on another
drivers
instructions for the OS to use other devices
special additions to an OS that lets it use new hardware (usually comes w/ CD or something to install the driver)
Ex: an OS might not know how to use a printer until it has the right driver for it
program
software that a user interacts with, that lets u do something
Ex: Microsoft Word, Mozilla Firefox
how OS’s, programs, & drivers all work together
BIOS
Basic Input/Output System
software built into the motherboard that runs when a PC is booting
most important thing it does = decide what storage device to use to finish booting (loading OS) - will typically use hard drive, but can load an OS from ANY storage device
-a CD, DVD, or memory stick
can access by pressing Delete, F1, F2, or F10 while PC is loading (keep tapping)
bootstrapping/booting up
describes a computer when it is just turned on
command line/shell
early comp’s didn’t have graphics - if u wanted to do anything u would have to type commands for the comp to do
still used today
someone proficient w/ the command line can navigate the comp & do some complex tasks more efficiently
prompt
a sequence of characters that the shell uses to inform u that it’s ready for a command
path
the folder/directory u r in
switch/option
Ex: /w
changes the behavior of the command
can have 1+ switch
read & write
the words used to refer to getting data from a storage device & putting data on a storage device
Van Eck phreaking
the process of eavesdropping on the contents of a CRT or LCD display by detecting its electromagnetic emissions
how does software work?
u boot the PC & it starts reading instructions from the storage device
the bytes r interpreted as intructions by the PC
the instructions = software –> created thru the process of programming
programming
giving sequential instructions to a comp. system
done using a programming language
programming language
turned into instructions for a CPU by a compiler
series of rules that u follow to write English-like text representing abstract instructions
Ex: Java
compiler
a translator from the programming language instructions to the byte instructions used by the CPU
programming constructs
many programming languages have similar capabilities
Integrated Development Environment (IDE)
something like BlueJ tht combines a text editor with a compiler
code
the text of a program
Java’s naming rules
starts with a letter
can contain letters, #’s, $, and _
no spaces
case sensitive
sample print statement
public class CompSci {
public static void main (String [] args) { System.out.println("Hello World!"); }
}
whitespace
spaces, tabs, etc.
values & types
Java & all other programming languages have diff types of info
Ex: strings, integers, doubles, and Booleans
strings
“string”
must have quotation marks
String
integers
whole #’s w/ no decimal point
weird math
int
Booleans
only 2 values; true and false
in Java, the words true and false (lowercase) r reserved for Boolean values
boolean
operators
the symbols tht we use to perform calculations on diff values
arithmetic operators
+, -, *, /, %
parenthesis used same as in math
concatenation/catting
if u “add” anything to a string, it will stick the value onto the string
must be adding
Ex: “Hello” + “werld” = “Hellowerld”
50 + “8” = “508”
“Zooba” + 0.5 * 3 = “Zoobah1.5”
integer division
when 2 integers r divided, the result is always an integer
Java will not round - will simply cut off
Ex: 6/4 = 1
2/3 = 0
if either of the values being divided is a double, then Java will do normal division
Ex: 1/5.0 = 0.2
Modulus Division
only works on integers
gives remainder of 1st # divided by the 2nd #
Ex: 6 % 4 = 1R2 = 2
12 % 3 = 4R0 = 0
If the 1st # is less than the 2nd #, then the answer is always just the 1st #
Ex: 3%4 = 3
integers
doubles/floating-point values
’s w/ decimal points
real #’s
double
variables
names containers for values
fundamental tool for programming
must be declared
variable declarations
statements, so must end in semicolons
int blah;
double aVariable;
String porty;
int ting, roo;
assignments/statements
putting a value into a variable for storage
blah = 10;
aVariable = 0.6;
porty = “Teapot”;
ting = 10/5;
roo = blah / ting; can use other variables in math expressions & assignment statements
combining declarations & assignments
int abc = 12, def = 801;
double xys = 10.5;
String ijk = “pointy hat”;
self assignments
can use a variable on the right hand side of its own assignment
int fumu = 10;
fumu = fumu + 3;
fumu = fumu - 5;
type mismatch
when variables r assigned values tht don’t match their type
int abc = 10.0;
double def = 3; this works tho cuz Java can turn integers into doubles when necessary
name conflict
w/in a Java program, no 2 variables can be declared w/ the same name, even if they r diff types
int neato;
String neato;
import
brings in a class from Java’s class library, a large # of classes & methods written by the ppl who made Java, 2 help ppl use Java
javax.swing.JOptionPane
a collection of useful methods tht can pop up diff windows 2 do stuff
showInputDialog
a method inside of JOptionPane
pops up a window that lets the user type a string
will then assign the string that was typed to the variable on the left side of the =
only works for Strings
Ex: String zin = JOptionPane.showInputDialog(“Type something!”);
Integer.parseInt
Double.parseDouble
takes any String in the parenthesis & tries to turn it into an integer/double
condition
an expression tht compares 2 values & gives a Boolean result (true/false)
5 > 12 (true)
3 > 7 (false)
6 >= 6 (true)
conditional operators
< less than
> greater than
<= less than/equal to
>= greater than/equal to
== equal to
!= not equal to
don’t work w/ strings
.equals()
bah.equal(wip) would give true if both bah & wip r the same string
works for strings
if
if (a
System.out.println("blah");
}
if the condition inside () is true, then Java will do the code inside the curly braces - otherwise, skips it
else
if (a < b) {
System.out.println("blah");
} else {
a = a + 10;
}
if the condition turns out to be false, the code inside the curly braces after the else keyword will be done
else if
if (a < b) {
a = a - 5;
} else if (b > c) {
b = b + 0
}
if 1st condition is false but 2nd is true, will do 2nd code
if 1st is true, then will do 1st code & skip else if
if-else chains
u can put if, lots of else ifs, & an else together in a “chain” of conditions
can have as many else ifs as u want, but only one if @ beginning and one else @ end
Java will work its way down the “chain” & do the code inside the curly braces for the 1st condition which = true
exclusive, so will only actually do the code b/w the 1 set of curly braces
branching
refers to the ability of the program to do diff things under diff conditions
Boolean operators
&& and
|| not
! not
used only with conditions
boolean order of operations
AND always before OR unless parenthesis
math operators ALWAYS take precedence over Boolean operators
(x - 5 < 2) will do x - 5 first
loops
allow a chunk of code to be repeated over & over, depending on a condition
while
int x;
x = 0;
while(x < 10) {
System.out.println("Hellow World!"); x++;
}
will repeat everything inside the curly braces of the loop as long as the condition inside the parenthesis is true
x++
short for x = x + 1
incrementing
adding 1 to the value stored in the variable
increment operator
++ in x++
for
almost identical to while, but syntax diff
public class TheCount
{
public static void main(String [] args); { for(int count = 1; count \<= 100; count++) { System.out.println(count + "! A-HA-HA!"); } }
}
for(initilization; condition; statement)
initialization
the initialization section of a “for” loop is done only 1 time before the loop starts
most programmers use this section to declare their counting variable & set u its starting value
counting variable/count
integer
set to a starting #
sentinel loop
waits for a condition to be true before stopping but doesn’t involve a looping variable
waiting for user to type something before it exits
\n
new line
cipher
(code)
to convert #’s to symbols
bitmap
a series of bits that represent pixels
binary → decimal
mutliply each bit by its place value & add
Example: 1001
1*1 + 1*8 = 9
binary place values
256 128 64 32 16 8 4 2 1
Hex Digits
0123456789ABCDEF
1 digit = 4 bits
works cuz 16 = power of 2
have h after
256 16 1
octal digits
use digits 0-7
preceded by oct
512 64 8 1
hex → decimal
Base 16 place values
Ex: 1B9
1*256 + 11*16 + 1*9 = 441
hex → binary
memory tip: last 3 #’s for both columns are the same
Ex: F5 1111+010=11110101
binary→hex
divide into groups of four bits from right to left
Ex: 1011101 = 0101+1101 = 5D
decimal→whatev
find the highest digit that can “fit” into the decimal #, then subtract from the original #
Division Remainder Method:
take ur #, divide by 2 for binary, 8 for octal, 16 for hex
the remainder of the division is a digit in ur answer
repeat process using the quotient, until the quotient is zero
put the remainders back together backwards for ur answer
binary addition
similar to addition of large decimal #’s
“carry” when a # gets too large for a single digit
change into decimal, add, change back to binary
for big #’s, put one over the another & add one by one
overflow error
the answer is more than 1 byte larger
a comp typically will drop the extra bit on the left
sometimes unpredicatble/undefined
why overflow happens
a comp’s processor stores info in something called a register
if a processor does a calculation & the answer exceeds the capacity of the register, then the extra bits r dropped
register
have a limited space - can only store a certain # of bits
twos complement
a binary digit “place value” could be negative
in this class, we’ll assume that 128 is negative (-128)
new range of #’s = -128 to 127
unsigned
a “normal” binary # (1111 1111 = 255)
binary subtraction
change second # into twos complement, then add normally