CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.
-
Upload
alaina-baldwin -
Category
Documents
-
view
220 -
download
1
Transcript of CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.
![Page 1: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/1.jpg)
CMSC 150INTRODUCTION
TOCOMPUTING
CS 150: Mon 9 Jan 2012
![Page 2: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/2.jpg)
About Me
Dr. Lewis Barnett Office: 212A Jepson Hall Office Hours: Most anytime, but
especiallyMT 2:30 - 3:30 pm; WR 10:30 - 11:30 am;
[email protected] http://www.mathcs.richmond.edu/~lbarnett/
![Page 3: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/3.jpg)
First: Meet Doug
![Page 4: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/4.jpg)
He Decides Network Connections
![Page 5: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/5.jpg)
Connections Doug Can Choose
![Page 6: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/6.jpg)
Hours to Install Each Connection
54
9
25
3
6
2
4
23
4
3
2
11
![Page 7: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/7.jpg)
What Doug Wants…
A set of connections so that: a connection to each place (no place left
out) no loops sum of all installation times is minimum
4
23
4
2
three loops here
4
23
2
one loop here
23
2
no loops here
![Page 8: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/8.jpg)
Start With A Smaller Example
5
1
32
2
Which connections should you include?5
4
![Page 9: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/9.jpg)
Start With A Smaller Example
5
1
32
2
Which connections should you include? Likely the shorter ones…
5
4
![Page 10: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/10.jpg)
Start With A Smaller Example
5
1
32
2
Which connections should you include? Likely the shorter ones Less likely the longer ones…
5
4
![Page 11: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/11.jpg)
Step by Step…
5
1
32
2
5
4
5
1
32
2
5
4
![Page 12: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/12.jpg)
Step by Step…
5
1
32
2
5
4
1
5
1
32
2
5
4
![Page 13: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/13.jpg)
Step by Step…
5
1
32
2
5
4
12
5
1
32
2
5
4
![Page 14: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/14.jpg)
Step by Step…
5
1
32
2
5
4
1
2
2
5
1
32
2
5
4
![Page 15: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/15.jpg)
Step by Step…
5
1
32
2
5
4
1
2
2
3 5
1
32
2
5
4
![Page 16: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/16.jpg)
Step by Step…
5
1
32
2
5
4
1
2
2
3
loop!
5
1
32
2
5
4
![Page 17: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/17.jpg)
Step by Step…
5
1
32
2
5
4
1
2
2
5
5
1
32
2
5
4
![Page 18: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/18.jpg)
Step by Step…
5
1
32
2
5
4
1
2
2
5
− each place connected− no loops− sum of times is minimum5
1
32
2
5
4
![Page 19: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/19.jpg)
Minimal vs. Not
1
2
2
5
− each place connected− no loops− sum of times is minimum
2
5
54 − each place connected
− no loops− sum of times is NOT minimum
34
5
12
3
![Page 20: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/20.jpg)
You Try It…
54
9
25
3
6
2
4
2
34
3
2
11
![Page 21: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/21.jpg)
Was This Your Result ?
54
9
25
3
6
2
4
2
34
3
2
11
− each place is connected− no loops− sum of times is minimum: 28 hours
![Page 22: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/22.jpg)
Doug is a Happy Fellow!
54
25
3 2 23
11
![Page 23: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/23.jpg)
Your Next Task
Break into pairs…
Write down the procedure you used: think in general terms
how do you start? how do you proceed from there? when do you finish?
![Page 24: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/24.jpg)
Your Algorithm
You have just written down your first algorithm Kruskal’s algorithm for finding Minimum
Spanning Tree
1. Include path with min time (ties broken arbitrarily)
2. Include next shortest path if it does not introduce a loop
3. Repeat step 2 until each place has a path connected to it
![Page 25: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/25.jpg)
Algorithms
Algorithm: Set of instructions for solving a problem known starting condition well-defined sequence of steps terminates
Computation: applying an algorithm to an input to obtain an output (solution)
Key: different algorithms can solve same problem Choose the “best” algorithm
![Page 26: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/26.jpg)
Applications of MST
Network Design computer, electrical, cable, road, … e.g., want set of lines that connects all
offices with minimum total cost
Real-time face verification Particle interactions in fluid flows Ethernet bridging to avoid cycles in
network
![Page 27: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/27.jpg)
About This Course
An introduction to the science of computing
You will learn: how to think algorithmically how to write your solutions in a program
(in Java) how to debug and test your solutions
![Page 28: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/28.jpg)
Remember…
Computer science is not (just) programming
Computer scientists do much more than program
They develop algorithms to solve
problems using the computer (and programs) incorporating a variety of disciplines myriad applications and real-world
benefits…
![Page 29: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/29.jpg)
![Page 30: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/30.jpg)
![Page 32: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/32.jpg)
But We Have To Start Simple…
JavaProgra
m(Source)
Compiler
JavaProgra
m(Byte Code)
You write the source codein an IDE, e.g., BlueJ
![Page 33: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/33.jpg)
But We Have To Start Simple…
JavaProgra
m(Source)
Compiler
JavaProgra
m(Byte Code)
The compiler is a program thatconverts source to binary; Included in BlueJ
![Page 34: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/34.jpg)
But We Have To Start Simple…
JavaProgra
m(Source)
Compiler
JavaProgra
m(Byte Code)
Byte code version can be executed on computer
![Page 35: CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e035503460f94aef309/html5/thumbnails/35.jpg)
Let’s Write Our First Program !