Question: vector bias(shared_ptr> root) For every node in the tree, compute the ratio of Females to Males in the left subtree of that node. The function

vector bias(shared_ptr> root) For every node in the tree, compute the ratio of Females to Males in the left subtree of that node. The function should return a vector which contains the ratios computed for all nodes, where the order of these ratios is the same as the level order traversal of the tree. (Simply put, the vector of ratios should be ordered the same way as the level-order traversal of the tree).

Code in c++.

Starter Code:

template

struct node {

S fullName;

T workExperience;

string gender;

shared_ptr left;

shared_ptr right;

int height;

node(T w, S n, C g) {

this->fullName = n;

this->workExperience = w;

this->gender = g;

left = NULL;

right = NULL;

height = 1;

}

};

// AVL Class (This will be used for both BST and AVL Tree implementation)

template

class AVL {

shared_ptr> root;

bool isAVL;

public:

AVL(bool);

void insertNode(shared_ptr>);

void deleteNode(T k);

shared_ptr>getRoot();

shared_ptr>searchNode(T k);

int height (shared_ptr > p);

// Part 3 Functions

int number_to_shortlist(shared_ptr> root);

vector right_most(shared_ptr> root);

vector in_order(shared_ptr> root);

vector level_order(shared_ptr> root);

vector bias(shared_ptr> root);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!