Speeding Up Your Code With Big O


Exercises for Chapter #4 of A Common-Sense Guide To Data Structures and Algorithms

Get The Book!

Chapter Exercises


Exercise #1

Regarding the array [50, 60, 70, 20, 30, 10]:

  1. Describe the exact steps that Bubble Sort would take on the array.
  2. How many comparisons occurred?
  3. How many swaps occurred?

Exercise #2

Regarding the array [10, 20, 30, 40, 50, 60]:

  1. Describe the exact steps that Bubble Sort would take on the array.
  2. How many comparisons occurred?
  3. How many swaps occurred?

Exercise #3

Regarding the array [60, 50, 40, 30, 20, 10]:

  1. Describe the exact steps that Bubble Sort would take on the array.
  2. How many comparisons occurred?
  3. How many swaps occurred?

Exercise #4

Describe the following code in terms of Big O Notation:

Let's Get In Touch!


Join the forum on The Pragmatic Programmers website to join in on the conversation about this book, or email Jay Wengrow, author of the book and this website directly.