Finding a Local Minimum in a Complete Binary Tree with Log(N) Probes

  • Thread starter Thread starter Jairo Rojas
  • Start date Start date
  • Tags Tags
    Algorithm
Click For Summary
SUMMARY

The discussion focuses on finding a local minimum in a complete binary tree T with n nodes using O(log n) probes. The proposed solution involves recursively comparing values in the left and right subtrees with the root node. The initial attempt, however, incorrectly suggests a method that requires O(n) time complexity, as it traverses the entire tree. A more efficient approach is necessary to achieve the desired logarithmic performance.

PREREQUISITES
  • Understanding of complete binary trees and their properties
  • Familiarity with recursion and tree traversal algorithms
  • Knowledge of time complexity analysis, particularly logarithmic complexity
  • Basic programming skills in C++ or a similar language for implementing tree algorithms
NEXT STEPS
  • Research efficient algorithms for finding local minima in binary trees
  • Learn about divide-and-conquer strategies in tree data structures
  • Explore the concept of implicit data structures and their applications
  • Study the implementation of binary search techniques in tree traversal
USEFUL FOR

Students studying algorithms, computer science enthusiasts, and software developers interested in optimizing tree traversal methods.

Jairo Rojas
Messages
17
Reaction score
0

Homework Statement


Consider a complete binary tree T with n nodes (n = 2^d − 1 for some d). Each node v of T is labeled with a distinct real number x. Define a node v of T to be a local minimum if the label x is less than the label y for all nodes m that are joined to v by an edge. You are given such a complete binary tree T, but the labeling is only specified in the following implicit way: for each node v, you can determine the value x by probing the node. Show how to find a local minimum of T using only O(log n) probes to the nodes of T.

Homework Equations

The Attempt at a Solution


The way how I attempted to do this problem was by recursively finding the local minimum in the left and right subtree and then compare those 2 with the root.
Code:
int T(Root)
{
    int small_left;
    int small_right;
        if(root!=null)
           if(root->left==null)
             {
             return root->data;
             }
    small_left=T(root->left)
    small_right=T(root->right)
    if(root->data<small_left && root ->data<small_right)
        return root->data
    else if(small_left<small_right)
      return small_left;
    else
   return small_right;
}
 
Last edited:
Physics news on Phys.org
Same problem as in the other thread, you go through the whole tree which needs O(n).
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
9K