Friday, November 23, 2007

os exam revision notes

Scheduling
SJF
SRTF(preemptive SJF)
-must know burst time first
-starvation for longer process

FCFS
RR
Multi-level feedback queue

Critical Section Problem
global turn
-no progess w strict alternation

local flag
-i/o => deadlock

flag + turn
-only works for 2 process

bakery algo
-get ticket of (max + 1)
-run if no one getting ticket and <= to all

Deadlock
Mutex. Hold-Wait. No-preempt. Circular wait

Banker algo.
-needs and resources
-find exec state run all => safe state

Paging
EAT = (A + B)p + (2A + B)(1-p)
A - PT
B - TLB
p - TLB Hit %


Disk Allocation
Contig
+Random Access
-Small file

Linked
-Sequential
+Large file

Indexed
-Sequential
+large file

Max. Disk File
Inode (Add all to find max file size)
-direct = blockSize
-Single indirect = (blockSize/pter size) blockSize
-Mulitple indirect = (blockSize/pter size) (blockSize/pter size) blockSize

Wednesday, November 21, 2007

database revision notes

Cost of Joins

Direct = A + B
[Needs suff memory]

Nested Loop = A + AB
with Buffer = A + Math.ceil(A/Buf-2)*B

Simple Loop = A + RecB [ XindexA + SelCardA ]
[index req]
XindexA : cost to access index
SelCardA = #tuple/#satisfy for A

Merge-Sort = 2A + 2A Math.ceil(log[deg]A) + 2B +2B Math.ceil(log[deg]B) + A + B
[A + B is the cost to join if they are already sorted]

Cost of write back(size of result)
Join Selectivity not known / No PK

JS = 1 / MAX(DistinctValueA, DistinctValueB)

Sz of join = Math.ceil(JS*RecA*RecB/bfr[size of joined tuple])

Minimal cover

1) All RHS only got 1 field
2) Remove each rule and check if can get it back w/o it

B+ tree
B = Block size // fit the nodes into a block
V = sz of key
D = sz of data pointer
P = sz of internal pointers[within node in tree]
p = no. of nodes in a block
Psp = sz of pointer for leaf node pointing to next leaf node(linked list)

Non-leaf node : pP + (p-1)V <= B
Leaf node : p[leaf] (V+D) + Psp <= B

NF
2NF
-no partial dependencies

3NF
-no transitive

BCNF
-Determinant is superkey

Equivalence
a = {A->C, AC->D}
b = {A->CD}

from a, {A}+ -> {ACD} covered {A->CD}
from b, {A}+ -> {ACD} covered {A->C}, {AC->D}
therefore, proven

DB Recovery
Immediate (Undo-Redo) / Defered Updates (Redo)

1) Find last checkpoint
2) 2 lists
-Committed Transaction
-Uncommitted Transaction
[ For Immediate Only
2b)
Analyze dependencies for any cascading and put affected commited to uncommited
-Undo UNCommitted
]
3) Redo commited
4) Restart uncommited

SQL optimise
Cartesian Product
Push select down and restrictive select first
Replace Cartesian Product with join
Push Project down

DB Security
1) Create View
2) Grant [*|select,...] on [table] to [user] [with Grant option]

Tuesday, November 20, 2007

db exam sql

select dest from flight f where not exists
(select LID from airline
except
select lid from flight where dest = f.dest)

select lid from flight group by lid having count(*) >
(select count(*) from flight f, airline a where f.lid = a.lid and name='Lion')

select top 1 aid from airport where aid not in
(select aid from locates l, airline a where l.lid = a.lid and name = 'Lion')
group by aid order by count(*) desc

Wednesday, November 14, 2007

HS811 Crime final review

Becarria / Classical Criminology
Social ecology / area of studies (Consensus)
Merton (anomie / strain) (CS)
Matza
Becker, Chambliss, Cohen, Goffman (interactionist)
Problem of official studies
Sutherland - White collar (CS)
Conflict studies - eg Chambliss, Kolko, Hall (Conflict)
Studies abt woman, including Messerschmidt (INT)
Right Realism - target hardening, ....
Left Realism (Use most of the above theories) [Sq of crime]
Police & Prison

-------------------------------------------------

Essay
-Org
-Start, end pt[Conclusion]

-------------------------------------------------

Overview
Classical Criminology
What give the rights to punish? Equal rights of rational men

Key idea: “rule of law”; justice (equally fair to all – blind to status differences of people, and other differences)

BUT unfortunately we continue unequal in property, etc, so we cannot fully practice the principles

Positivists
What causes criminals? comparing criminals with non-criminals
Control groups may not be valid control groups

Lombroso – born morally inferior.
Sheldon - born aggressive, impulsive, blithely (happily) unconcerned.
Eysenck – born unconditionable.
McCords and Gluecks – are unloved and unsupervised.
Shaw and McKay – are living in an area of mixed values and some criminals living there that one mixes with & can learn from.

Merton
What factors within American society (at structural level) cause criminals?

Strong materialistic values/success, plus structured lack of real opportunities of materialistic success

Sutherland
But, why do we not notice much of the criminality? done at work and it is done by high status people
Other high status people don’t like to send their sort of people into the criminal courts or into prison.
However, it is still done because of mixing with other people who do it.

Interactionists (labeling theory)
asking the wrong questions
“Crimes” and “criminals” are not “definite things”.
Criminals don’t come before crime, they come a long, long time after the first actions that are interpreted as crime.
And actions can only be “interpreted” as crimes if someone makes a law first.

what would-be law makers, & what law enforcers do?
=crusades to make laws, or unmake laws.
=panics about behavior and stop-and-search people ….
=label people

Marxists to Interactionists "Capitalist society”

Feminists: socially constructed “male-ness”

Right Realists: Practical changes instead of theories

Left Realists
Taking account first of those who suffer from the situation most.
And using a square as a way to organize it.”

Post-Modernists: “No ultimate truth"

Past year paper
a)Sutherland White Collar Crime. [how, why impt?]
b)Relevant in SG

1) S defined WCC ... He included ...
2) His studies ... huge amount, unrecorded
3) Impt because middle/high status crime ignored ...
4) but he put together some crimes that may be different ….
5/6) In Singapore,...

Merton vs Conflict
1. Merton focussed on and explaining crime, Conflict theory analysis whole society, crime just small element// or both analyse structures and connection to crime but focussed on individuals who commit crime // or …
[... vs Sub/super structure]
2, 3 Merton theory – [Zone in transition - mixed values, rundown, not well-off to move away, immigrant]
4, 5. Conflict theory –
6. Final summary point, or new point

Square of Crime
1. LR, (L Idealists, R Realists) ..
2. Square of crime – four parts, draw and label it.
3, 4, 5, 6. Look at one “corner” each. Refer to theories that are utilised. E.g. State and social control – Conflict theory, and interactionist theory. Work on prisons, etc.
7. Own view if LR is fully comprehensive. Is anything left out?

Tuesday, October 30, 2007

csc206 security

Security

1)Discernationry

a)Authorisation (GRANT select,..ON table TO .) [Value-independent]

b)Views (CREATE VIEW name as ... )[Value-dependent]
-updating is problematic


2)Mandatory Access Control
-Practical for Mulit-lvl security
-Classification of object
-Group User
ie clearance lvl Unclassified, Confidential, Secret
-Can Read lower only (null if cannot see)
-Can Write higher only

Each tuple with own classification (TC) [match this first then attribute]
Each attribute with Classification (C) clearance

3)Statistical DB security
-no personal info

Monday, October 29, 2007

csc184 exam

no business plan
past yr *different* focus

styles
-explain understanding of ... and ref to that model ...
-agree w ...? explain with ref to ...

Wk 1 & 2
Factors impact business (PESTE)
Srcs of competitive advantage (CA) of firm
resources that deliver CA (tangible, intangible, org capabilities)
sustainability of CA (valuable, rare, hard-to-copy, non-sustainable)

Wk 3
Basic functions of mgmt
mangerial roles (plan, org, lead, ...)
manager skill
fundamental changes facing manager (make flatter, organic, flexible w dealing HR)


Wk 4
What is corporate culture?
Foster ethnics @ work
Barrier dealing w diversity and how to manage them

Wk 5 (****)
Basic HR process [plan -> evaluate, compensation]
Recruitment and selection
Interview & other ways of employee selection ****
compensation

Wk 6
What are learning org (more organic)
Abolish org boundaries
Delegation

Wk 7
Group Dynamic : norms & cohesiveness
Self-directed work team
Symptons of unproductive team & how to improve team perfomance
how leaders create self-managing team
org context that support teams ****

Wk 8
Needs-based [Maslow, Herzberg 2-factor]
Process-based [Equity, expectancy theory]
10 methods to motivate employee

csc205 security

threat -potential security violation
attack -attempt to breach

accidental/malicious
unauth read, write, delete

4 levels
physical
human
network
os

types of attack
interrupt [block]
intercept [read]
modify [change]
fabricate [fake as sender]

program threat
trapdoor [hole put by designer for himself]
worms [standalone program spawns itself]
trojan horse

csc205 os protection

Domain - {user-id}
least rights needed

1) unix
rws owner ... filename (s -> setid)
s on -> when file run, change domain to owner
s off -> when file run, change domain to executer

2) multics (rings)
Domains i < j -> i more priority (smaller more permissions)

Abstract Model) AccessMatrix

object1, o2, o3
domain1 rw , ,
d2 r , ,
d3 , ro , read*,exe

process in d1 can only run op inside matrix on object i
ie d1 can read, write object1 but cannot touch o2, o3

o -> owner (can add/remove right on object)
ie owner of o2 can add rw to d2 on o2

read* -> copy operation to other domain on same object
ie d3 can copy read, exe to d1 (no *)

extended access matrix
o1 o2 | d1 d2
d1 r switch
d2 w control

switch -> allow switch to another domain
ie d1 can switch to d2 but d2 cannot switch to other

control -> modify(add/remove) rights in a row
ie d2 can change the rights of d1 (ie add write to d1,o1)
but d1 cannot change d2

Implementation of access matrix
-access control list(ACL) define for object[column] ie acl for o1
-capability list for domain[row] ie list for d1

ACL [user-oriented]
-ie o1 = d1 {rw}, d3{r} [o2 no op->not needed]
-when obj first created, owner specify which domain can access
-slow for many operation with many users[linked-list]
-unix (rwx)

Capability list [process-oriented]
-opposite of acl
-when obj first created, os gives all rights to owner
-stored by os and protected from being tampered[not viewable]

Tuesday, October 23, 2007

hs811 moral panic

Stuart Hall - Policing Crisis
60 Muggings in UK
Murder called "mugging gone wrong"
"mugging" not used previously in UK
associate "mugging" with "dangerous USA"
associate black American (Afro American)

Buildup of mugging
-Police report 129% rise in mugging
-Media circulation

Analysis
-"mugging" not defined -> how police have stats
-street crime common, esp industrial cities
-allowed "stop-and-search", esp West Indian youth
-- -ve reponses
-- alienate West Indian

1945 to 1955 : West Indian encourage to migrate
-Truce between union/govt. since times are bad
After 1968 : unemployment, growth slowed
-Govt not governed by consent
->Harsher punishment
->Focus on blacks to take focus away from govt/capitalist

Sg
Limited, Centrepoint Kids, Mac Kids, Marina Kids
Nowadays, comment rather than panic. "emo" kids

Demonising (eg Suicide Bomber demonized as terroists)
->can do anything to "demon", "evil"

hs811 Media, "actor" relating crime & responses

a)Marihuana Ban
Moral campaign
But from economy view
-Funding declining -> make it serious

b)Cohen Contemporary study (Scooter, Rocker)
"Moral panic" to behaviour @ seaside during Easter Holiday
Scooter - New style clothing
Rocker - Motorbike, leather
97 arrests
No other news -> worldwide news
Widely publicised

Next public holiday also trouble till 1966
-> Eg of "untrue, but repeat stories"

c) Cohen 75 pound cheque
Children mentions writing cheque but was just arguing

Adults of 60's
-Experience war, bad economic changes
-Pessimetic
-Worry teenagers of 60's

Teenager of 60's
-Always hopeful
-Never go through war

hs811 media & crime

Often blamed for behaviour, violence [Difficult to determine]

1)Report of crime by media
a)Content analysis
Column width/height
Objective

b)Violence
More attention to violence by popular[TNP] than quality media[STime]

c)All media
Over report violence over property
Media : 8V to 2P
Stats : 9P to 1V

d)Older, more violence Offender
Correct on Age : disproportionate focus on delinquents in the official statistics
Incorrect on violence

e)Unreported family violence & gender pattern

f)White-collar crime obscured from view
In finanical section instead of front page

Crime,as fiction, as entertainment
Eg. Killing "bad guy" is okay

hs811 Crime/Conflict theory

Crime/Conflict theory

Marx - Social evolution via conflict

2 metatheories
1)Consenus (Shaw & McKay, etc)
-Shared set of values
-Conflict seen as unnatural, problematic

2)Conflict
-Conflict seen as natural due to power differences
-Consenus arrive due to ideology [Ideas that justify differences/ take focus from differences
Eg. Patriotism

Sub-structure and super-structure
Super-Structure
-Social relation of Law, Family, Politic, Relation

Social Relation
-Owner of means of production
-Non-owner

Sub-structure
-(food) production

Means of production
-land, labour, tools
-Newer replaces old

Stages of society
1. Primitive communism
no classes

2. Ancient society (eg Roman)
Slave owner/slave
Few owned the land, labour, tools

3. Feudal society
Lord/serf
Cannot get more/leave the land

4. Capitalist
Factory owner/Worker
Buy land, worker

5. Advanced communism
no classes

Changes involves conflict
-Life
-Idea
-Economy

Law not internal but social construct
Law not just moral[Interactionist]
but interests of econ, politic holder in unequal society

Eg. of historical change for economy
Chambliss colonial tax East Africa
Vagrancy law of feudal England
Carrier case [charged carrier for any mistake -> allows longer distance trading]

Developing Capitalism
Laws to protect consumer [but still benefit capitalist]
-make capitalist more restricted (ie safety)

Kolko
meat packing
-hygience law [increased cost of production -> puts off smaller capitalist]
railroad industry
-no monopoly to cut costs [ but fixed costs(never reduce) -> guarantee profit ]

Graham
-drug [but not as strict because of drug company]

Laws to protect worker [but still benefit capitalist]
Trade union, ... [keeps worker happy]

Separation of government and captalist, employee
-Govt acts as interests of all
-Actions of "moral" for poor/discriminated group
-- only successful if in relation to wider economy interest
Eg.
Need serf -> no change
With machinery, no need serf -> change

Crime from conflict perspective
1)Unequal punishment = interests of capitalist
Connection to white-collar crime
-Widespread
-Few punishment
-Only serves as ideology

2)Crime inevitable as capitalism needs of "reserve group of labour" -> not working -> commit crime

3)Employment for police officer

4)Ideological purpose for leaders (elections)

Local eg.
Casino

Monday, October 22, 2007

hs811 white collar crime

Sutherland
-Favour higher-privileged social class
-Insufficient info based on crimes of higher classes
[prevailing theories of crime which focussed on lower class groups]

Socially wrong if left ignored
-distrust & disrespect of higher class
-encourage law-breaking of lower class
-produce diversity & social Disorganization

Critics felt not crime since not prosecuted but Sutherland argue
-indeed crime becuase against the law and were documented
-but judged under court not criminal court

Data
70 largest company USA
-Law enforcers do not "fit" them as criminal
-High-status people
-not "real criminal"

Cultural Transmission == Differential Association [ From Shaw & McKay]
||
\/
Learnt crime from society

For Company
-Misrepresent financial statements

Against Company
-Embezzlement
-"Mafia"

hs811 Official Statistics

1)Official Statistics constructed
statistics "socially constructed"

statistics of "crimes clear up" (ressolved reported crime)
-[measure of the efficiency of a police force]
-normally understated

Unknown Figure
-not reported crimes

trends of "reported", "real"
-manipulated by increased raid, etc

rates of crime (per '000 as suited/relevant)

changes in offence/crime
-due to new evidence/decision ( murder -> manslaughter )
-plea -> reduced crime
-trial (insuff evidence -> fewer crime) [sg only]

2)Other ways to measure crime
a) Victimization Studies
Random survey if had been victim
Issues
-Reliability - Same result with other
-Validality - Find what you are investigating
-Need trust

b) Self-Report Studies
Random survey if had commit crime
Issues
-Need skills

ee8062 exam notes

idle time always adverse
salvage should be discounted

only for worksheet (p/l, etc exam paper)
allow pencil for worksheet but pen for lines
use middle/ double page
graph optional

Sunday, October 14, 2007

Cost Variances

1)Flexed Budget
Using actual quantity but standard(budgeted) costs/estimate

2)Steps
Calc Budget, Flexed, Actual
Calc Total costs variances (Actual - Flexed) [sales +ve -> (F), cost +ve -> (A)]
Calc Invdivual variances
Summarize values (ensure tally)

a)Sales Variance


b)Direct material (graph similar to sales variance)


c)Direct labour
active = actual - idle


d)Variable overhead


d)Fixed overhead

Friday, October 12, 2007

Capital Budgeting & DCF

1)Payback period
period(in years) = Investment/Annual Return(Cash revenue)

2)NPV [calc periodic(ie cashflow) NOT lump sum]

A is annual payment, P is loan, i interest, r no. of years
Just inverted when calculating P

**Meaning**
An annunity/loan P @ i interest will give/require A payment at the end of r years.
ie, annunity $10 @ 5% interest 5 years
A = 10(1.055(.05)/[1.055-1]) = 10*.231=$2.31
Year 1) P = 10*1.05 - $2.31 = $8.19 (5% interest then give $2.31)
Year 2) P = 8.19*1.05 - $2.31 = $6.2895 (5% interest then give $2.31)
Year 3) P = 6.29*1.05 - $2.31 = $4.2945 (5% interest then give $2.31)
Year 4) P = 4.29*1.05 - $2.31 = $2.19 (5% interest then give $2.31)
Year 5) P = 2.19*1.05 - $2.31 ~ 0 (5% interest then give $2.31)

Example
Investment = 30K
Discount rate, r = 20%
Annual Return = 11K
Useful life = 10 years
Scrap Value = 1K

NPV (discount scrap)
= -30K + 1K/1.210 + [11K * (1/1.2 + 1/1.22 + ... + 1/1.210 )]
= -29.838K + 11K * [(1.210-1)/1.210/0.2] (using formula above)
= -29.838K + 11K * 4.192
~ $16274

3) Break even example
27K = net annual return × 4.192 (from above)
6441 = 10% of cash(to factory) + 3.7K
2741 = (0.1)Min. Annual Sales
Min Annual Sales = 2741/0.1 = 27410

4)IRR
a)Discount rate, r that NPV = 0
b)Iteratively test to find IRR


5)Hire purchase(eg Car)[principal instead of remaining to calc interest]
Example
$50 @ 0.06 for 10 years
Total Payment = (50 + 50 * (0.06) * 10 =$80
Annual Payment = 80/10 = $8
Compare NPV, Annual Payment = $6.79

6)Additional formula based on 2)
a) Sinking fund
Info on sinking fund
FUTURE VALUE of money

Without the (1+i)n, it is the FUTURE VALUE of the money
With (1+i)n, it is PRESENT VALUE of money (< than FUTURE)

b) Present value, given infinite Period

Leadership

1)
Effective Mgmt & Leadership Inseparable


2)
Building Block of Leader

2a)
Traits of Leader
  • Assertive
  • Dependable
  • Decisive
  • Cooperative
  • Tolerant of stress
  • Self Confident


3)
Leader Behaviour
  • Concern for production
  • Concern for people


3a)
Leadership Grid



4)
Hersey and Blanchard’s Situational/Contingency Leadership Styles

Employee Readiness Level
Level 1: Low ability, high drive (start)
Level 2: Ability increasing, low drive
Level 3: Good ability, low drive
Level 4: High ability, drive

4a)
Styles to used for each level