But the question which I asked is pre-order and post-order's predecessor and successor

The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

0 votes

e.g inorder of a BST is increasing sorted order

3 5 8 12 15 21 25 27 31 35

if u want to find inorder successor of 15

u can see it is 21

Now how to find it in BST inorder successor of 15

pick up right subtree of 15 and find minimum element there which is 21

And to minimum element in BST you have to travel to leftmost branch upto leave i.e go left left left upto leave

**Overall Conclusion : 1. Pick right subtree
2. then go left left left ..... find minimum element in that subtree which is leftmost element**

If you understand this predecessor is just reverse of it

lemme know if you still have problem

- All categories
- General Aptitude 1.8k
- Engineering Mathematics 7.3k
- Digital Logic 2.9k
- Programming & DS 4.9k
- Algorithms 4.3k
- Theory of Computation 6k
- Compiler Design 2.1k
- Databases 4.1k
- CO & Architecture 3.4k
- Computer Networks 4.1k
- Non GATE 1.4k
- Others 1.4k
- Admissions 596
- Exam Queries 577
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 18

49,541 questions

54,071 answers

187,187 comments

70,978 users