• +1-617-874-1011 (US)
  • +44-117-230-1145 (UK)
Online Customer Service
Follow Us:

General N-ary Trees Implementation

template < typename object>
class Nary_tree{
private:
object element;
int N;
Nary_tree **children;
public:
Nary_tree(object const & = object(), int = 2);
//...
}
template < typename object>
Nary_tree< object>::Nary_tree(object const &e, int n):
element (e),
N( std::max( 2, n )),
children ( new *Nary_tree[N] ) {
for (int i = 0; i < N; ++i ) {
children[i] = 0;
}
}
N-ary Trees Homework Help

However, this requires the allocation of dynamic memory in all cases. An alternate design is to use templates:

template < typename object, int N>
class Nary_tree{
private:
object element;
Nary_tree * children [std::max(N,2)|];//an array of N Children
public:
Nary_tree (object const &e );
element ( e) {
for (int i = 0; i < N; ++i) {
children[i] = 0;
}
}

N-ary Trees Implementation Assignment Help

n this case, we could create an N-ary tree as follows

N-ary Trees Online Tutoring


N-ary Trees Implementation Assignment Help
PLACE ORDER NOW

Resources

  • 24 x 7 Availability.
  • Trained and Certified Experts.
  • Deadline Guaranteed.
  • Plagiarism Free.
  • Privacy Guaranteed.
  • Free download.
  • Online help for all project.
  • Need Assignment Help

Testimonial

Urgenthomework helped me with finance homework problems and taught math portion of my course as well. Initially, I used a tutor that taught me math course I felt that as if I was not getting the help I needed. With the help of Urgenthomework, I got precisely where I was weak:
Read More

Tap to Chat
Get Instant Assignment Help
Tap to Chat
Get Instant Assignment Help