MCPcopy Create free account
hub / github.com/SR-Sunny-Raj/Hacktoberfest2021-DSA / insertRec

Method insertRec

06. Sorting/Treesort.java:39–59  ·  view source on GitHub ↗
(Node root, int key)

Source from the content-addressed store, hash-verified

37 /* A recursive function to
38 insert a new key in BST */
39 Node insertRec(Node root, int key)
40 {
41
42 /* If the tree is empty,
43 return a new node */
44 if (root == null)
45 {
46 root = new Node(key);
47 return root;
48 }
49
50 /* Otherwise, recur
51 down the tree */
52 if (key < root.key)
53 root.left = insertRec(root.left, key);
54 else if (key > root.key)
55 root.right = insertRec(root.right, key);
56
57 /* return the root */
58 return root;
59 }
60
61 // A function to do
62 // inorder traversal of BST

Callers 1

insertMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected