Tuesday common C++ interview problem: Construct a binary tree from preorder and inorder traversals. Given the preorder and inorder traversals (both as std::span<int>), construct the corresponding binary tree. Use the add_node(int) method on the provided tree object and return the root node. Solve it yourself: https://lnkd.in/en7G93vC Solution: https://lnkd.in/eZ9MT4yG #cpp #cplusplus #coding #programming #dailybiteofcpp
Šimon Tóth’s Post
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
ISO/IEC JTC1/SC22/WG21 - The…•11K followers
2yI actually did have an post-order/in-order tree reconstruction problem as an interview question many years ago. Many years before span. That is an interesting twist for a solution. I did it the old pointer based way back then (could have used indexes) but I did templatize the data type. Also for the 'fun' of it my solution used a functor type monad with a hidden friend streaming operator to drive the print order. godbolt.org/z/zso9dMrda