Algorithms: pseudo-code
This course covers algorithms and how to describe them in pseudocode before writing Ruby. It defines an algorithm by three properties: finiteness, definiteness and effectiveness. It presents pseudocode conventions, common patterns and the three control structures. Linear and binary search are compared, along with database indexes in Rails. Bubble sort and selection sort are contrasted with the sorts used in production. Big-O notation, time and space tradeoffs and the N+1 query problem follow. A six-step workflow from problem statement to tested Ruby code closes the course.
What you'll learn
- ✓The three properties of an algorithm and the difference from a heuristic
- ✓Pseudocode conventions and the accumulator, finder, collector and transformer patterns
- ✓Sequence, selection, iteration and guard clauses
- ✓Linear search, binary search and database indexes in Rails
- ✓Bubble sort, selection sort and sort stability in Ruby
- ✓Big-O notation and a six-step workflow from pseudocode to Ruby
What is an algorithm?
An algorithm is a precise, finite sequence of well-defined steps that solves a specific problem or performs a specific task.
Read the full lesson free →Curriculum
7 lessonsWhat is an algorithm?
Defines an algorithm by finiteness, definiteness and effectiveness, with examples in Rails and a comparison with heuristics.
Pseudocode fundamentals
Presents pseudocode conventions, the anatomy of a function, four common patterns and a translation table to Ruby.
Control flow in pseudocode
Covers sequence, selection and iteration in pseudocode, plus guard clauses to avoid deep nesting.
Searching algorithms
Compares linear and binary search and shows how PostgreSQL indexes in Rails apply binary search through B-trees.
Sorting algorithms
Explains bubble sort and selection sort, the O(n log n) sorts used in production, and sort stability in Ruby.
Algorithm efficiency: big-o notation
Introduces Big-O notation, common complexities, time and space tradeoffs, and fixing N+1 queries with includes in Rails.
From pseudocode to Ruby: the full workflow
Walks through a six-step workflow on a case study, with translation patterns and common mistakes when converting to Ruby.