I am a software Engineer. I have worked with companies like Digismart, ARI Networks, SVG Media, and I am sure, 99% of you might not have heard about these companies. Whenever I tell my friends and relatives about my company, I have to repeat it 2 or 3 times to…

An empty tree is height balanced. A non empty binary tree T is balanced if

  1. Left subtree of T is balanced
  2. Right subtree of T is balanced
  3. The difference between heights of left subtree and right subtree is not more than one. This above height balancing scheme is used in AVL trees.
  4. Get height of right and left tree. return true if difference between height is not more than one.
class BinaryTree{
Node root;
boolean isBalanced(Node node){
int lh;
int rh;
if(node == null)
return true;
lh = heigh(node.left);
rh = height(node.right);
if(Math.abs(lh -rh)<= 1 && isBalanced(node.left) && isBalanced(node.right))
return true;
return false;
int height(Node node){
if(node == null)
return 0;
return 1+Math.max(height(node.left), height(node.right)); }}

Time complexity. O(n²) worst case, occurs in case of skewed trees.

So basically we have two methods by which we can implement queue using stacks.

  1. By Making Enqueue operation costly
  2. By Making Dequeue operation costly

Let’s see which one we should choose.

Method 1: By making enqueue operation costly. This method makes the oldest element always at the top of stack…

I have taken a course on udemy for microservices architecture and I am going to describe the case study given over there. We will go through the main steps of architecture process:

  1. Functional Requirements
  2. Non Functional Requirements
  3. Mapping the components
  4. Define communication pattern

We are going to discuss Library Management…

Navneet Ojha

I am Indian by birth, Punjabi by destiny. Humanity is my religion. Love to eat, travel, read books and my million dreams keep me alive.

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