Presumably you are taking this class for a variety of (non-exclusive) reasons:
These are not in opposition. As a CS major you are likely to apply your computational skills to problems in other domains (sometimes called “CS+X”). For example, most of my research is focused on human genomics. The opportunity to have an impact in other domains, such as improving human health, is what draws me to CS!
The short answer: 2 weeks. The longer answer: CS4All emphasizes six concepts at the heart of CS: data, problem solving, algorithms, programming, abstraction, and creativity1. You will get experience with all 6 in either class. The difference is that we use those two weeks to learn more about the tools, like plotting libraries, used for scientific computing and data analysis.
What do we use computers for, especially in the sciences? Why pursue CS at all? It can be hard to answer those questions without defining “What is Computer Science?”.
However, there is no single definition of “Computer Science”. Some describe it as the study of complexity, others as the study of automating tasks1. While the latter seems like it might trivialize the discipline, I think it just the opposite. A computer is the right tool when you need to do something more than once (and perhaps many, many, times). And doing something more than once – efficiently – depends on a range of innovations and knowledge from applied math to psychology.
In some ways it is easier to describe what Computer Science is not. It is not study of how computers work (in the way that the natural sciences are the study of how the natural world works). And it is not just about programming, i.e., programming is to CS as telescopes are to astronomy – a means to an end (not the end itself).
A definition for CS I like is “Algorithmic thinking/problem solving usually (but not always) involving computers.”
Again the implementation (the part involving the computer) is just one component of solving a computational problem. We need to be able to answer a number of questions on our way to solving a computational problem, only one of which is about programming (Adapted from Zach Dodds):
By the end of the semester we will be able to answer all of these questions!
But what is an algorithm? What might be an analogy for an algorithm that we encounter outside computation? As a hint, think about the kitchen… Show an answer…
A recipe is a ready, if informal, analogy for an algorithm.
More formally, an algorithm:
Our general approach to problem solving:
We will first try out these steps in the context of Picobot, a 2-D programmable “robot” that is similar to the Roomba vacuum. Check out the Picobot simulator. Picobot’s capabilities are described more here.
What is the problem we are trying to solve? What are the inputs and outputs? The input is a “empty” room, with Picobot starting randomly somewhere in the room, but always in state 0. We want to traverse all of the white squares using only local sensing (what is immediately north, east, west or south of Picobot).
One of the trickier aspects of Picobot can be the “state”. State is Picobot’s “memory”, how it knows, for example, that it is supposed to be going “north”. Recall that Picobot can only sense its local surroundings and doesn’t have any overarching sense of direction (other than those local observations). The state can provide that context. More generally the state of the computer is its current condition or alternately its current internal configuration. For Picobot the state is a number from 0 - 99. That number doesn’t have any intrinsic or built-in meaning. The meaning comes from you. For example, you could effectively define state 0 as the “going north till it hits a wall” state and 1 as the “going south until it can’t anymore” state (or whatever numbers you choose). That is I recommended associating a goal with each state, e.g., “go all the way to the east”. And when you want Picobot to switch to a new goal, you probably want to switch to a different state.
Having learned about Picobot works, let’s consider the initial example algorithm provided on the Picobot page. Without running it, will the following algorithm traverse all the open squares of the “empty room”?
#
# Hashtag lines are optional comments
#
# state 0 with nothing N: go one step N
0 x*** -> N 0
# state 0 with something to the N: go W and into state 1
# ** This will crash if picobot has a wall to the W! **
0 N*** -> W 1
# state 1 with nothing to the S: go one step S
1 ***x -> S 1
# state 1 with something to the S: stay put and go into state 0
1 ***S -> X 0
Don’t be afraid to use a piece of paper to help you keep track of Picobot’s behavior. The “Computer” in Computer Science doesn’t mean we don’t ever use pencil/paper to help us! Also don’t be afraid to “act out” what Picobot is doing. What we are practicing here is building a mental model of the current state of the computation, i.e., Picobot’s location and the current rule state, and then projecting the “next” state of the computation based on the algorithm, i.e., Picobot’s rules.
PI questions
Show the PicoBot challenge instructions (after the PI questions…)
As we predicted, with the initial rules, Picobot will get stuck in the “northwest” corner of the maze. How could you change the algorithm to prevent Picobot from getting stuck? (Note that there are multiple potential solutions). What would you want Picobot to do differently when it gets to that upper left corner? And then how could you implement that algorithm in terms of Picobot’s rules? The order of those questions was purposeful, I suggest you articulate your approach in natural language first (e.g., “After Picobot gets stuck in the NW corner, it should …”) and then start figuring out to implement that plan in Picobot rules. As a hint, you already have effective rules for traversing the space from east to west. How could you take advantage of those existing rules to cover the entire room?
Optionally with a partner, develop an algorithm to traverse the entire empty room and implement that algorithm as a set of Picobot rules (steps 2 and 3 above). Test your rules with the Picobot simulator. Once you have a working set of rules, save your rules as a text file (using Notepad on Windows or TextEdit on Mac) named empty_room.txt
. If you are using TextEdit make sure to select “Format→Make Plain Text” so that you can save a plain “.txt” file that Gradescope understands (instead of a Rich Text File). I have provided a empty_room.txt starter file with the rules above that you can download and modify. You will then submit your solution to https://gradescope.com following these instructions. We will use Gradescope to submit all of our programming assignments, so this is a chance to activate your account and try out the site. Gradescope will automatically test your submission to make sure it works correctly. Note that the file name and format matters, you must name your file exactly as specified. If you are not yet registered for the class in Banner, notify me (the instructor) so I can add you to Gradescope. You can submit multiple times, only the last submission will be retained. If you do work with a partner, whoever submits to Gradescope should make sure to add their group mate as described here.
For this problem, Gradescope will test your Picobot program for correctness and record the number of steps needed to traverse the room and the number of rules used. This is not a graded assignment (ignore the points, they are needed for Gradescope to display tests properly), but those two values are used to populate a leaderboard. The team(s) with the best submission, i.e., the fewest steps (using the smaller number of rules to break ties), will win a small prize! Your solution has to pass the tests, i.e., be correct, to be eligible (think correctness first, then efficiency then conciseness…).
The online syllabus has information on office hours, books, schedule, grading, etc. The website is the “official” source for the syllabus, course policies, etc.
Please note:
We will typically have lecture/problem solving on Monday and Wednesday, then a quiz and lecture/problem solving on Friday. At the beginning of Friday’s class we will have a regular short quiz on the material we covered during the week. The quizzes are intended to provide a low-stakes opportunity to check whether you understand the material. To prepare for the quizzes (and the exams) there are practice problems (and solutions) posted on the course webpage (as “Practice problems”). Computer Science (and even programming, specifically) is not all about the computer. As we observed already, our success depends on us building an accurate mental model of what the computer is doing; paper-based problems will help us do so!