Cory Althoff - The Self-Taught Computer Scientist

Здесь есть возможность читать онлайн «Cory Althoff - The Self-Taught Computer Scientist» — ознакомительный отрывок электронной книги совершенно бесплатно, а после прочтения отрывка купить полную версию. В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: unrecognised, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

The Self-Taught Computer Scientist: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «The Self-Taught Computer Scientist»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

The Self-Taught Computer Scientist
The Self-Taught Programmer
In
, Cory showed readers why you don't need a computer science degree to program professionally and taught the programming fundamentals he used to go from a complete beginner to a software engineer at eBay without one.
In
, Cory teaches you the computer science concepts that all self-taught programmers should understand to have outstanding careers.
will not only make you a better programmer; it will also help you pass your technical interview: the interview all programmers have to pass to land a new job.
Whether you are preparing to apply for jobs or sharpen your computer science knowledge, reading
will improve your programming career. It's written for complete beginners, so you should have no problem reading it even if you've never studied computer science before.
 

The Self-Taught Computer Scientist — читать онлайн ознакомительный отрывок

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «The Self-Taught Computer Scientist», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

# Internal stack # n = 3 [return n * factorial( n - 1), 2]

Finally, because Python knows the last return result, it can calculate the previous return result, remove the previous result from the stack, and return the answer.

3 * 2 = 6 # Internal stack [return 6]

As you can now see, calculating the factorial of a number is a perfect example of a problem you can solve by finding solutions to smaller instances of the same problem. By recognizing that and writing a recursive algorithm, you created an elegant solution to calculate a number's factorial.

When to Use Recursion

How often you want to use recursion in your algorithms is up to you. Any algorithm you can write recursively, you can also write iteratively. The main advantage of recursion is how elegant it is. As you saw earlier, your iterative solution to calculate factorials took six lines of code, whereas your recursive solution took only four. A disadvantage of recursive algorithms is that they often take up more memory because they have to hold data on Python's internal stack. Recursive functions can also be more difficult than iterative algorithms to read and debug because it can be harder to follow what is happening in a recursive algorithm.

Whether or not you use recursion to solve a problem depends on the specific situation, for example, how important memory usage is versus how much more elegant your recursive algorithm will be than a corresponding iterative algorithm. Later in the book, you will see more examples where recursion offers a more elegant solution than an iterative algorithm, like traversing a binary tree.

Vocabulary

iterative algorithm: An algorithm that solves problems by repeating steps over and over, typically using a loop.

recursion: A method of solving a problem where the solution depends on solutions to smaller instances of the same problem.

base case: A condition that ends a recursive algorithm to stop it from continuing forever.

factorial: The product of all positive integers less than or equal to a number.

Challenge

1 Print the numbers from 1 to 10 recursively.

Конец ознакомительного фрагмента.

Текст предоставлен ООО «ЛитРес».

Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.

Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «The Self-Taught Computer Scientist»

Представляем Вашему вниманию похожие книги на «The Self-Taught Computer Scientist» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «The Self-Taught Computer Scientist»

Обсуждение, отзывы о книге «The Self-Taught Computer Scientist» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x