AVL Tree
X: Height with difference >1
R: Root of higher subtree
Case 1: BF ( X) = BF (R)
Procedure: Rotate R to X
Update BFs
Case 2: BF(X) and BF(R) have opposite BFs.
Procedure: Let Q be higher subtree of R
Rotate Q to R
Rotate Q to X
Update BFs
Hash Table
Keys: set of values to be hashed into table
Hash Function: (key value) % (table size)
Chaining:
Unordered: Insertion worst case: O(n)
A single key is O(1), so if there are n keys, inserting all keys is O(n)
Ordered: Insertion worst case is O(n^
Huffman Coding
Operates based on frequency.
Characters have a code(eg 001) and frequency (eg 12).
Total #Bits = Bit length * frequency (eg 3 * 12)
Tree: Left branch = 0, Right branch = 1.
Algorithm:
Take 2 lowest and make tree.
Compare next char with tree
Graphs
Edge
Vertex
Directed
Undirected (Symmetric): Space utilization / 2
Edge Weights: -1 for empty
Space Utilization: Sparser or Denser
Relationship between # edges:
Undirected: N vertices has N(N-1)/2 Max Possible Edges
Directed: N vertices has N(N-1)
Big O (BST, AVL, Huffman, Hash)
BST
Insert, Search, Delete
Average = O(log(n)
Worst = O(n)
Insertion:
0 for first item
2 for second item (=, >) or 2*each node in level
4 for third level or 4*each node in level
etc.
Search:
Worst Case Successful search:
1
SQL: Interactive Queries (1)
John Ortiz
Basic Select Statement
Basic form of the select statement:
select target-attribute-list
from
table-list
where conditions;
Correspondence to relational algebra:
select-clause projection ()
from-clause Cartesian pro
Sorting Algorithms
Merge Sort(not in place):
Time complexity O(nlogn)
Recursively divides a list of n elements by 2, into logn levels
At each level i, the list is divided into 2^i sublists
At each level, there is n/2 comparisons
Length of sublist * #subli
String Methods
Method
var.length()
Description
# of chars in string
var.charAt(int)
char at specified index
var.indexOf(char)
position of first char
occurrence
position of first string
occurrence
position of first char
occurrence starting from
the int fro
1. Which speech "delivery method" (p.208) discussed in Chapter 15 do you think you prefer
the most? Please explain why.
I one hundred percent prefer the extemporaneous delivery as I would never feel
comfortable being asked to speak in front of a number of
1
What is one example of when someone has presented a "process speech" to you? Was it
effective? Why or why not?
A couple years back I use to watch cooking shows. They were effective as I always took
away good cooking tips and was able to go from not know
1. After reading Chapter 11, you should have a decent understanding of "audience
analysis". With this in mind, what is one example of where audience analysis (i.e.,
knowing more about your audience, clients, customers, etc) might help you engage in
more e
1. How do you think improving your public speaking skills could benefit you in your
professional and/or personal life?
While I do not have a professional life at the moment I do believe and hope that by
improving my public speaking skills I will in turn n
save the bees
intro q: by asking a question they can all relate to and are able to answer.
INTRO THESIS: I'd like to share with you the alarming percentage of bees we lost in 2015-2016,
what's causing these numbers, and what we can do at home in order to
Homework 1 (Programming)
1) Numerical information, graphical information, textual information.
2) CPU controls and coordinates all the computer operations. It also
performs logical and arithmetic operations on data.
3) Input devices: a) keyboard b) mouse
CS Homework 2
1) Comments can be placed anywhere on a program and are divided into two
parts, single line comments and block comments.
Single line comments always start with double slash (/). Block comments
always start with slash-star and ends with star-
CS 1057-003
Assignment 2 Questions:
1. What were the five mistakes in program one?
[]
printf("end=0, ", ended),
printf( "start=0.\n", started );
end
started.
2. What were the five mistakes in program two?
Line 21: ')' before ';' token
Line 23: ';' before
Normal Language Acquisition
Katharyn Bannar
Study Guide for Exam 1
Chapter 1
Define language
The systematic and conventional use of sounds (or signs or written symbols) for
the purpose of communication or self-expression. Language is complex and
multiface
The run time of this algorithm is given by the recursive equation
Given a sequence
X = <x1, x2, ., xn>
a sequence of length k
Z = <z1, z2, ., zk>
is a subsequence if there exists a strictly increasing set of indicies <i1, i2, ., ik> such
that
In other wor
The question now is how do we construct a hashing function that satisfies the desired
property of simple uniform hashing? The answer to this question is usually dependent
on the distribution of the keys (which for a limited number can simply be a lookup
t
Directed Graph (digraph)
In a directed graph, the edges are represented by ordered pairs of vertices (u, v) and
shown diagramatically as directed arrows (a vertex may be connected to itself via
a self-loop).
An edge (u, v) is incident from (i.e. leaves) u
Chain Operations
INSERT(T, x) - place new element x at the head of list h(k) - O(1) assuming element is
not in list, otherwise need to search list
DELETE(T, x) - delete element x from list at T(h[x.key]) - O(1) since x would contain
pointers to the next a
Birthday Paradox
Another interesting problem that can be solved with indicator random variables is the
well known birthday paradox problem. The problem is - "How many people do you
need in a room to have at least 2 with the same birthday?" (We assume that
Step 1: Characterize optimality
Without loss of generality, we will assume that the a's are sorted in non-decreasing
order of finishing times, i.e. f1 f2 . fn.
Define the set Sij
Sij = cfw_ak S : fi sk < fk sj
as the subset of activities that can occur be
Hiring Problem
Consider that you are in charge of hiring and are looking to fill an office position. The
prospective candidates are sent by an employment agency and are assumed to be
numbered 1.n. Your hiring strategy is to interview each candidate and hi
Let us first formalize the problem by assuming that a piece of length i has price pi. If
the optimal solution cuts the rod into k pieces of lengths i1, i2, . , ik, such
that n = i1 + i2 + . + ik, then the revenue for a rod of length n is
Therefore the opt