Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Written by Prashant Basnet
<section class="bg-white dark:bg-gray-900 px-4 py-8 max-w-2xl mx-auto text-gray-800 dark:text-gray-200">
<h1 class="text-2xl sm:text-3xl font-signature italic font-semibold text-center mb-4">
👋 Welcome — You’ve Landed on My Signature Page
</h1>
<p class="text-base sm:text-lg mb-4">
Hey, I’m <strong class="text-black dark:text-white">Prashant Basnet</strong> — software developmemt engineer at
<a href="https://unisala.com" class="text-indigo-600 dark:text-indigo-400 underline hover:no-underline" target="_blank" rel="noopener noreferrer">
Unisala.com
</a>.
</p>
<p class="text-base sm:text-lg mb-6">
You’re viewing my <strong>Signature</strong>, a digital space where I share what I’m learning, building, and reflecting on, all in one place.
</p>
<div class="border-l-4 border-indigo-400 dark:border-indigo-500 pl-4 italic mb-6 text-sm sm:text-base text-gray-700 dark:text-gray-400">
📍 Found this page via LinkedIn, my personal site, or a shared link?
<br />
This isn’t a traditional portfolio. It’s my public digital notebook where I document useful ideas, experiments, and lessons I’ve learned as I build.
</div>
<h2 class="text-lg font-semibold mb-2">What You’ll Find Here:</h2>
<ul class="list-disc list-inside space-y-1 text-sm sm:text-base">
<li>✍️ Thoughts on algorithms, systems, and software design</li>
<li>🧠 Insights from building at Unisala</li>
<li>🔗 Direct links to everything I’ve published on Unisala</li>
</ul>
</section>
What are some real world usage of this tree comparison algorithm?
1. Facebook: React's Virtual DOM:
2. Amazon: Merkle Trees in S3 and DynamoDB:
2. Google: Google Drive File Sync:
Now that we understand what's the use of this algorithm. let's look into our actual question of comparing if two binary trees given to us are same or not.
Given the roots of two binary trees p and q, write a function to check if they are the same or not.
Two binary trees are considered the same if they are structurally identical, and the nodes have the same value.
Derivatives:
How do we link this solution to check if the tree are identical?
To me this sounds reasonable solution??
BFS ensures that the nodes are visited level by level. However, two trees can have the same BFS result but different structures. For example:
Both trees would produce the same BFS result [1, 2], but they are structurally different.
So does it have to do anything with BFS or DFS at all?
All we know is we need to traverse all the nodes in a tree and compare to each other as we traverse.
To me if we are solving same nature of problem over and over again it is some kind of recursive problem.
Does that ring a bell? Recursive is how our DFS are designed.
We want to compare these nodes as we go through: i.e grab as you go (Pre-order)
Now next few questions we need to tackle:
Complexity:
Following up questions:
let's continue the discussion!!
#blind75 #tree #binaryTree