Need Implemented Java Linked List Consists Sequence Nodes Elements Keys Stored Node Pointe Q43826013
Need to be implemented in Java
A linked list consists of a sequence of nodes where elements(keys) are stored. Each node has a pointer to the next node. Thefirst node is called head, the rest is called tail. Searching in alinked list is recursively starting with the head: if an element isnot in the head, we continue to search in the tail. An element isinserted at the end of the list. If we want to delete an element,we need to first find it, and then modify the pointersappropriately.
A binary search tree is an ordered rooted tree, where each nodehas at most two children. Elements stored in nodes are called keys.In an ordered tree, we have that, for an arbitrary node v, all theelements (keys) in the left subtree are smaller then the key storedin v, while all the elements (keys) in the right subtree are graterthen the key stored in v. Searching in a tree is recursively fromthe root to the leaf: if the searched element (key) is equal to theelement (key) in the current node, we return the searched node.
Otherwise, if the searched element (key) is smaller then theelement (key) in the current node, we continue to search in theleft subtree, otherwise we continue in the right subtree. Anelement is inserted in the left subtree if it is smaller that thecurrent node or in the right subtree if it is greater. To delete anelement we need to first find the node in which it is stored.
Then we consider three different cases: (i) if the node has nosuccessors, we simply delete the node; (ii) if the node has onesubtree, we replace the node (and element) with its child; (iii) ifthe node has both subtrees, we replaced the node with the one inthe right subtree that stores the minimal element (such a node isthe left-most node in the right subtree).
You need to implement recursive data structures, namely, alinked list and a binary search tree. You should follow thefollowing instructions. – In the class NodeSeznam, you can add thecomponent, say tail, which is of type NodeSeznam, and add aconstructor. Integers being inserted in the list are stored as keysin objects of type NodeSeznam. To compare keys (elements) you mustuse the method compare(NodeSeznam node), because the latter is usedto test the correctness and efficiency of your solution.
For this purpose, it is useful to add the methodsinsert(NodeSeznam node), delete((NodeSeznam node) andsearch((NodeSeznam node) in this class, which can than be used inthe class Seznam. – In the class Seznam you should implement thefollowing methods: 3
(i) insert, which takes an integer and inserts it in the list.The method should return true, if the element is successfullyinserted, and false, if the element is already in the datastructure;
(ii) search, which takes an integer and finds an element in thelist. The method returns true, if the element is already in thelist, and false otherwise;
(iii) delete, which takes an integer and deletes an element fromthe list. The method returns true, if the element is successfullydeleted, and false otherwise. – In the class NodeBinarno you canadd components, say, left and right child of type NodeBinarno, andadd a constructor. Integers being inserted in the tree are storedas keys in objects of type NodeBinarno.
To compare keys (elements) you must use the methodcompare(NodeBinarno node), because the latter is used to test thecorrectness and efficiency of your solution. For this purpose, itis useful to add the methods insert(NodeBinarno node),delete(NodeBinarno node) and search(NodeBinarno node) in thisclass, which can than be used in the class Binarno. – In the classBinarno you should implement the following methods:
(i) insert, which takes an integer and inserts it in the tree.The method should return true, if the element is successfullyinserted, and false, if the element is already in the datastructure;
(ii) search, which takes an integer and finds an element in thetree. The method returns true, if the element is already in thelist, and false otherwise;
(iii) delete, which takes an integer and deletes an element fromthe tree. The method returns true, if the element is successfullydeleted, and false, if the element has not been in the datastructure. If the node has both the left and right subtree, youshould replaced it with the minimal element in the right subtree.For this purpose, it is useful to add also the method findMin() inthe class NodeBinarno.
Expert Answer
Answer to Need to be implemented in Java A linked list consists of a sequence of nodes where elements (keys) are stored. Each node…
OR