Data Structures, Algorithms, And Big O Notation! A Beginners Guide.

I may or may not regret this decision, but I’m sticking to it.

Data Structures, what are they?

  • Array: data is organized within brackets in sequential order. Each data entry within these brackets is called an element and is separated by a comma. These elements can be accessed via numbered indexes which start at 0 and increment per data entry. A Javascript example would be:
below is an example of how to extract a value from this array
> catchPhrase[0]
"Big"
  • Hash: data is organized within braces with a key pointing to a value. These key/value pairs are generally separated by a coma. The data (value) can be accessed by its key. This has the advantage of having a constant reference point to access said value. The syntax for this varies in different languages, and in Javascript this is called an object. Here’s a Javascript example:
below is an example of how to extract a value from this hash
> characters['Android']
"Dorothy"
A visual aid for different data structures, these can even be nested inside one another.

What is an Algorithm?

  1. Be a Bruce Wayne esq. billionaire.
  2. Either go to giant robot building school or hire someone who has.
  3. Buy required tools and materials.
  4. Assemble Gundam Wing style robot or hire someone to do so.
below are some examples of different returns this function might have, this function uses the previously defined catchPhrase array by default.
> findIndexOfElement("Showtime!")
2
> findIndexOfElement("Not Present")
false

A Brief Description Of Big O Notation

Sadly this has absolutely nothing to do with Big O Notation, but I’m stubbornly keeping this analogy.
  • Constant Time or O(1) the algorithm has a constant run time relative to its input. Generally this is something that can be done in one “step”
  • Linear Time or O(n) the algorithms execution time increases relative to the size of its input. Generally this is some basic iteration
  • Quadratic Time or O(n²) the algorithms execution time increases relative to the size of its input squared. Generally this involves looped iteration
As you can imagine the runtime for this increases exponentially as the input increases because you are iterating through the entire array per element.

Conclusion

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Say Hello to YELD v4

Spring Framework — Benefits in Automation

“Unable to evaluate the loss function. Check the loss function and ensure it

How to Incrementally Develop an Algorithm using Test Driven Development — The Prime Factors Kata

7 Ways Testers Could Help Leverage The Quality Assurance Process

New Challenges

Using field parameters in Power BI to dynamically create hierarchies with a single select slicer

Accident Lawyer Sandy Utah

accident lawyer sandy utah

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ryan Schleck

Ryan Schleck

More from Medium

How to convert strings into an array of characters.

Communication Layer in Real Time Applications (Read if you wanna learn about WebSockets and Long…

The Developer Apprentice Journey (Week XVI)

Deadlines | Distractions