Question bank › Binary Search Tree
Dsa Binary Search Tree Medium

Flatten BST to Sorted Linked List

Given a binary search tree (BST), flatten it into a sorted linked list in place. You should not create new nodes, just rearrange the existing nodes' pointers to create a right-skewed structure. The left child of each node should be null. Input format: - The first line contains an integer N, the number of nodes in the BST. - The next N lines contain three integers each: the current node value, the left child value, and the right child value (where a value of -1 indicates no child). Output format: - Print the flattened list as space-separated values from leftmost to rightmost. Example: Input: 5 3 1 4 1 -1 -1 4 -1 5 5 -1 -1 -1 -1 -1 Output: 1 3 4 5

Key concepts

binary_search_treetree_traversal

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
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.