CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012
About Me Dr. Lewis Barnett Office: 212A Jepson Hall Office Hours: Most anytime, but especially MT 2:30 - 3:30 pm; WR 10: :30 am;
First: Meet Doug
He Decides Network Connections
Connections Doug Can Choose
Hours to Install Each Connection
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 three loops here one loop here no loops here
Start With A Smaller Example Which connections should you include? 5 4
Start With A Smaller Example Which connections should you include? Likely the shorter ones… 5 4
Start With A Smaller Example Which connections should you include? Likely the shorter ones Less likely the longer ones… 5 4
Step by Step…
loop!
Step by Step…
− each place connected − no loops − sum of times is minimum
Minimal vs. Not − each place connected − no loops − sum of times is minimum − each place connected − no loops − sum of times is NOT minimum
You Try It…
Was This Your Result ? − each place is connected − no loops − sum of times is minimum: 28 hours
Doug is a Happy Fellow!
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?
Your Algorithm You have just written down your first algorithm Kruskal’s algorithm for finding Minimum Spanning Tree Kruskal’s algorithm 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 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
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
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
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
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…
Google’s Autonomous Vehicle
But We Have To Start Simple… Java Program (Source) Java Program (Source) Compiler Java Program (Byte Code) Java Program (Byte Code) You write the source code in an IDE, e.g., BlueJ
But We Have To Start Simple… Java Program (Source) Java Program (Source) Compiler Java Program (Byte Code) Java Program (Byte Code) The compiler is a program that converts source to binary; Included in BlueJ
But We Have To Start Simple… Java Program (Source) Java Program (Source) Compiler Java Program (Byte Code) Java Program (Byte Code) Byte code version can be executed on computer
Let’s Write Our First Program !