Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 399 Weeks Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 19 Jul 2017 My Price 9.00

bintree.h

#include

#include

#include "bintree.h"

 

using namespace std;

 

struct bnode {

int data;

bnode *left;

bnode *right;

};

 

BinTree NewBinTree()

{

srand(time(NULL));

return 0;

}

 

void InsertRandom(BinTree& root, int val)

{

if (root == 0) {

root = new bnode;

root->data = val;

root->left = root->right = 0;

return;

}

 

int r = rand() % 2;

 

if (r == 0)

InsertRandom(root->left, val);

else

InsertRandom(root->right, val);

}

 

void PrintNested(BinTree& root)

{

if (root == 0) {

cout

}

else {

cout << "( " << root->data

PrintNested(root->left); cout

PrintNested(root->right); cout

}

}

 

void InOrder(BinTree& root)

{

if (root == 0)

return;

 

InOrder(root->left);

cout << root->data

InOrder(root->right);

}

 

BinTree MirrorImage(BinTree t)

{

// FOR YOU TO DO: Implement the following recursive algorithm to create a mirror image of a binary tree:

// If t is empty, return empty tree (0)

// Else t = (root, L, R) where L = left subtree, R = right subtree.

// Return tree t2 = (root, MirrorImage(R), MirrorImage(L))

 

BinTree t2; // mirror image

 

// Your code here.

 

 

 

 

 

 

 

return t2;

}

 

int NumTrees[100] = {1,1}; //For memoization.

 

int NumBinTrees(int n)

{

// Implement the recursion:

// NumBinTrees(0) = 1

// NumBinTrees(n) = Sum(k=0 to n-1) B(k)*B(n-1-k) for n > 0;

// Use memoization.

 

// Your code here:

 

 

 

 

 

 

 

}#include <iostream>

 

#include <cstdlib>

#include "bintree.h"

 

using namespace std;

 

struct bnode {

    int data;

    bnode *left;

    bnode *right;

};

 

BinTree NewBinTree()

{

    srand(time(NULL));

    return 0;

}

 

void InsertRandom(BinTree& root, int val)

{

    if (root == 0) {

        root = new bnode;

        root->data = val;

        root->left = root->right = 0;

        return;

    }

 

    int r = rand() % 2;

 

    if (r == 0)

        InsertRandom(root->left, val);

    else

        InsertRandom(root->right, val);

}

 

void PrintNested(BinTree& root)

{

    if (root == 0) {

        cout << "[ ]";

    }

    else {

        cout << "( " << root->data << ", ";

        PrintNested(root->left); cout << ", ";

        PrintNested(root->right); cout << " )";

    }

}

 

void InOrder(BinTree& root)

{

    if (root == 0)

        return;

 

    InOrder(root->left);

    cout << root->data << " ";

    InOrder(root->right);

}

 

BinTree MirrorImage(BinTree t)

{

    // FOR YOU TO DO: Implement the following recursive algorithm to create a mirror image of a binary           tree:

    //      If t is empty, return empty tree (0)

    //      Else t = (root, L, R) where L = left subtree, R = right subtree.

    //      Return tree t2 = (root, MirrorImage(R), MirrorImage(L))

 

    BinTree t2; // mirror image

 

    // Your code here.

 

 

 

 

 

 

 

    return t2;

 }

 

int NumTrees[100] = {1,1}; // For memoization.

 

int NumBinTrees(int n)

{

    // Implement the recursion:

    //       NumBinTrees(0) = 1

    //       NumBinTrees(n) = Sum(k=0 to n-1) B(k)*B(n-1-k) for n > 0;

    // Use memoization.

 

    // Your code here:

 

 

 

 

 

 

 

}

Answers

(5)
Status NEW Posted 19 Jul 2017 08:07 AM My Price 9.00

Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- Th-----------ank----------- Yo-----------u f-----------or -----------usi-----------ng -----------our----------- we-----------bsi-----------te -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill-----------

Not Rated(0)