What would be the Big O notation for this pseudocode and the total time cost? (I made it for a Binary Search Tree): (SIDE NOTE: I have attached Big O notation table and vector pseudocode that I have done as an example. If you could put it in a table like I did for visualization that would be great. ) BINARY SEARCH TREE FUNCTIONS TO CREATE OBJECT AND NODE: FUNCTION InsertCourse(Course courseData) IF (root is equal to NULLPTR) SET root equals the new node courseData SET left of root equal to NULLPTR SET right of root equal to NULLPTR END IF ELSE CALL AddNode (root, courseData) END ELSE END FUNCTION //Function used to insert node and loaded course details (courseData) FUNCTION AddNode(Node* node, Course courseData) IF (node is larger than root value, add to left) IF (no left node exists) SET node equal to courseData END IF ELSE RECURSE down the left node END ELSE END IF ELSE IF (no right node exists) SET node equal to courseData END IF ELSE RECURSE down the right node END ELSE END ELSE END FUNCTION
What would be the Big O notation for this pseudocode and the total time cost? (I made it for a Binary Search Tree):
(SIDE NOTE: I have attached Big O notation table and
BINARY SEARCH TREE FUNCTIONS TO CREATE OBJECT AND NODE:
FUNCTION InsertCourse(Course courseData)
IF (root is equal to NULLPTR)
SET root equals the new node courseData
SET left of root equal to NULLPTR
SET right of root equal to NULLPTR
END IF
ELSE
CALL AddNode (root, courseData)
END ELSE
END FUNCTION
//Function used to insert node and loaded course details (courseData)
FUNCTION AddNode(Node* node, Course courseData)
IF (node is larger than root value, add to left)
IF (no left node exists)
SET node equal to courseData
END IF
ELSE
RECURSE down the left node
END ELSE
END IF
ELSE
IF (no right node exists)
SET node equal to courseData
END IF
ELSE
RECURSE down the right node
END ELSE
END ELSE
END FUNCTION
Step by step
Solved in 2 steps with 1 images