Professional Documents
Culture Documents
645842d96e8314d66777cbcc PracticeTest2 CSD201 2 SU24
645842d96e8314d66777cbcc PracticeTest2 CSD201 2 SU24
645842d96e8314d66777cbcc PracticeTest2 CSD201 2 SU24
Time (60 minutes) The Question will be submitted along with your source code
to edu-next.
CGDFBEA
4. The set of all addition edges generated by the DFS tree starting at node D is.
5. The common data structure required for Depth First Traversal on a graph is.
a. Stack
b. Queue
c. Tree
d. All of the above
6. Which is the correct order for Kruskal’s minimum spanning tree algorithm to add edges to
the minimum spanning tree for the figure shown Below?
8. Suppose we remove the root node from the following BST tree, which could be the
new root?
a. 2
b. 1
c. 5
d. 4
a . Build the minimum spanning tree from this graph by Kruskal algorithm and explain
Đầu tiên, để add một node vào cây AVL thì trước hết cứ phải
add một node vào tree.
Bắt đầu từ root, hàm insert 1 sẽ được gọi và truyền vào tham
số root, data mới, và null là giá trị của parent.
Check root -> nếu null -> trả về giá trị new Node (data) ->
set parent = null (root không có cha)
Root không null -> check value –> quẹo trái -> quẹo phải
đến lúc tham số root truyền vào = null -> set null = new
Node (data)
Sau khi add xong -> trả về cây cân bằng, duyệt từ root của cây
Node: Hàm balance có giải thích ở dưới ạ
Hàm balance em sẽ check xem cái node được truyền vào lệch
trái hay lệch phải, lệch trái -> thì quay phải; lệch phải -> quay
trái
d. Write code to remove node 10 from the tree
Write code (20pts) and explain how you write your code
(40pts) . Note Writing code without explaining anything is
considered plagiarism and will not get marked.