Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions