In this blog, we implement a Quicksort in JavaScript. Quicksort is an algorithm used to sort arrays with a divide and conquer technique. First, we select a pivot element of the array, in this case the middle element. Next, we swap elements that are greater than or less than the pivot and produce 2 sub-arrays. When successful, the sub-array on the right only contains elements that are greater than the pivot, and the one on the left only contains elements that are less than the pivot. After this step, we know that the pivot element has found its’ final position…
The Fibonacci sequence is a sequence of numbers where the next number in the sequence is the sum of the previous 2 numbers. It is typically illustrated like this:
In this blog, I’ll be dipping my toes into the basics of how recursion works. I’ll implement two different solutions in Ruby to find the element of the Fibonacci sequence specified. The first solution is more standard coding practice while the second uses a more elegant, recursive solution to do the job.
The first solution takes in a number n, and creates a Fibonacci sequence from the beginning all the way…
As I try to wrap my brain around all of these different data structures that exist in the world of programming, today I’m looking into linked lists and how they differ from arrays. Each structure is a way to store groups of data and provide different advantages and disadvantages when working with the structure.
I’m currently learning the Ruby programming language, and I was curious what kind of search is used in Ruby’s .find method for arrays. After a bit of searching around the docs, then figured why not find out for myself. I was interested to see what method of searching .find uses, and whether it was the fastest method to search through arrays or not.
To find this out, I wrote Ruby methods for linear search and binary search, implemented them, and tested their benchmarks with different sized arrays.
Here is how I implemented linear search:
Here is how I implemented binary…
Software Engineer