Q5 30 Points Linked Data Structures • Assume that you have a TreeNode class. (See code attached for reference.) . Cla

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Q5 30 Points Linked Data Structures • Assume that you have a TreeNode class. (See code attached for reference.) . Cla

Post by answerhappygod »

Q5 30 Points Linked Data Structures Assume That You Have A Treenode T Class See Code Attached For Reference Cla 1
Q5 30 Points Linked Data Structures Assume That You Have A Treenode T Class See Code Attached For Reference Cla 1 (105.7 KiB) Viewed 39 times
Linked Data Structures
Q5 30 Points Linked Data Structures • Assume that you have a TreeNode<T> class. (See code attached for reference.) . Class TreeList<T> below implements a binary tree using TreeNode<T> objects. • You need to write code for the TreeList<T> class insertAfter method. . The insertAfter method creates a new TreeNode<T> object to encapsulate the provided element of type T. . This new node should become the right child of refNode, and count should be updated, too 1. If refNode's right child is null, then the new node can take that position. 2. Otherwise, move refNode's right child to the new node, and then make the new node to be refNode 's right child Because a TreeNode<T> object has a parent reference, you must update each node's parent - if the node's parent changes. Image reference for node insertion concept: ● a)
Image reference for node insertion concept: public class TreeList<T> { Fill in the appropriate part of the code below: 3 a) m. b)
Fill in the appropriate part of the code below: public class TreeList<T> { private TreeNode<T> root; private int count; public TreeList() { count = 0; root = null; } public void insertAfter (T element, TreeNode<T> refNode) { // write your code here // Below there is space to submit an image, if you wish Enter your answer here } } // end class TreeList<T>
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply