Dsa
Binary Search Tree
Easy
BST to Sorted Array
Given a binary search tree, write a program that converts it to a sorted array. The input will be given as a pre-order traversal of the BST.
Input Format:
A single line containing integers of the BST in pre-order traversal.
Output Format:
Print the sorted array of the BST elements.
Example:
Input:
4 2 1 3 6 5 7
Output:
1 2 3 4 5 6 7
Key concepts
binary_search_treetraversalarray_conversion
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now