Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Advanced level school computer science. need helps. A program uses a binary search tree to store ordered data. The programmer implements the binary search tree
Advanced level school computer science. need helps.
A program uses a binary search tree to store ordered data. The programmer implements the binary search tree using linked nodes. Each node comprises three parts: left_ptr, right_ptr and number_item. The number_item stores the data as an integer. The left_ptr is a pointer that points to the left of the current node, while right_ptr is a pointer that points to the right of the current node. Node: The root of the binary search tree is stored in a variable, root. A representation of the binary search tree is as follows: Function A is an operation on the binary search tree. The function takes a parameter and returns the data of a node. FUNCTION A (root_node: Node) RETURNS INTEGER current_node root_node IF current node = NULL THEN RETURN NULL ENDIF WHILE current_node.right_ptr NULL current_nde current_node.right_ptr ENDWHILE RETURN current_node.number_item ENDFUNCTION (a) State the return value of function call A (root) when it is operated on the above binary search tree. (b) What does function A achieve when it is operated on the binary search tree? (c) Using pseudocode, write a recursive version of function A that achieves the same purpose. Besides using a binary search tree, the programmer also considers using a singly linked list to store ordered data. A linked list consists of nodes, where each node holds a value and a pointer to the next node in the sequence. (d) If frequent search operations are required, explain whether an ordered linked list or a binary search tree is preferred for storing the ordered data. (e) If there are frequent insertions and deletions of nodes, explain whether an ordered linked list or a binary search tree is preferred for storing the ordered data
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started