The N-Queens Problem in Scala

Recently at my office I had a discussion about algorithms and the N-Queens problem came up. I didn’t know about it, so I decided to check it out and then I felt like I wanted to write an implementation in Scala. This blog post documents all of this.

Continue reading “The N-Queens Problem in Scala”

Smallest Enclosing Circle Algorithm in Scala

In the last couple of years I have been using the Scala programming language for a large chunk of projects at work. I use it to write batch processing jobs with Spark, APIs using the Play Framework, different Akka programs as well as apps and tools. I’ve even written a book about design patterns in Scala in 2 editions.

Scala is an awesome programming language and I enjoy using it. It is very quick to write complex and efficient code. Of course, if you’re not careful or familiar enough with the language you might pay some price in terms of efficiency, but any programming language is like that. It is a multi-paradigm language that combines object-oriented and functional programming. It runs on the JVM and in theory it is compatible with Java and Java bytecode. And it practically is in most cases.

Continue reading “Smallest Enclosing Circle Algorithm in Scala”

Algorithms: Sorting – Heap Sort

Before we start discussing the topic of this post, we need to point out how important sorting actually is. Almost every problem that one will face in computer science can be solved with sorting as an initial phase. That’s why everybody must know a few good sorting techniques and when they can be used.

Let’s not even consider bubble sort and other algorithms with sqr(n) complexity as this is way too much especially with the amounts of data we see nowadays. If someone gets asked a question with sorting on a job interview, please don’t reply bubble sort! Of course, it is good knowing about it, but there are methods, which are much more suitable.

Continue reading “Algorithms: Sorting – Heap Sort”

Algorithms and Data Structures – Binary Trees

In this article I will present trees. This is another data structure that is really important in computer science and it can be used to model different relationships between real life objects. It could be also helpful as a data structure for some algorithms and also as a base of other data structures like maps or sets for example (tree maps/tree sets).

Continue reading “Algorithms and Data Structures – Binary Trees”

Advanced Operations over Linked Lists

This article continues my previous talk about linked lists and basic operations that can be performed with them. If you haven’t read the first part, I recommend you do this at https://www.ivan-nikolov.com/2017/09/01/algorithms-and-data-structures-linked-lists.

Except just inserting, deleting and searching for elements, a linked list can be reversed, it can have a different sctucture, it can be maintained sorted, etc.

Continue reading “Advanced Operations over Linked Lists”

Algorithms and Data Structures – Linked Lists

Before I even start talking about linked lists in this post, I would like to strongly point out how important algorithms and data structures are. This is something a software engineer uses literally 100% of the time, even if we are talking about the simplest possible task. It is essential for someone to understand what algorithm complexity means and how it can affect their code and more importantly – the quality and the performance of their program.

Continue reading “Algorithms and Data Structures – Linked Lists”