Showing posts with label searching algorithms. Show all posts
Showing posts with label searching algorithms. Show all posts

Thursday, September 7, 2023


 Depth-First Search - Postorder Traversal of a Binary Tree



Intro


The Postorder traversal is another strategy of the Depth-First Search algorithm.
In the previous posts, we covered the Preorder and Inorder traversals of a Binary Tree.

Here, we will go through and understand the Postorder traversal and see how we can implement it.


Wednesday, September 6, 2023

 Depth-First Search - Inorder Traversal of a Binary Tree



Intro

In the previous post, we covered the Preorder traversal of a Binary Tree, and here, we'll go through one more DFS strategy of a tree traversal: Inorder Traversal. It is similar to the Preorder, just the order in which we visit the nodes is a bit different.

Depth-First Search - Preorder Traversal of a Binary Tree



Intro


In the previous post, we've covered the Depth-First Search algorithm.
We said that there are three strategies for the DFS traversal: Preorder, Inorder, and Postored. In this post, we'll cover the Preorder traversal of a Binary Tree.

Monday, September 4, 2023

 Depth-First Search


Intro


There are two ways to traverse the tree data structure: Breadth-first search (BFS) and Depth-First Search (DFS).

We've already covered the BFS and Order Lever traversal of a Binary Tree. Here, we will explore the Depth-First Search algorithm and the ways we can traverse the tree using it.

 Breadth-First Search (Level Order Traversal)


Intro


We use the Breadth-First Search algorithm to traverse the Tree data structures. It is usually used when we want to determine if some value is present in the Binary Tree.


 Binary Search


Intro


Binary search is an efficient divide-and-conquer algorithm for finding an item from a sorted list of items.
It has a time complexity of O(n log n).


 Linear Search


Intro


Linear search is a fairly simple searching algorithm with a time complexity of O(n).
It is a well-suited algorithm for small datasets. It can be used for both sorted and unsorted datasets.