Download presentation
Presentation is loading. Please wait.
1
UMBC CMSC 104 – Section 01, Fall 2016
Algorithms I
2
Notes & Announcements TA contact info posted to website Project 1A Results were mixed Everyone who submitted gets full points
3
Survey Results
4
Survey Results I compiled all the surveys I received as of Saturday (the vast majority of you) I then created a program to parse & graph results The source code has been posted to the website if you’d like to look at it. Don’t worry if it doesn’t make any sense right now. Some of you suck at following instructions Had to throw away some bad responses Here’s the results…
5
Survey Results - Majors
6
Survey Results - Years
7
Survey Results - OS
8
Survey Results – Cmd Line Exp
9
Survey Results – Programming Exp
10
Survey Results – C Experience
11
Survey Results – Mobile Platform
12
Survey Results – Gaming Platform
13
Survey Results – Free Response
Some observations from the free response questions… Major reasons for choosing UMBC: Close to home Cost Reputation Major reasons for taking this class: Want to learn programming Easier/more interesting than Calc II Where you expect to be in 10 years “Working” Med School Thanks to those of you who didn’t give smartass one-word responses.
14
Project 1B
15
Sticking points… Generally, you all did well
Lots of wrong directory structures We covered this in the slides… It even tells you this in the project description! Most confusing part? tail -2 numbers > ../c/somenumbers Lets look at this too.
16
Directories Structures
Directory Structure of jdoe28 jdoe28 junk recipes pies apple peach cookies choc_chip notes CMSC104
17
The Command in Question
The command at hand tail -2 numbers > ../c/somenumbers What are the parts of this command? tail -2 numbers > ../c/somenumbers
18
tail –2 numbers The command at hand How do we find out what this does?
Run it man tail What does it do? Outputs the last two lines of the numbers file.
19
> ../c/somenumbers The command at hand What does the > do?
From step 9 of Project 1B: The character > is used to redirect the output of a command. When used, it will create a file that contains the output of the command that precedes the character >. What does ../c/somenumbers do? .. means “up one directory from the current” /c/ means “in the c directory” somenumbers is a new file name.
20
The Command in Question
The command at hand tail -2 numbers > ../c/somenumbers What does it do? Output the last two lines of the numbers file in the current directory into a new file called somenumbers in the c directory, one directory up from the current
21
Algorithms
22
Problem Solving Problem solving is the process of transforming the description of a problem into the solution of that problem. We use our knowledge of the problem domain. We rely on our ability to select and use appropriate problem-solving strategies, techniques, and tools.
23
Algorithms An algorithm is a step by step solution to a problem.
Why bother writing an algorithm? For your own use in the future. You won’t have to rethink the problem. So others can use it, even if they know very little about the principles behind how the solution was derived.
24
Examples of Algorithms
Washing machine instructions Instructions for a ready-to-assemble piece of furniture A classic: finding the greatest common divisor (GCD) using Euclid’s Algorithm
25
Washing Machine Instructions
Separate clothes into white clothes and colored clothes. For white clothes: Set water temperature knob to HOT. Place white laundry in tub. For colored clothes: Set water temperature knob to COLD. Place colored laundry in tub. Add 1 cup of powdered laundry detergent to tub. Close lid and press the start button.
26
Observations About the Washing Machine Instructions
There are a finite number of steps. We are capable of doing each of the steps. When we have followed all of the steps, the washing machine will wash the clothes and then will stop.
27
Refinement of Algorithm Definition
Our old definition: An algorithm is a step by step solution to a problem. Adding our observations: An algorithm is a finite set of executable instructions that directs a terminating activity.
28
Assembling a Piece of Furniture
“Align the marks on side A with the grooves on Part F.” How could these instructions be hard to follow? Which side is A? A & B look alike -- both line up with Part F! This instruction is ambiguous.
29
Algorithm Definition – Final Version
Our old definition: An algorithm is a finite set of executable instructions that directs a terminating activity. Final version: An algorithm is a finite set of unambiguous, executable instructions that directs a terminating activity.
30
History of Algorithms The study of algorithms began as a subject in mathematics. The search for algorithms was a significant activity of early mathematicians. Goal: To find a single set of instructions that can be used to solve any problem of a particular type (a general solution).
31
Euclid’s Algorithm Problem: Find the largest positive integer that divides evenly into two given positive integers (i.e., the greatest common divisor). Algorithm: Assign M and N the values of the larger and smaller of the two positive integers, respectively. Divide M by N and call the remainder R. If R is not 0, then assign M the value of N, assign N the value of R, and return to Step 2. Otherwise, the greatest common divisor is the value currently assigned to N.
32
Finding the GCD of 24 and 9 M N R 24 9 6 9 6 3 6 3 0
So, 3 is the GCD of 24 and 9.
33
Euclid’s Algorithm (con’t)
Do we need to know the theory that Euclid used to come up with this algorithm in order to use it? What intelligence is required to find the GCD using this algorithm?
34
The Idea Behind Algorithms
Once an algorithm behind a task has been discovered We don't need to understand the principles. The task is reduced to following the instructions. The intelligence is "encoded into the algorithm."
35
Algorithm Representation
Syntax and Semantics Syntax refers to the representation itself. Semantics refers to the concept represented (i.e., the logic).
36
Contrasting Syntax and Semantics
In the English language, we have both syntax and semantics. Syntax is the grammar of the language. Semantics is the meaning. Given the following sentence, I walked to the corner grocery store. Is this sentence syntactically correct? Is it semantically correct?
37
Contrasting Syntax and Semantics (con’t)
Given the following sentence, I talked to the funny grocery store. Is this sentence syntactically correct? Is it semantically correct? How about I grocery store walked corner the to.
38
Contrasting Syntax and Semantics (con’t)
Conclusion: An English sentence may be syntactically correct, yet semantically incorrect. This is also true of algorithms. And it is also true of computer code.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.