DEV Community

Whiteboarding in Python
Whiteboarding in Python

Posted on • Updated on

How to Learn Data Structures and Algorithms When You're Fresh Out of Your Bootcamp


(Image Source: Facebook)

Okay, so you just finished your coding bootcamp. You bought this book, Cracking the Coding Interview. You open it up, try to do some problems. When you go to look at the solution, you see some strange things.

For example, to check to see if two strings are equal, the solution suggests string1.equals(string2). Why can't we just use string1 == string2? The book's solutions, detailed as they are, might as well be written in Russian if the only languages you know are JavaScript and Python, and you just learned them a couple months ago. After struggling to make sense of the book, you give up and set it aside, letting it become a big green paperweight on the end of your desk.

System.out.println("Am I having a stroke?");

As it turns out, the solutions are in Java, the object oriented language mainly taught at a number of universities. At least, they taught it at the university I went to, where the CS program is so competitive that a 3.9 grade in the intro course might be egregious enough for them to reject your major application. Perhaps kicking off the first day of class with public static void main(String[] args) is their first attempt to scare off potential CS students.

But in bootcamp, we ain't like that. Everyone is welcome. Anyone can learn to code if they're willing to put in the effort. But also, the program is only 12 weeks, so instead of Java, we'll start with something easier, like Python.

Why do bootcamps teach Python instead of Java?

A number of factors make Python simpler to learn than Java. As stated before, Java is an object oriented language. This means everything must be defined in a class, i.e. everything must be an object. For Java to run your code, you have to put it in the main method (that gibberish I said was used to scare away potential CS majors). Java is also a compiled language, meaning that before it runs, it has to compile for syntax errors. Remember in JavaScript when you missed a semicolon, and everything ran fine anyway? Not so with Java. One missing semicolon means your program won't compile, which means it won't run, either.

And finally, Java is typed, meaning every variable has to be declared with its type. Remember the let keyword in JavaScript? Like "let this variable be like, whatever type idk"? Java wants to know that you want it to be an integer, so instead, you would use the keyword int-- and that variable would have to stay an integer as long as you use it.

Taking all this into consideration, Python syntax looks much cleaner. For example, let's look at what's needed to print "Hello World" to the console with Java versus Python 3.

Main.java

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}
Enter fullscreen mode Exit fullscreen mode

hello_world.py

print("Hello World")
Enter fullscreen mode Exit fullscreen mode

So it's no wonder that they taught you Python instead. Powerful built in methods make for great data analysis, so there are plenty of places to use it in industry. But learning data structures and algorithms isn't about the language you use; it's about the theory behind it. I know, not something they spent a lot of time on in your bootcamp. That's why I'm here.

Every week, I'll be posting simple, easy-to-understand explanations of sample whiteboarding problems, approaching them how you would as a Python developer. Solutions will be posted to a github repo here. Of course, you won't be an expert over night, but I hope some weekly coffee reading will help put you on track to cracking those coding interviews in Python.

See you next time!

Week 1: Stacks >>

Sheamus Heikkila is formerly a Teaching Assistant at General Assembly Seattle. This blog is not associated with GA.

Top comments (0)