DS&A

Data Structures and Algorithms

Recursive Sorting

Apr 162018

In the previous post we saw two iterative sorting algorithms: selection sort and insertion sort both work using a loop to put the right values in the right places, one at a time. They are two of the simplest sorting algorithms. But they’re not very efficient — for long lists, they’re too slow.(1)

In this post we’ll see one of the simplest efficient sorting algorithms, called merge sort. Rather than sorting items one-by-one, it works by recursively sorting shorter lists.

Depth-First Search

Apr 092018

Search problems vary in two ways: what do we want to search for, and what type of collection are we searching in?(1)

When we need a search algorithm, the data structure we want to search is more important than what we want to find. We could even say that linear search and binary search work on different data structures: linear search uses a list, and binary search uses a list which must be kept in order.(2)

Three Ways to Think About Recursion

Mar 122018

Like all important ideas, recursion can be thought about in many ways, and there is no single “correct” or “best” way to think about it. Rather, each way of thinking is useful for some purposes, but not helpful in every situation.

In the posts about recursion on trees and linked lists, we thought about:

  • What recursion is,
  • How to find recursive structures in problems, and
  • How to write simple recursive functions to solve those problems.

We haven’t yet thought about how recursive functions actually work — what happens when a recursive function is called? In this post we’ll see three different ways to think about how recursive functions are actually computed.

Atom

hosted on werp.site