BST - 21: Convert BST to Sorted Doubly Linked List (DLL)

Описание к видео BST - 21: Convert BST to Sorted Doubly Linked List (DLL)

Source Code: https://thecodingsimplified.com/conve...
Solution
We traverse the binary tree in inorder manner
We take a global variable 'prev' & 'headOfList'
We assign lowest node as headOfList. This is when prev is null.
When prev is not null, then node.left = prev & prev.right = node
After each iteration we update the prev to current node

Time Complexity: O(n)
Space Complexity: O(1)

For more info, please see the video.

CHECK OUT CODING SIMPLIFIED
   / codingsimplified  

★☆★ VIEW THE BLOG POST: ★☆★
http://thecodingsimplified.com

I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 500+ videos.

★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★
https://www.youtube.com/codingsimplif...

★☆★ Send us mail at: ★☆★
Email: [email protected]

Комментарии

Информация по комментариям в разработке