Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6667499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:56:24+00:00 2026-05-26T02:56:24+00:00

I am trying to implement a binary search tree. Here is the code I

  • 0

I am trying to implement a binary search tree. Here is the code I have so far:

#include <iostream>
using namespace std;
class BST{
    public:
        int n,*v,vn;
        struct node{
            int val;
            node *left,*right;
            node (int v){ val=v; left=right=0;}
        };
        node *root;

        node *rinsert(node *p,int t){
            if (p==0){
                p=new node(t);
                n++;
            }
            else if (t<p->val){
                p->left=rinsert(p->left,t);

            }
            else if (t>p->val){
                p->right=rinsert(p->right,t);
            }

            return p;
        }

        void traverse(node *p){
            if (p==0) return;
            traverse(p->left);
            v[vn++]=p->val;
            traverse(p->right);

        }
        void print(node *p){
            if (p==NULL) return;
            cout<<p->val;
            traverse(p->left);
            traverse (p->right);
        }

    public:
        BST(int maxelms,int maxval){ root=0;n=0;}
        int size(){ return n;}
        void insert(int v){ root=rinsert(root,v);  }
        void report(int *x){ v=x;vn=0;traverse(root);}
} ;

int main(){
    struct node *root;
    BST bt(12,25);
    bt.insert(12);
    bt.insert(10);
    bt.insert(25);
    bt.insert(7);
    bt.insert(11);
    bt.insert(8);
    bt.insert(4);
    bt.insert(3);
    bt.insert(20);
    bt.insert(23);
    bt.insert(24);
    bt.insert(1);
    bt.Print();

    return 0;
}

It doesn’t compile: the problem is that the Print() method is unknown for the class:

1>c:\users\...\bst\bst.cpp(54): error `C3861: 'Print': identifier not found`

How can I fix this?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:56:25+00:00Added an answer on May 26, 2026 at 2:56 am

    C++ is case-sensitive. You typed Print but the method is called print. And, of course, you need to pass that method a node pointer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to implement binary search tree but I think I have made
I've been trying to implement a delete function for a Binary Search Tree but
I am trying to implement binary search tree operations and got stuck at deletion.
I'm quite new to C and I'm trying to implement a binary tree in
I'm trying to implement a method for a binary tree which returns a stream.
i have made an binary tree, and im trying to make an postorder traversal.
I am trying to connect the siblings of the binary search tree. You can
Working on a binary search. The code below should explain what I'm trying to
I'm a Python guy. Learning C language and I've been trying to implement Binary
trying to implement a dialog-box style behaviour using a separate div section with all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.