是否二叉搜尋樹

2021-09-01 09:24:25 字數 1073 閱讀 1791

是否二叉搜尋樹 (25 分)

本題要求實現函式,判斷給定二叉樹是否二叉搜尋樹。

bool isbst ( bintree t );
其中bintree結構定義如下:

typedef struct tnode *position;

typedef position bintree;

struct tnode;

函式isbst須判斷給定的t是否二叉搜尋樹,即滿足如下定義的二叉樹:

定義:乙個二叉搜尋樹是一棵二叉樹,它可以為空。如果不為空,它將滿足以下性質:

如果t是二叉搜尋樹,則函式返回true,否則返回false。

#include #include typedef enum  bool;

typedef int elementtype;

typedef struct tnode *position;

typedef position bintree;

struct tnode;

bintree buildtree(); /* 由裁判實現,細節不表 */

bool isbst ( bintree t );

int main()

/* 你的**將被嵌在這裡 */

是否二叉搜尋樹

本題要求實現函式,判斷給定二叉樹是否二叉搜尋樹。函式介面定義 bool isbst bintree t 其中bintree結構定義如下 typedef struct tnode position typedef position bintree struct tnode 函式isbst須判斷給定的t...

是否二叉搜尋樹

習題4.3 是否二叉搜尋樹 25 分 本題要求實現函式,判斷給定二叉樹是否二叉搜尋樹。bool isbst bintree t 其中bintree結構定義如下 typedef struct tnode position typedef position bintree struct tnode 函式...

是否二叉搜尋樹PTA

本題要求實現函式,判斷給定二叉樹是否二叉搜尋樹。bool isbst bintree t 其中bintree結構定義如下 typedef struct tnode position typedef position bintree struct tnode 函式isbst須判斷給定的t是否二叉搜尋樹...