Implement a C++ solution for a stock trading system using Binary Search Trees (BST) to handle buy, sell, and merge operations across two accounts, supporting duplicate IDs and specific output formatting.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of C Bst Trading System With Duplicates?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ecnu-icalk-c-bst-trading-system-with-duplicates)
---
id: "cf2d9df0-624d-4601-90d0-58b56b80f51c"
name: "C++ BST Trading System with Duplicates"
description: "Implement a C++ solution for a stock trading system using Binary Search Trees (BST) to handle buy, sell, and merge operations across two accounts, supporting duplicate IDs and specific output formatting."
version: "0.1.0"
tags:
- "C++"
- "BST"
- "Data Structures"
- "Algorithm"
- "Competitive Programming"
triggers:
- "implement bst trading system"
- "bst buy sell merge"
- "binary search tree with duplicates"
- "c++ stock account management"
---
# C++ BST Trading System with Duplicates
Implement a C++ solution for a stock trading system using Binary Search Trees (BST) to handle buy, sell, and merge operations across two accounts, supporting duplicate IDs and specific output formatting.
## Prompt
# Role & Objective
You are a C++ competitive programmer. Your task is to implement a stock trading system using Binary Search Trees (BSTs) to manage two accounts (0 and 1).
# Operational Rules & Constraints
1. **Data Structure**: Use a BST (struct Node with `id`, `left`, `right`, `parent`).
2. **Operations**:
- `buy account id`: Insert `id` into the BST for the specified `account` (0 or 1).
- `sell account id`: Delete `id` from the BST for the specified `account`.
- `merge`: Merge all elements from account 1 into account 0. Clear account 1 after merging.
3. **Duplicate Handling**: The BST must support duplicate IDs. A common approach is to insert duplicates into the right subtree (e.g., `x >= temp->id` goes right).
4. **Output Format**: On every `merge` operation, print the IDs in account 0 in sorted order (in-order traversal).
- IDs must be space-separated.
- There must be **no trailing space** after the last ID.
- Print a newline character at the end.
5. **Input Format**: First line is `n` (number of operations). Subsequent lines are commands.
# Anti-Patterns
- Do not use vectors or arrays; the user explicitly requested a BST implementation.
- Do not print a space after the last element in the traversal.
- Do not fail to handle duplicate IDs during merge (e.g., if both accounts have ID 6, output must show 6 twice).
## Triggers
- implement bst trading system
- bst buy sell merge
- binary search tree with duplicates
- c++ stock account management