binary-tree

    -2熱度

    2回答

    public static Node insert(Node root, int data) if (root == null) return new Node(data);

    1熱度

    1回答

    今天我收到了一個作業,約function pointer(binary tree)。 有代碼,我無法理解一大塊......我明白了一個function pointer是什麼以及它是如何工作的,但怎麼樣2 function pointers(1處於parameter) header.h typedef struct _node_ { int key; struct _node_ *left;

    -1熱度

    2回答

    沒有人知道如何將值保存到左側或右側的二叉樹中? 比如我們有2層結構: struct A { int a; struct A *left; struct A *right; } struct B { A *root; } ,我們有一個功能: void insert(B *tree, int value) { if(tree== NU

    -1熱度

    1回答

    PHYTON - 如何在此代碼中創建一個功能來打印每個節點的層次? referrer=input() location=input() readFAQ=input() pagesVisited=input() serviceChosen=input() testCase=[referrer, location, readFAQ, pagesVisited, serviceChosen

    -1熱度

    1回答

    System.NullReferenceException:對象不設置到對象的實例 public int find(int value) { Node curr = root; while (curr != null) { if (curr.value == value) { return value;//success }

    1熱度

    2回答

    我真的被困在試圖弄清楚這一點。 這是樹: 5 /\ 4 8 //\ 11 13 4 / \ \ 7 2 1 問: 創建一個函數來搜索上面給出的二叉樹的值。如果找到該值,該函數應返回指向該節點的指針;否則函數應該返回一個空指針。這些參數應該是一個指向二叉樹根節點的指針和一個要搜索的值。 BinaryTree *sear

    2熱度

    2回答

    我有一個問題,解析樹代碼。當我試圖用後期訂單展示它時,它給了我一個錯誤消息,應該是str參數,而不是int。 from classStack import Stack from classTree import BinaryTree def buildParseTree(fpexp): fplist = fpexp.split() pStack = Stack()

    -4熱度

    1回答

    例如全部打印出來: 1 / \ / \ 2 3 /\ /\ 4 5 6 7 序遍歷輸出:4 2 5 1 6 3 7 預期輸出:4 -2爲序5 -1 6 -3 7 代碼是 Node * func(struct Node * root){ if(root!=NULL) { func(root->lChild); cout<<root->no

    2熱度

    4回答

    我試圖實現一個二叉搜索樹,我需要一個函數告訴我一個元素是否已經存在於樹中! 但是我唯一可以使用的運營商是<。 這甚至可能嗎? 我已經嘗試過 和(a<b) || (b<a)!(a<b) && !(b<a) 注:我只允許使用<比較我的元素二叉樹。

    1熱度

    2回答

    如何發送(node.data)SortTree類到TreePrinter然後用於打印樹。 import javax.swing.tree.TreeNode; public class SortTree { static Node root; TreePrinter type =new TreePrinter(); class Node<A extends Comparable>{