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

  Рет қаралды 8,049

Coding Simplified

Coding Simplified

Күн бұрын

Пікірлер: 7
@avikdutta5965
@avikdutta5965 3 жыл бұрын
space complexity cannot be O(1) because there is recursion function for that we required auxiliary space. So space complexity is near about height of the tree, i.e. O(h) [h = height of the tree]
@lokeshkumarrathinavel6566
@lokeshkumarrathinavel6566 3 жыл бұрын
I liked your explanation... made it easy to understand. Actually I solved leet code - 426. Convert Binary Search Tree to Sorted Doubly Linked List - with this explanation. Everything same.. just make it circular, do this.. head.left = prev and prev.right = head. :) Appreciated!!!Thanks Man.
@CodingSimplified
@CodingSimplified 3 жыл бұрын
Thanks for your nice feedback.
@saisiddana9345
@saisiddana9345 3 жыл бұрын
sir u missed that headlist .left==null
@harish-wi3ts
@harish-wi3ts 4 жыл бұрын
Hi...sir I am unable to solve a single problem in leetcode What are the maths concepts are required...to solve as java developer.sir please do video on this.. or reply me sir. Thanks you.
@CodingSimplified
@CodingSimplified 4 жыл бұрын
Sure, I'll try to these questions. My suggestion is if you finding in leetcode some difficulty, don't focus much on it but start from basics first. For example, in our playlist we've basics to good questions. Once you've some command on a topic, you can see leetcode questions.
@ozanservet
@ozanservet 2 жыл бұрын
I think we should count recursive space complexity in the stack and it might be O(n). My solution is below, I am open to comments; Node dLL = null; public void convertBSTToSourtedDoublyLinkedList(Node node) { if(node == null) { return; } convertBSTToSourtedDoublyLinkedList(node.left); if(dLL == null) { dLL = new Node(node.getData()); } else { Node tmp = new Node(node.getData()); dLL.right = tmp; tmp.left = dLL; dLL = dLL.right; } convertBSTToSourtedDoublyLinkedList(node.right); } public void printdLL() { Node node = dLL; System.out.print("printdLL: "); while(node != null) { System.out.print(node.getData() + " "); node = node.left; } System.out.println(); }
L38. Flatten a Binary Tree to Linked List | 3 Approaches | C++ | Java
21:51
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Flatten Binary Tree to Linked List - Leetcode 114 - Python
14:27
L52. Recover BST | Correct BST with two nodes swapped
15:56
take U forward
Рет қаралды 143 М.
The hidden beauty of the A* algorithm
19:22
Polylog
Рет қаралды 923 М.
BST - 20: Check if given Binary Tree is BST
9:52
Coding Simplified
Рет қаралды 4,9 М.