Swift Programming Algorithm & Data Structure - Convert Sorted Array to Binary Search Tree

preview_player
Показать описание
I love the Swift programming language. In this channel, I will showcase anything that I am building or solving via the Swift programming language.

In this video, I have attempted to solve an algorithm / data structure question. The question today is about converting a sorted array into a Binary Search Tree (BST).

In this video you'll watch my take on how I solve this problem:

1. Create a TreeNode class for us to build a Tree

2. Create the class SortedArrayToBST to handle the conversion

3. The key point to note is about the array is already sorted. Hence, I chose to use Binary Search to build the Binary Search Tree. We created a helper method that will be used recursively to build the left and right side of the node once root node is created.

4. As this problem may have more than one answer, i ended the video after building the function. Feel free to test and validate this answer.

Hope this video is helpful! Would be looking forward to upload more videos relating to me attempting to solve some Algorithm and Data Structure questions in my current favourite language, Swift. Will try to ramp up production quality as time comes. =]

#swiftprogramming #swiftalgorithm #swiftdatastructures
Рекомендации по теме
visit shbcf.ru