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
Construction
1. Select a prime number p such that for every key k (clearly p > m)
0 k p-1
2. Randomly select a constant a such that
1 a p-1
3. Randomly select a constant b such that
0 b p-1
4. Construct the hashing function as
Using this procedure it can
Longest Common Subsequence
Given two sequences X of length m and Y of length n as
X = <x1, x2, ., xm>
Y = <y1, y2, ., yn>
find the longest common subsequence (LCS).
Step 1: Characterize optimality
The brute force procedure would involve enumerating all 2
Indicator Random Variables
The technique of indicator random variables is based upon the concept of
an event either occuring or not occuring. Thus for an event A (which is a random
event), we will define an indicator variable as
Thus I simply indicates wh
Chapter 6 Making Decisions
Learning Objectives:
if,
if else,
if, else if, else
Random number generator
Exam 1: Tuesday, February 15th
(in two weeks)
1
if statement syntax:
if(some condition)
/note there is no semi-colon
cfw_
/c+ statements that execut
Lecture 12 Modular Programming
with Functions
Learning Objectives:
Understand the purpose of functions
Understand how to use functions and the
vocabulary
Write your own functions
1
Modularity (the purpose of functions)
1.
2.
Doing the same thing more t
More Fun with Graphics and GUIs
Learning Objectives:
More Form Components: Menus, PictureBoxes,
ColorDialog
Drawing using the mouse
Boolean Variables
Go ahead and start up Visual Studio
1
More Form Components
Menu: From Toolbox, drag MenuStrip onto fo
Chapter 5 Program Looping
Learning Objectives:
Field Width Specification in printf
Review Nested loops
Triangular Loops
Exam 1 Tuesday!
1
Field Width in printf
Example:
int a = 5;
printf(a = %3i\n);
%3i means use a minimum of 3 spaces to print it out
A
Using C# for Graphics and GUIs
Handout #2
Learning Objectives:
C# Arrays
Global Variables
Your own methods
Random Numbers
Working with Strings
Drawing Rectangles, Ellipses, and Lines
Start up Visual Studio now so it has time to load.
1
C# Arrays
Arr
Chapter 7 Working With Arrays
Learning Objectives:
Understand the Purpose of 1-D arrays and
vectors
Understand the differences between
arrays and vectors
Be able to declare 1-D arrays
Be able to use 1-D arrays
Going out of bounds with an array
Swapp
C# Continued
Learning Objectives:
Open File Dialog and Save File Dialog
File Input/Output
Importing Pictures from Files and saving
Bitmaps
Reading and Writing Text Files
Try and Catch
Working with Strings
ListBoxes
1
OpenFileDialog and SaveFileDial
Lecture 13 Modular Programming
with Functions
Learning Objectives:
Review Functions
Other function capabilities
1
Notes about Functions
For any program that is more than about 25 lines long,
you should use functions.
main() should consist mainly of func
Lecture 18 Structures Continued
Learning Objectives:
Review of Structures and Functions
1
What is a Structure?
It is a user-defined data type (like double or vector) that can
hold one or more variables (called fields).
You can put as many fields in your
Chapter 4 Variables, Data Types, and
Arithmatic Expressions
Learning Objectives:
Programming
Variables Revisited
Equal sign Revisited
Type Change Operator
Abbreviated Operators
Math Functions
1
Steps for Creating a Program
(What you SHOULD Do)
1. Be
1-D Vectors (not in your Text)
Learning Objectives:
Review of Arrays
The main differences between vectors and
arrays
Preprocessor directives for vectors
Be able to declare 1-D vectors
Be able to use 1-D vectors
Classes / Objects
Functions associate
Lecture 15 Passing Arrays and
Vectors into Functions
Learning Objectives:
Passing vectors into functions (1-D and 2-D)
Returning vectors from functions
Passing Arrays into functions
Passing a vector by reference
1
Passing 1-D vectors into functions
A
Variables, Data Types, and Arithmetic
Expressions
Learning Objectives:
Printing more than one variable in one printf()
Printing formatting characters in printf
Declaring and initializing variables
A couple of Variable types
Input and output of float or do
Chapter 7 Working With Arrays
Learning Objectives:
Review 1-D arrays
Be able to declare 2-D arrays
Be able to use 2-D arrays
Be able to declare 2-D vectors
Sizing 2-D vectors
Using Functions with 2-D vectors
1
Review of 1-D Arrays
Array = Variable t