background preloader



Lectures 1 and 2: Analysis of Algorithms I just finished watching the last lecture of MIT's "Introduction to Algorithms" course. Having a great passion for all aspects of computing, I decided to share everything I learned with you, my dear readers! This is the first post in an article series about this course. As I wrote earlier, I am very serious about watching video lectures. There are totally 23 video lectures, each around 1 hour 20 minutes long. Understanding and designing effective algorithms is a very important skill for a top-notch programmer. Let's start with Lecture 1 of this course. Lecture 1: Analysis of Algorithms The first lecture is given by the famous professor Charles E. He starts the lecture by explaining what this course and algorithms will be all about. Designing great software is not just about performance. Here is the list of things more important than performance that Charles presented: He also asks "Why study algorithms and performance at all?". Sometimes performance is correlated with user-friendliness.

ajmals PEP 8 -- Style Guide for Python Code Code should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such).For example, do not rely on CPython's efficient implementation of in-place string concatenation for statements in the form a += b or a = a + b. This optimization is fragile even in CPython (it only works for some types) and isn't present at all in implementations that don't use refcounting. In performance sensitive parts of the library, the ''.join() form should be used instead. This will ensure that concatenation occurs in linear time across various implementations.Comparisons to singletons like None should always be done with is or is not, never the equality operators.Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context!

How not to write Python code – Ikke's blog Lately I’ve been reading some rather unclean Python code. Maybe this is mainly because the author(s) of the code had no in-depth knowledge of the Python language itself, the ‘platform’ delivered with cPython,… Here’s a list of some of the mistakes you should really try to avoid when writing Python code: Some days ago RealNitro pointed me at this list of essential Python readings. That’s about it for now, maybe I’ll add some more items to this list later on. Posted in Development, Technology. Tagged with Development, python. By Nicolas – February 8, 2008

Reverse a linked list in java « Think ! If you search for it you will get millions of solutions but sadly (like many things in internet) the first few solutions seem unintuitive and unnecessarily complex for such a simple problem, not sure why, anyway putting mine out there for somebody to point out why I should go for a more complex solution. [in java for a change] Idea : Use two references and reverse their links and proceed till we reach the end public void reverse_iterative { if(isEmpty()) { return;} //curr == null Node currNode,nextNode , loopNode; currNode = head; nextNode =; = null; while(nextNode != null) { loopNode =; = currNode; currNode = nextNode; nextNode = loopNode; } head = currNode; } Recursive Idea : Reverse the sublist starting from second node and point the second node to first, apply this recursively. Share This

Chemoton § Vitorino Ramos' research notebook PEP 257 -- Docstring Conventions What is a Docstring? A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition. Such a docstring becomes the __doc__ special attribute of that object. All modules should normally have docstrings, and all functions and classes exported by a module should also have docstrings. String literals occurring elsewhere in Python code may also act as documentation. String literals occurring immediately after a simple assignment at the top level of a module, class, or __init__ method are called "attribute docstrings".String literals occurring immediately after another docstring are called "additional docstrings". Please see PEP 258, "Docutils Design Specification" , for a detailed description of attribute and additional docstrings. XXX Mention docstrings of 2.2 properties. For consistency, always use """triple double quotes""" around docstrings. There are two forms of docstrings: one-liners and multi-line docstrings. Multi-line Docstrings

PyPy Status Blog Jeff Erickson's Algorithms Sadly, this page has become embarrassingly stale. Updated revisions of most notes, along with unedited video captures of several lectures, are indeed available on the web sites of my most recent courses: (You might notice that some of the updated notes look more like book chapters.) Check back this summer for a major update to this page, complete with three more years of homeworks, exams, and lab problems. This page contains lecture notes and other course materials for various algorithms classes I have taught at the University of Illinois, Urbana-Champaign. New Jan 2015: In addition to the algorithms notes I have been maintaining since 1999, this page also contains new notes on "Models of Computation", which cover a small subset of the material normally taught in undergraduate courses in formal languages and automata. Each lecture note includes several exercises, and a near-complete archive of my old homeworks, exams, and discussion problems also follows the lecture notes on this page.