Abhimanyu Singh
231 FOLLOWERS
Keep up with articles from Abhimanyu Singh.
Abhimanyu Singh
3w ago
The real magic happens when efficiency and curiosity work hand in hand ..read more
Abhimanyu Singh
2M ago
Job satisfaction isn’t a luxury; it’s a necessity. It’s the driving force behind our motivation, productivity, and overall well-being. Beyond the tangible benefits like pay and perks, the intangible aspects often play a pivotal role in our overall job contentment. But how do we measure these intangibles?
Pillars of Job Satisfaction
Understanding the core attributes that influence our job satisfaction is crucial. Let’s delve into each:
1. Value Contribution: It’s the sense of purpose. Satisfaction naturally follows when you feel your work is impactful and aligns with the company’s goals.
2 ..read more
Abhimanyu Singh
3y ago
Problem Statement
We want to create a balanced binary tree that supports insertion in O(log N) time, deletion, and search operations.
Let’s have the following two constraints on insertion:
We insert a node in the next level if the current level is complete.
We create a right child if the left child is already present.
With these constraints, we guarantee that the binary tree is a complete binary tree that could be a perfect binary tree, given that we insert the right amount of nodes in the tree. Also, the binary tree will be a balanced binary tree.
Representation
First of all, we n ..read more
Abhimanyu Singh
3y ago
Problem Statement
We want to create a balanced binary tree that supports insertion in O(1) time, deletion, and search operations.
Let’s have the following two constraints on insertion:
We insert a node in the next level if the current level is complete.
We create a right child if the left child is already present.
With these constraints, we guarantee that the binary tree is a complete binary tree that could be a perfect binary tree, given that we insert the right amount of nodes in the tree. Also, the binary tree will be a balanced binary tree.
Representation
First of all, we need ..read more
Abhimanyu Singh
3y ago
Representation
We represent the node as:
Node => Value Node Left Node Right
Level-order Traversal
We traverse the tree level-by-level because we want to cover the breadth. We first traverse all the nodes in a level and then traverse the next level guaranteeing a unique visit order. We visit the root node first and then visit its child nodes, then their child nodes, etc.
The traversal is complete once we have visited all the nodes in the tree.
Level-order TraversalExample
We will do the level-order traversal on the following binary tree:
Binary Tree for Level-o ..read more
Abhimanyu Singh
3y ago
Representation
We represent the node as:
Node => Value Node Left Node Right
Post-order Traversal
The post-order traversal is a kind of depth-first traversal. We perform the following steps:
Recursively traverse the node’s left subtree in post-order
Recursively traverse the node’s right subtree in post-order
Access the node
After traversing the left and the right subtrees of the root node, we consider the traversal complete.
Post-order TraversalExample
We will do the post-order traversal on the following binary tree:
Binary Tree for Post-order Traversal
The nodes ..read more
Abhimanyu Singh
3y ago
Representation
We represent the node as:
Node => Value Node Left Node Right
In-order Traversal
The in-order traversal is a kind of depth-first traversal. We perform the following steps:
Recursively traverse the node’s left subtree in in-order
Access the node
Recursively traverse the node’s right subtree in in-order
After traversing the left and the right subtrees of the root node, we consider the traversal complete.
In-order TraversalExample
We will do the in-order traversal on the following binary tree:
Binary Tree for In-order Traversal
The nodes in y ..read more
Abhimanyu Singh
3y ago
Representation
We represent the node as:
Node => Value Node Left Node Right
Pre-order Traversal
The pre-order traversal is a kind of depth-first traversal. We perform the following steps:
Access the node
Recursively traverse the node’s left subtree in pre-order
Recursively traverse the node’s right subtree in pre-order
After traversing the left and the right subtrees of the root node, we consider the traversal complete.
Pre-order TraversalExample
We will do the pre-order traversal on the following binary tree:
Binary Tree for Pre-order Traversal
The nodes in yell ..read more
Abhimanyu Singh
3y ago
In this story, we familiarize ourselves with the different types of traversals. We cover each traversal in detail in separate stories. You can find the links at the end of the story.
What is traversal?
Traversal is iterating over the nodes in the tree exactly once. We can traverse the tree in the following two ways:
We first cover the depth, i.e., depth-first traversal
We first cover the breadth, i.e., breadth-first traversal
Depth-first Traversal
As we cover the depth-first, we iterate on the nodes along the path from the root to leaf nodes. Consider the following binary tree ..read more