Difference between revisions of "Guides"

From CS 61A Wiki
Jump to: navigation, search
(Andrew's environment diagram rules)
(How to learn Computer Science)
Line 42: Line 42:
 
== Student guides ==
 
== Student guides ==
 
=== How to learn Computer Science ===
 
=== How to learn Computer Science ===
 +
[https://piazza.com/class/hoxc5uu6sud761?cid=241 Source: Spring 2014 Piazza (241)]
 +
 
If you've never programmed before, or if you've never taken a class quite like 61A before, things right now might be scary. Everything is strange and new and there quite a lot to take in all at once. So if you're having a hard time so far, here are a few articles that might help.
 
If you've never programmed before, or if you've never taken a class quite like 61A before, things right now might be scary. Everything is strange and new and there quite a lot to take in all at once. So if you're having a hard time so far, here are a few articles that might help.
  

Revision as of 19:56, 15 June 2014

Higher-order functions

Environment diagrams

Andrew's environment diagram rules

Creating a function

  1. Draw the func <name>(<arg1>, <arg2>, ...)
  2. The parent of the function is wherever the function was defined (the frame we're currently in, since we're creating the function).
  3. If we used def, make a binding of the name to the value in the current frame.

Calling user-defined functions

  1. Evaluate the operator and operands.
  2. Create a new frame; the parent is whatever the operator s parent is. Now this is the current frame.
  3. Bind the formal parameters to the argument values (the evaluated operands).
  4. Evaluate the body of the operator in the context of this new frame.
  5. After evaluating the body, go back to the frame that called the function.

Assignment

  1. Evaluate the expression to the right of the assignment operator (=).
  2. If nonlocal, find the frame that has the variable you're looking for, starting in the parent frame and ending just before the global frame (via Lookup rules). Otherwise, use the current frame. Note: If there are multiple frames that have the same variable, pick the frame closest to the current frame.
  3. Bind the variable name to the value of the expression in the identified frame. Be sure you override the variable name if it had a previous binding.

Lookup

  1. Start at the current frame. Is the variable in this frame? If yes, that's the answer.
  2. If it isn't, go to the parent frame and repeat 1.
  3. If you run out of frames (reach the Global frame and it's not there), complain.

Tips

  1. You can only bind names to values. No expressions (like 3+4) allowed on environment diagrams!
  2. Frames and Functions both have parents.

Sequences

Recursion

Data abstraction

Time complexity

Mutability

Mutable data-structures

Object-oriented programming

Iterables, iterators and generators

Scheme

Streams

Logic

Python syntax and semantics

Student guides

How to learn Computer Science

Source: Spring 2014 Piazza (241)

If you've never programmed before, or if you've never taken a class quite like 61A before, things right now might be scary. Everything is strange and new and there quite a lot to take in all at once. So if you're having a hard time so far, here are a few articles that might help.

Note: these articles are pretty long, so feel free to read them in multiple sittings.

At the beginning, everything seems a bit scary in CS. Michelle Bu, a Berkeley alum and a crazy good hacker, shares one of her experiences when she was a wee n00b in 21 Nested Callbacks.

Start here! "A Beginner's Guide to Computer Science" Written by Berkeley's own James Maa. James is known for his killer walkthroughs (check out his Productivity guide). This article gives you some background on learning CS and then provides a practical guide on how to learn effectively.

How do we learn? Mark Eichenlaub explains in this Introduction to Learning Theory. This is quite possibly the best introduction to Learning Theory.

Sometimes, you're stuck and you end up really, really frustrated. Marcus Geduld explains Why do we get frustrated when learning something?

Composition

Debugging

Miscellaneous