data structures and algorithm

Breadth First Traversal

Introduction This is the first article in the Graph Traversals – Online Classes. Dear Readers, these set of posts under Graph Traversals will make more sense if you have read the Graph Theory. Here is a quick brush up for the same. However, if you are familiar with Graph Theory and have a basic knowledge of what graphs are and how they are stored, you can dive into the traversals. Later in the series we will discover that the Graph Traversals are widely used in various application. Let me point out a couple of real world examples here: How can we conduct matches between teams in a C...
Read More

Complex Graph Operations

Introduction This is the fourth article in the Graph Theory - Online Classes. After learning the basic graph operations, its time to dive deeper and have some understanding about the complex operations which we can be done over a graph or a set of graphs. To learn about the basics you can always visit Graph Theory Basics. Complex Graph Operations Union of Graphs The union of two graphs G(VG, EG) and H(VH, EH) is the union of their vertex sets and their edge families. Which means G ∪ H = (VG ∪ VH, EG ∪ EH). The below image shows a union of graph G and graph H. Make sure that all the v...
Read More

Graph Operations

Introduction This is the third article in the Graph Theory - Online Classes. With some basic concepts we learnt in the previous two articles listed here in Graph Theory, now we have enough tools to discuss some operations on any graph. In this article we will try to define some basic operations on the Graph. Graph Operations - Extracting sub graphs In this section we will discuss about various types of sub graphs we can extract from a given Graph. Sub graph Getting a sub graph out of a graph is an interesting operation. A sub graph of a graph G(V,E) can be obtained by the following...
Read More

Special Graphs

Introduction This is the second article in the Graph Theory - Online Classes. Dear readers, I assume that you have already finished reading the first post, if not I would advise you to please go through the first article in the series Introduction to Graph Theory, as this post will require some basic knowledge which we discussed in the previous post. Few Special Graphs The Null Graph The first graph we will discuss is the Null Graph. By definition, this graph has a V(G) which is non-empty and a E(G) which is empty. In simple words a graph which only has vertices and no edges is a Null...
Read More

Tree Diameter

Introduction This is the fifth article in the Tree Traversals - Online Classes. A very interesting problem is to find the diameter of a tree. The challenge is not in coding the algorithm but in understanding the meaning of the problem. We will try to define the problem so that visualizing the solution becomes easy. Defining the problem - Tree Diameter Few confusions about the diameter must be avoided before we start. The tree diameter is always the distance between two leaf nodes The diameter may or may not pass through the root. The diameter can also lie on one of the two sides,...
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