On the Science Behind Computing (Part I)
Samir Khuller
1 Intro to Ruby
You can nd many online resourcs for Ruby this is a brief introduction to the basics about
programming in ruby. We discuss three rather simple programs.
This program denes two variables

Fall 2009
CMSC 198K: Homework 4
Khuller & Bhattacharjee
Due at the start of class Thurs, Dec 10, 2009.
Problem 1. Explain the role of the check digit in ISBN numbers on every book. Take an
ISBN number and explain how the check digit works (please use a di

Fall 2009
CMSC 198K: Homework 3
Khuller & Bhattacharjee
Due at the start of class Thurs, Nov 12, 2009.
Problem 1. Run the shortest path algorithm on the following graph (Figure 1). Show all
the steps, as well as all the d values of all nodes. Please start

Programming Assignment #1
Due Thu October 29th.
C
I
A
G
K
D
B
J
N
O
E
L
M
Figure 1: A graph with 15 nodes and 3 connected components
In this assignment, you will write two functions that operate over graphs. The graphs
will be specied using an adjacency m

Fall 2009
CMSC 198K: Homework 1
Khuller & Bhattacharjee
Due at the start of class Thurs, Oct 15, 2009.
Problem 1. Suppose I think of a number that is positive. I do not tell you the range of
the number (in class we played the game where I thought of a num

Fall 2009
CMSC 198K: Homework 1
Khuller & Bhattacharjee
Due at the start of class Tuesday, Sep 15, 2009.
Problem 1. Run the stable marriage algorithm on the following instance to create a stable
marriage. Show all your steps.
Instance: There are 4 men, m1

Final Programming Assignment
Due Dec 8th
Write a function Chain that takes two words, s and e of equal length as input, and
populates an array Soln such that the rst word in Soln is s, the last word is e, and each
intermediate word diers from its predeces

On the Science Behind Computing (Part I)
Samir Khuller
1 Circuits
We shall now examine the question of how a modern electronic computer actually computes
functions. Let us consider a simple problem that involves adding two numbers. In ruby, this is
easily

On the Science Behind Computing (Part I)
Samir Khuller
1 Internet Search
In 1995 when the world wide web was fairly new, I tried to search for information on the Grand
Canyon. Many of the web sites that came up were of the type Here are the pictures of my

On the Science Behind Computing (Part I)
Samir Khuller
1 Shortest Path Routing in Graphs
Many applications need to compute routes to go between nodes in a graph. This occurs when
we use online maps to get directions. When we use online maps, we enter a st

On the Science Behind Computing (Part I)
Samir Khuller
1 Graphs and their Representation
We had several discussions about graphs and even informally discussed some simple algorithms
that processed graphs to achieve certain objectives. However we only drew

On the Science Behind Computing (Part I)
Samir Khuller
1 Binary Arithmetic
We rst discuss representation of numbers the numbers we are used to are numbers such as 137,
or 2358. The rst number is really 1 100 + 3 10 + 7 1. The second number can be written

On the Science Behind Computing (Part I)
Samir Khuller
1 Graphs and Facebook
Facebook is a social networking website. From my point of view it is simply a graph people
correspond to nodes in this large graph, and edges correspond to friendship links (neig

On the Science Behind Computing (Part I)
Samir Khuller
1 Arrays
Often we need to store a large collection of values, and not just a single value. Say for example
we wish to compute the average height of the students in the class. To do this, we rst need t

CMSC 198k Computer Networks
Fall 2009
Programming Exercise
Open book and notes; In class
Thursday, October 17th
What is the output of the following program:
x=1; y=2
def f(a, b)
return a * b
end
What will f(x,x) return?
Fill in the body of the conv func