BST - Cây nhị phân
Dữ liệu vào: Standard input
Dữ liệu ra: Standard output
Giới hạn thời gian: 1.0 giây
Giới hạn bộ nhớ: 128 megabyte

/ckfinder/userfiles/files/BST.pdf

Ta xem xét thủ tục dựng cây nhị phân đệ quy như sau:

void build(int L, int R, int h)
{
    if (L>R)
        return;
    int r=max(L,R-(1<<h-1)+1);
    cout<<r<<' ';
    build(L,r-1,h-1);
    build(r+1,R,h-1);
}

Ví dụ

  • input
    4 9
    output
    1 2 3 4
Back to Top