首页 >
> 详细

CSI 403 Data Structures and Algorithms Fall 2019

Homework IV Hurd

Problem 1 [25 pts]:

Given the sequence of numbers: 20, 7, 34, 29, 43, 40, 8, 12, 30, 42

a) [7 pts] Show the resulting BST after inserting the numbers as keys.

b) [9 pts] What will be the resulting tree if you delete the root? Show the tree and explain

the steps taken in deleting the root according to the delete procedure we discussed in

class.

c) [9 pts] Can you reorder the original sequence of numbers to obtain a tree of a smaller

height? If, yes, show the permutation of the sequence and the new tree. If no, argue why a

smaller height is not obtainable.

Problem 2 [25 pts]:

We discussed a delete operation that if necessary, swaps with a successor of the deleted node

when the deleted node has two children.

a) [8 pts] Argue that swapping one can also swap with the predecessor, and that it will result

in a correct BST, once the predecessor is spliced out.

b) [2 pts] Demonstrate the delete operation with predecessor swap on the example from

Q1(a) by deleting the root 20. Show the resulting tree?

c) [15 pts] Swapping predecessor and successors may result in a relatively balanced tree.

Provide the pseudo code of a procedure that in case where both children of the node to be

deleted exist:

a. swaps with the predecessor if the left subtree of the deleted node is larger

(contains more nodes) than the right subtree,

b. swaps with the successor otherwise,

The procedure should work as the original delete operation for the cases of zero or one children.

Problem 3 [25 pts]:

Suppose we have integer key values between 1 and 1000 stored in a binary search tree and we

want to search for the key value 363. For each of the following sequences, indicate whether or

not it can be a valid sequence of nodes examined during the search. If the sequence is valid, draw

the search path clearly indicating whether a node is the left child or the right child of its parent. If

the sequence is invalid, explain why it cannot arise in the search.

a) [12.5 pts] 2, 399, 387, 219, 266, 382, 381, 278, 363.

b) [12.5 pts] 935, 278, 347, 621, 299, 392, 358, 363.

Problem 4 [25 pts]:

Is the delete (remove) operation on a binary search tree \commutative" in the sense that deleting

key x and then y leaves the same tree as deleting y and then x? If the operation is commutative,

explain why. If not, provide a counter example.

联系我们

- QQ：99515681
- 邮箱：99515681@qq.com
- 工作时间：8:00-23:00
- 微信：codinghelp2

- Tsp课程作业代写、代做algorithms留学生作业、代做java，C/C 2020-06-23
- Kit107留学生作业代做、C++编程语言作业调试、Data课程作业代写、代 2020-06-23
- Sta302h1f作业代做、代写r课程设计作业、代写r编程语言作业、代做da 2020-06-22
- 代写seng 474作业、代做data Mining作业、Python，Ja 2020-06-22
- Cmpsci 187 Binary Search Trees 2020-06-21
- Comp226 Assignment 2: Strategy 2020-06-21
- Math 504 Homework 12 2020-06-21
- Math4007 Assessed Coursework 2 2020-06-21
- Optimization In Machine Learning Assig... 2020-06-21
- Homework 1 – Math 104B 2020-06-20
- Comp1000 Unix And C Programming 2020-06-20
- General Specifications Use Python In T... 2020-06-20
- Comp-206 Mini Assignment 6 2020-06-20
- Aps 105 Lab 9: Search And Link 2020-06-20
- Aps 105 Lab 9: Search And Link 2020-06-20
- Mech 203 – End-Of-Semester Project 2020-06-20
- Ms980 Business Analytics 2020-06-20
- Cs952 Database And Web Systems Develop... 2020-06-20
- Homework 4 Using Data From The China H... 2020-06-20
- Assignment 1 Build A Shopping Cart 2020-06-20