Question

17) Which of the following is a valid binary search tree? 23 12 40 19 30 61 13 21 41 50 23 43 10 18 34 51 15 21 40 50 23 43 10 18 51 15 27 40 50 What is the worst-case runtime of searching for a value in a binary search tree? (a) constant O(1) (b) logarithmic O(logn) (c) linear O(n) 18) Pag

0 0
Add a comment Improve this question Transcribed image text
Answer #1

17) A binary search tree is a node-based search tree with the following properties:

1. The left subtree of a node contains only nodes with keys less than the node's key

2. The rightt subtree of a node contains only nodes with keys greater than the node's key

3. Both the left and right subtree must also be binary search trees.

So, from this we can say that:

(a) is not a valid binary search tree, as 41 is in the left subtree of 40 which is does not comply.

(b) is a valid binary search tree as it complies with the properties of a binary search tree.

(c) is also not a binary search tree as seen in the left subtree of 23, 27 is present which is greater than 23.

18) The worst case runtime of searching for a value in a binary search tree is O(n)

So option C linear O(n) is true

Add a comment
Know the answer?
Add Answer to:
17) Which of the following is a valid binary search tree? 23 12 40 19 30...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Prob. 3. Given the following data 50 40 23 36 19 20 9 a) Is this...

    Prob. 3. Given the following data 50 40 23 36 19 20 9 a) Is this a max heap, draw the tree and check if this is a max heap. b) Illustrate how you would add a new data 46 to the existing maxheap. c) From the answer obtained in part b, illustrate how you would delete the data 40 d) Now illustrate heap sort with the existing data after step c. Give steps, and find runtime. Runtime|Explanation of Algorithm...

  • Suppose a binary tree data (in tiny written size) is stored in an array (A) as...

    Suppose a binary tree data (in tiny written size) is stored in an array (A) as given below and root is placed at “0”index. Note the array indices are in larger written size (0 to 74). Show the traversal data of the given tree for a)      In-Order Traversal b)     Post Order Traversal A 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 28 13 36 15 9 22 44 7 10 75 33 19 15...

  • In the binary search tree below, carry out the following operations in sequence Add 5, add 17, de...

    In the binary search tree below, carry out the following operations in sequence Add 5, add 17, delete 23, delete 9. 15 23 12 19 21 10 In the binary search tree below, carry out the following operations in sequence Add 5, add 17, delete 23, delete 9. 15 23 12 19 21 10

  • A Binary Search Tree is a binary tree where nodes are ordered in the following way:...

    A Binary Search Tree is a binary tree where nodes are ordered in the following way: each node contains one key (also known as data) the keys in the left subtree are less than the key in its parent node the keys in the right subtree are greater than the key in its parent node duplicate keys are not allowed Create a Binary Search Tree inserting the following list of numbers in order from left to right. 10,          6,           4,            8,            18,          15,          21 Please type...

  • 1.(10 pts) Contrast a heap with a binary search tree by inserting the numbers 60, 30,...

    1.(10 pts) Contrast a heap with a binary search tree by inserting the numbers 60, 30, 40, 50, 20, 10 first in a BST and then in a min-heap. Draw the resulting BST on the left and the heap on the right. You may draw any valid BST or Heap that contain the provided values 2. (5 pts) In section 11.1, the book mentions that heaps are **complete** binary trees, what does that mean? Demonstrate by drawing an example of...

  • Starting with an empty binary search tree, insert each of the following keys and rotate it...

    Starting with an empty binary search tree, insert each of the following keys and rotate it to the root in the specified order: 6   1   18   7   15 Starting with an empty red-black binary search tree, insert the following keys in order:: 12   5   23   9   19   2   21   18   7 Show the tree immediately after you insert each key, and after each time you deal with one of the book's cases 1, 2, or 3 (that is, if dealing with one case leads to another, show the additional case as a...

  • Draw the binary search tree that results from starting with an empty tree and a. adding...

    Draw the binary search tree that results from starting with an empty tree and a. adding 50 72 96 94 26 12 11 9 2 10 25 51 16 17 95 b. adding 95 17 16 51 25 10 2 9 11 12 26 94 96 72 50 c. adding 10 72 96 94 85 78 80 9 5 3 1 15 18 37 47 d. adding 50 72 96 94 26 12 11 9 2 10, then removing 2...

  • Generate a binary search tree for following numbers and perform in-order and post-order traversals: 50, 40,...

    Generate a binary search tree for following numbers and perform in-order and post-order traversals: 50, 40, 80, 20, 0, 30, 10, 90, 60, 70 (JAVA)

  • c. predict the mean cost per person for a restaurant summated rating of 30. A magazine...

    c. predict the mean cost per person for a restaurant summated rating of 30. A magazine publishes restaurant ratings for various locations around the world. The magazine rates the restaurants for food, decor, service, and the cost per person. Develop a regression model to predict the cost per person, based on a variable that represents the sum of the three ratings. The magazine has compled the accompanying table of this summated ratings variable and the cost per person for 25...

  • RANGES FREQUENCY RELATIVE FREQUENCY CUMULATIVE REL. FREQ. 1 - 10 11 - 20 21 - 30 31 - 40...

    RANGES FREQUENCY RELATIVE FREQUENCY CUMULATIVE REL. FREQ. 1 - 10 11 - 20 21 - 30 31 - 40 41 - 50 51 - 60 61 - 70 71 - 80 81 - 90 91 - 100 '= 100 DATA VALUES?? SO, WHAT DOES A FREQUENCY TABLE TELL US? If you wrote each of the above data values on a ping pong ball,, put them in a jar and blindly pulled one out: What is the probability that this ball...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT