only do if u can do all questions please
Posted: Sat May 14, 2022 6:36 pm
only do if u can do all questions please
40 78 10 SO 93 17 30 38 Figure 2. A Tree
10. Assume the tree on Figure 2 is a BST and we want to search for number "g" in it. What is the output of int Tree.search(8)? Trace the code below. You can draft a tree in the empty square below and visually explain your answer using this tree (how the search worked) step by step. Output: (3 points) goverride /** Returns true if the element is in the tree / public boolean search(e){ Treehode<E> current - roots / Start from the root while (current le null) { if (e.compare(e, current.element) < 0) { current current.left; 2 else if (c.compare(e, current.element) > e) { current - current.right; > else // element matches current.element return true; // Element is found > return false;
40 78 10 SO 93 17 30 38 Figure 2. A Tree
10. Assume the tree on Figure 2 is a BST and we want to search for number "g" in it. What is the output of int Tree.search(8)? Trace the code below. You can draft a tree in the empty square below and visually explain your answer using this tree (how the search worked) step by step. Output: (3 points) goverride /** Returns true if the element is in the tree / public boolean search(e){ Treehode<E> current - roots / Start from the root while (current le null) { if (e.compare(e, current.element) < 0) { current current.left; 2 else if (c.compare(e, current.element) > e) { current - current.right; > else // element matches current.element return true; // Element is found > return false;