Data Structures

This category contains all the posts related to data structures. For e.g.: Hash Tables, Linked Lists, Trees, Graphs, Heaps, Tries etc..

Hashing in detail – Part One

Introduction This is the first post in Hashing - Online Classes. I always wanted to write this article after writing couple of articles on sorting algorithms. It doesn't make any difference, but of course it helps to establish a flow to the reader. There is a lot to understand and learn about hashing and I do not consider it good to throw Hashing on someone as the first article. Please read any of my articles in the Sorting Series before reading further, so that a mindset is properly developed. Purpose of the Article The article Hashing in detail - Part One might not end up in just one ...
Read More

Comb Sort – An extension over the Bubble Sort

Introduction This article is in continuation of the article Improving Bubble Sort – A detailed explanation which I wrote to explain the basic idea behind bubble sort. Purpose of the article This is an improvement over Bubble Sort, an improvement which is pretty much similar to Shell Sort over Insertion Sort. To know more about the relationship between Shell Sort and Insertion Sort, please read the articles in my previous posts. What are we trying to improve? Before we try to improve, we must know what to improve. The thing which is clear is that Bubble sort takes more time (or may I say m...
Read More

Improving Bubble Sort – A detailed explanation

Introduction Ever wondered why bubble sort is slow? Does it look similar to Insertion Sort ? Can it be improved to have better than quadratic time in average cases? Here we start with a detailed analysis of bubble sort in the easiest possible way. Bubble Sort as the name suggests, bubbles up the heaviest (or may be lightest, depending on the comparison operator) elements to the top. Purpose of the article The article Improving Bubble Sort, is dedicated to explain the mechanism behind bubble sort in detail, apart from that, it also offers an improved bubble sort. Moreover, it also helps us ...
Read More

Merge Sort

Introduction Can sorting be made faster? We have seen sorting techniques like (Insertion Sort, Selection Sort and Shell Sort) which have a quadratic running time. With growing size of the inputs, it becomes tough to use these algorithms. Is there any faster alternative? We would like to find answers to these questions in the Merge Sort article. On the other hand if you are interested in watching a video for this article, you can subscribe our Youtube Channel. Purpose of the Article In this article we try to answer the questions mentioned above. Yes there are many faster alternatives....
Read More

How selection sort works – A detailed explanation

Introduction Probably the most crude sorting technique, and also the most in-efficient one. But it's important, because until we know the worst we can't understand the importance of the good and the better. So let us try to find out, how selection sort works. Purpose of the article We will try to understand here, how selection sort works and how is the nature of input affecting the running time of this algorithm. Why this is a crude way of sorting and its advantages and dis-advantages. Idea behind Selection Sort As the name suggests, there is definitely something to select. Lets assume we...
Read More

Merging two Sorted Singly Linked List

Introduction - Merging two Sorted Singly Linked List This question is mostly asked in interviews and hence I thought of writing few possible solutions to the same. I also asked the same question on stackoverflow.com. You can visit the link here Problem Statement You have two singly linked lists that are already sorted, you have to merge them and return the head of the new list without creating any new extra nodes. The returned list should be sorted as well The method signature is: [crayon-59ed8a1d827a1540926137/] Node class is below: [crayon-59ed8a1d827aa620438259/] Solution There c...
Read More