-5

I have a couple of questions that I need help answering. I am currently using C++ in a data structure class. Any help will be greatly appreciated.

  1. How could you count the frequency of a number in a binary search tree?
  2. How could you tell if 2 binary search trees contained exactly the same numbers?
  3. Could we make a template class for binary search trees? Why or why not?
  4. Convert 23415 in base 7 to base 5, using the digit-wise algorithm
  5. Tell me 2 big differences between a copy constructor and an assignment operator (operator =). Justify your answers.
Steven
  • 1

2 Answers2

3
  1. With utmost care and finesse.
  2. I would tell it like it is.
  3. Depends on who you mean by "we".
  4. Done. Did you mean to ask a question?
  5. -

        One performs a copy,
    the other an assingment.
       One is a constructor,
      the other an operator.
    
Igor Tandetnik
  • 50,461
  • 4
  • 56
  • 85
0

Here are the links which can help you with the answer: (It would be too long to paste solution here)

1. How could you count the frequency of a number in a binary search tree?

Visit below for tree traversal technique. While traversing just increment a counter (starting from 0) whenever you find your number.

http://www.geeksforgeeks.org/618/

2. How could you tell if 2 binary search trees contained exactly the same numbers?

Check below link. It says equal, so I am not sure if this might help you, but surely can give you can idea

Determine if two binary trees are equal

3. Could we make a template class for binary search trees? Why or why not?

Certainly we can. Templates are made for keeping things generic. BST can hold any data - Char, int, long anything even your own data type. So this data type can be used in Template class object creation and class can be defined as class BST. Let me know if you need further help on this

4. Convert 23415 in base 7 to base 5, using the digit-wise algorithm

Digit-Wise algorithm is used to calculate a power of a number. and while converting numbers to different bases, we need to add number in base^digit fashion. So, there isnt a problem. Refer the link I have given for implementation of Digit-Wise algoritm. Then use that function on each digit of number giving num as 'base' and power as 'digit'

5. Tell me 2 big differences between a copy constructor and an assignment operator (operator =). Justify your answers.

Well I remember that from my undergrad course :) But I am, too lazy to write here. So refer below

http://www.geeksforgeeks.org/copy-constructor-vs-assignment-operator-in-c/

Community
  • 1
  • 1
SimpleGuy
  • 2,764
  • 5
  • 28
  • 45
  • Thank you guys very much for getting back to me and giving me some sites to look at to help me out! – Steven Nov 21 '14 at 04:02
  • @Steven Pleasure ! If you think my answer helped you, you can upvote and accept it as answer so that others can be benefited too – SimpleGuy Nov 21 '14 at 05:29