CSC 151.01, Class 01: An introduction to algorithms
Overview
- Preliminaries
- Notes and news
- Upcoming work
- Extra credit
- Questions
- Introduction - What is CS?
- Exercise - An everyday algorithm
- Debriefing on exercise
- Common parts of an algorithm
Preliminaries
News / Etc.
- Welcome to CSC 151!
- I’m Sam (or SamR)
- Your class mentors are Sally and Shelby
- You should have received four handouts at the start of class.
- A playing card
- The CS Department Academic Honesty Policy
- Assignment 1
- A packet of readings
- Reading: Algorithms
- Reading: Linux
- Reading: The DrRacket Programming Environment
- Reading: Beginning Scheme
- Since it’s the first day of class, I’ll be taking attendance. (It will take
a few weeks for me to learn all of your names.
- “Hi, my name is FORENAME SURNAME.”
- “You can call me PRIMARY NAME.”
- “If you must address me by surname, you can call me Mr./Ms./Mx./[nothing] SURNAME.”
- I’m from …
- Optional: “My pronouns are ….”
- Disclaimers
- Sam is slightly hard of hearing.
- Sam is incredibly snarky. (Sam = Snarky and mean)
- Contact Sam if you would like to be on the department mailing list.
Upcoming work
- Assignment 1 due Tuesday night.
- Readings (handed out today), due before class Wednesday.
- Signed academic honesty policy due in class on Friday.
- If you are uncomfortable signing it, make an appointment to chat with me.
Extra credit (Academic/Artistic)
- MLK day (+ 1 week + 1 day) event, Tuesday, 7:00 pm, JRC 101
Extra credit (Peer)
None yet.
Extra credit (Misc)
- Fill out the Data Buddies survey that you received over break. https://cerp.co1.qualtrics.com/jfe/form/SV_3UH7q6TmdZ8YRPD
Other good things
Questions
Introduction - What is CS?
Write down a definition (your definition). You may be called upon to share it with the class.
- The study and practice of computers.
- Horrible and vague.
- What does it mean to study?
- Disect
- Look at the individual components
- Get a deeper understanding
- What’s a computer?
- A machine, of sorts
- Things that you can program
- What is to program?
- Write a language (that computers understand)
- A program is a set of instructions that tell a computer what to do.
- Do computers have to be machines?
- Computer used to be a job title
- Computer scientistists, when thinking about our discipline, prefer
to focus more on the instructions and less on the computers.
- Computer science is the study of instructions and data (representation)
- How you write them to solve problems
- Computer science is the study of algorithms and data structures.
- “Algorithm” = “instructions for accomplishing a solution to a problem.”
- Computer science is the study of instructions and data (representation)
- The class will be about writing algorithms, verifying algorithms, analyzing algorithms, and other related.
- We will generally write our algorithms in an artificial language, Scheme.
- Artificial languages are generally less ambiguous than English.
Exercise - An everyday algorithm
The problem: Write an unambiguous set of instructions for making a nut-butter and preserve sandwich.
- Note: Your instructions should be moderately general, in that they should work with other loaves of bread, jars of butter, and jars of preserves.
- As a team based on your card number.
- Your “computer” deals poorly with ambiguous instructions.
- “Open” can mean many things. I have been known to open a jar by hitting it against the side of a table.
Basic instructions
- Get with your matching number group.
- Introduce yourselves to each other.
- Write unambiguous instructions that teach me how to make a nut butter and jam sandwich.
Debriefing on exercise
Come up with at least four things you might have learned from doing this exercise.
- Important: Things will go wrong when you try to write algorithms. When they do, look back on today and laugh.
- Most common: Be unambiguous in writing instructions. Ambiguity
can often lead to errors, sometimes dangerous ones. What you think
is “obvious” may not be obvious to the “computer”.
- Assume nothing (or at least very little)
- Be specific.
- Watch what your algorithm does and go back and correct mistakes before moving on.
- Writing general algorithms can be much harder than writing very
specific algorithms.
- Good general algorithms ask about their inputs and make decisions based on those inputs. “If the bread loaf has a twisty tie, … Otherwise, if the bread loaf has a plastic clip, ….. Otherwise, grab the ends of the bag and pull apart.”
- So think carefully about what the different cases may be.
- There might be multiple solutions to the same problem.
- Groups tend to predict problems better than individuals; group algorithm
writing tends to be more successful.
- Because of this, we will make you work in groups (more or less every day of class)
- Don’t try to write a large algorithm all at once. Write a part, try it, write the next part, try it. Etc. (Develop interactively.) Common parts of an algorithm —————————-