Amenzz / BST-Regex-Natives

we are regex natives.
0 stars 0 forks source link

Assignment #1

Open Amenzz opened 2 years ago

Amenzz commented 2 years ago
  1. This graded out of 5 so after you finished Assessing don`t forget to grade!!
  2. If you find Error in the code write the correct code in this comment section.
  3. You should mention the class you assessed.
Danuh16 commented 2 years ago

I assigned the class BST delete by merge Line 160-164 it describes that P (have been assigned to the root) is not null and the key that we want to delete is not in the tree and if the loop check whether the key is greater or lesser. Line 168-181 It explains that P is equal to null and if the inserted information on P is equal to the delete (removing) key which is used to manipulate when some conditions are full filled and the node have 1 child. For the first case if the node to the right is null, it assigns left node; For the second if the left node is null, it assigns right as a node; the last case is the while loop that explains when the condition for the node to have 2 child is fulfilled, it finds the direct predecessor and also appends the node's right sub-tree to its direct predecessor, lastly replace the node by its left subtree Line 183-187 In this current line the if loop explains that when P is equal to the root, the root will also be equal to the node. the above condition helps us to explain the following cases:-If the previous left of the node is equal to P then it will assign to the node otherwise the previous right of the node is equal to the node. The other case is when the root is not equal to null, when this occur it displays "the key is not in the tree" otherwise it displays "the tree is empty"

Rating: 4/5

RahelAle commented 2 years ago

Breadth first traversal /*it check if the statement is true or not

Ruth-925 commented 2 years ago

insert a node line 14-/the method mainly calls insert rec/ /A recursive function to insert a new key in the BST , if the tree is empty it returns a new node and if not recurs down the tree and returns the unchanged node pointer / /inserts the node if the key is greater than the root to the right and if less than the root inserts to the left/

Rating: 5/5

daggtes commented 2 years ago

Delete by copying As I see it the code is written nicely, but it lacks explanation for each line of code (absence of comment). It would be nice if add a comment. For example we can add a comment before node = p; as shown below. public void deleteByCopying(int key) { Node node, p = root, prev = null; while (p != null && p.key != key) { prev = p; if (p.key < key) p = p.right; else p = p.left; } / It copies the previous value of p and assigns it as the node/ node = p;

Rating 5\5

MikyasBetru commented 2 years ago

I have assessed the Queue, search and visit part of the code and I liked how it is written, it’s well explained. Specially the Queue.

public Node search(int key){ Node temp = this.root; while(temp!=null){ if(temp.key==key) return temp; else if(temp.key<key) temp = temp.right; else temp = temp.left;

public Node search(Node root, int key) { if (root==null || root.key==key) return root; if (root.key < key) return search(root.right, key); return search(root.left, key); }

I was trying to identify the difference between the two classes it would be nice if you use comment to explain it more. Rating 4.8/5

Thankyou.