AvlTree.h
#ifndef AVL_TREE_H
#define AVL_TREE_H
#include "dsexceptions.h"
#include <iostream> // For NULL
#include <queue> // For level order printout
#include <vector>
#include <algorithm> // For max() function
using namespace std;
// AvlTree class
//
// CONSTRUCTION: with ITEM_NOT_FOUND object used to signal failed finds
//
// ******************PUBLIC OPERATIONS*********************
// Programming Assignment Part I
// bool empty( ) --> Test for empty tree @ root
// int size( ) --> Quantity of elements in tree
// int height( ) --> Height of the tree (null == -1)
// void insert( x ) --> Insert x
// void insert( vector<T> ) --> Insert whole vector of values
// void remove( x ) --> Remove x (unimplemented)
// bool contains( x ) --> Return true if x is present
// Comparable findMin( ) --> Return smallest item
// Comparable findMax( ) --> Return largest item
// boolean isEmpty( ) --> Return true if empty; else false
// void printTree( ) --> Print tree in sorted (in) order
// void printPreOrder( ) --> Print tree in pre order
// void printPostOrder( ) --> Print tree in post order
// void printInOrder( ) --> Print tree in *in* order
// Programming Assignment Part II (microassignment)
// void makeEmpty( ) --> Remove and delete all items
// void ~AvlTree( ) --> Big Five Destructor
// AvlTree(const AvlTree &other) --> BigFive Copy Constructor
// AvlTree(const AvlTree &&other) --> BigFive Move Constructor
// AvlTree &operator= ( AvlTree & other ) --> Big Five Copy *assignment* operator
// AvlTree &operator= ( AvlTree && other ) --> Big Five Move *assignment* operator
// void printLevelOrder( ) --> Print tree in LEVEL order :-)
// ******************ERRORS********************************
// Throws UnderflowException as warranted
template <typename Comparable>
class AvlTree
{
public:
/**
* Basic constructor for an empty tree
*/
AvlTree( ) : root( NULL )
{
//cout << " [d] AvlTree constructor called. " << endl;
}
/**
* Vector of data initializer (needed for move= operator rvalue)
*/
AvlTree( vector<Comparable> vals ) : root( NULL )
{
insert(vals);
}
//*******************************************************************************************
// START AVL TREES PART II - TODO: Implement
// Other functions to look for include: clone, makeEmpty, printLevelOrder
/**
* Destroy contents of the AvlTree object - Big Five Destructor
*/
~AvlTree( )
{
//cout << " [d] AvlTree Destructor called. " << endl;
// Empty out the AVL Tree and destroy all nodes (makeEmpty?)
}
/**
* Copy other to new object - Big Five Copy Constructor
*/
AvlTree( const AvlTree &other ) : root( NULL )
{
cout << " [d] Copy Constructor Called." << endl;
// Copy contents of other to ourselves (maybe clone?)
// Get a deep copy of other's tree
}
/* ...
lab08/build.bat
@echo off
cls
set DRIVE_LETTER=%1:
set PATH=%DRIVE_LETTER%\MinGW\bin;%DRIVE_LETTER%\MinGW\msys\1.0\bin;%DRIVE_LETTER%\MinGW\gtkmm3\bin;%DRIVE_LETTER%\MinGW\gtk\bin;c:\Windows;c:\Windows\system32
set PROJECT_PATH=.
make DRIVE_LETTER="%DRIVE_LETTER%" PROJECT_DIR="%PROJECT_PATH%"
lab08/CSC2110/CD.h
#if !defined CD_H
#define CD_H
#include "Song.h"
#include "Text.h"
using CSC2110::String;
#include "ListArray.h"
using CSC2110::ListArray;
namespace CSC2110
{
class CD
{
private:
String* artist;
String* title;
int year;
int rating;
int num_tracks;
ListArray<Song>* songs;
public:
CD(String* artist, String* title, int year, int rating, int num_tracks);
virtual ~CD();
String* getKey();
void addSong(String* title, String* length);
void displayCD();
static ListArray<CD>* readCDs(const char* file_name);
static int compare_items(CD* one, CD* two);
static int compare_keys(String* sk, CD* cd);
static char getRadixChar(CD* cd, int index); //1-based
};
}
#endif
lab08/CSC2110/Double.h
#if !defined (DOUBLE_H)
#define DOUBLE_H
namespace CSC2110
{
class Double
{
private:
double value;
public:
Double(double val);
~Double();
double getValue();
};
}
#endif
lab08/CSC2110/HighPerformanceCounter.h
#if !defined (HIGHPERFORMANCECOUNTER_H)
#define HIGHPERFORMANCECOUNTER_H
namespace CSC2110
{
class HighPerformanceCounter
{
private:
double micro_spt; //micro_seconds per tick
HighPerformanceCounter();
static HighPerformanceCounter* hpc;
static int getTicksPerSecond();
public:
virtual ~HighPerformanceCounter();
static HighPerformanceCounter* getHighPerformanceCounter();
int getCurrentTimeInTicks();
double getTimeDifferenceInMicroSeconds(int start_time, int end_time);
};
}
#endif
lab08/CSC2110/Integer.h
#if !defined (INTEGER_H)
#define INTEGER_H
namespace CSC2110
{
class Integer
{
private:
int value;
public:
Integer(int val);
virtual ~Integer();
int getValue();
};
}
#endif
lab08/CSC2110/Keyboard.h
#if !defined KEYBOARD_H
#define KEYBOARD_H
#include "Text.h"
using CSC2110::String;
#include <string>
using namespace std;
namespace CSC2110
{
class Keyboard
{
private:
Keyboard();
public:
virtual ~Keyboard();
static Keyboard* getKeyboard();
//pre: the string (character literal) that will prompt the user for input
//post: the input read from the keyboard interpreted as an int is returned
int readInt(string prompt);
int getValidatedInt(string prompt, int min, int max);
//pre: the string that will prompt the user for input
//post: the input read from the keyboard interpreted as a double is returned
double readDouble(string prompt);
double getValidatedDouble(string prom ...
AvlTree.h
#ifndef AVL_TREE_H
#define AVL_TREE_H
#include "dsexceptions.h"
#include <iostream> // For NULL
#include <queue> // For level order printout
#include <vector>
#include <algorithm> // For max() function
using namespace std;
// AvlTree class
//
// CONSTRUCTION: with ITEM_NOT_FOUND object used to signal failed finds
//
// ******************PUBLIC OPERATIONS*********************
// Programming Assignment Part I
// bool empty( ) --> Test for empty tree @ root
// int size( ) --> Quantity of elements in tree
// int height( ) --> Height of the tree (null == -1)
// void insert( x ) --> Insert x
// void insert( vector<T> ) --> Insert whole vector of values
// void remove( x ) --> Remove x (unimplemented)
// bool contains( x ) --> Return true if x is present
// Comparable findMin( ) --> Return smallest item
// Comparable findMax( ) --> Return largest item
// boolean isEmpty( ) --> Return true if empty; else false
// void printTree( ) --> Print tree in sorted (in) order
// void printPreOrder( ) --> Print tree in pre order
// void printPostOrder( ) --> Print tree in post order
// void printInOrder( ) --> Print tree in *in* order
// Programming Assignment Part II (microassignment)
// void makeEmpty( ) --> Remove and delete all items
// void ~AvlTree( ) --> Big Five Destructor
// AvlTree(const AvlTree &other) --> BigFive Copy Constructor
// AvlTree(const AvlTree &&other) --> BigFive Move Constructor
// AvlTree &operator= ( AvlTree & other ) --> Big Five Copy *assignment* operator
// AvlTree &operator= ( AvlTree && other ) --> Big Five Move *assignment* operator
// void printLevelOrder( ) --> Print tree in LEVEL order :-)
// ******************ERRORS********************************
// Throws UnderflowException as warranted
template <typename Comparable>
class AvlTree
{
public:
/**
* Basic constructor for an empty tree
*/
AvlTree( ) : root( NULL )
{
//cout << " [d] AvlTree constructor called. " << endl;
}
/**
* Vector of data initializer (needed for move= operator rvalue)
*/
AvlTree( vector<Comparable> vals ) : root( NULL )
{
insert(vals);
}
//*******************************************************************************************
// START AVL TREES PART II - TODO: Implement
// Other functions to look for include: clone, makeEmpty, printLevelOrder
/**
* Destroy contents of the AvlTree object - Big Five Destructor
*/
~AvlTree( )
{
//cout << " [d] AvlTree Destructor called. " << endl;
// Empty out the AVL Tree and destroy all nodes (makeEmpty?)
}
/**
* Copy other to new object - Big Five Copy Constructor
*/
AvlTree( const AvlTree &other ) : root( NULL )
{
cout << " [d] Copy Constructor Called." << endl;
// Copy contents of other to ourselves (maybe clone?)
// Get a deep copy of other's tree
}
/* ...
lab08/build.bat
@echo off
cls
set DRIVE_LETTER=%1:
set PATH=%DRIVE_LETTER%\MinGW\bin;%DRIVE_LETTER%\MinGW\msys\1.0\bin;%DRIVE_LETTER%\MinGW\gtkmm3\bin;%DRIVE_LETTER%\MinGW\gtk\bin;c:\Windows;c:\Windows\system32
set PROJECT_PATH=.
make DRIVE_LETTER="%DRIVE_LETTER%" PROJECT_DIR="%PROJECT_PATH%"
lab08/CSC2110/CD.h
#if !defined CD_H
#define CD_H
#include "Song.h"
#include "Text.h"
using CSC2110::String;
#include "ListArray.h"
using CSC2110::ListArray;
namespace CSC2110
{
class CD
{
private:
String* artist;
String* title;
int year;
int rating;
int num_tracks;
ListArray<Song>* songs;
public:
CD(String* artist, String* title, int year, int rating, int num_tracks);
virtual ~CD();
String* getKey();
void addSong(String* title, String* length);
void displayCD();
static ListArray<CD>* readCDs(const char* file_name);
static int compare_items(CD* one, CD* two);
static int compare_keys(String* sk, CD* cd);
static char getRadixChar(CD* cd, int index); //1-based
};
}
#endif
lab08/CSC2110/Double.h
#if !defined (DOUBLE_H)
#define DOUBLE_H
namespace CSC2110
{
class Double
{
private:
double value;
public:
Double(double val);
~Double();
double getValue();
};
}
#endif
lab08/CSC2110/HighPerformanceCounter.h
#if !defined (HIGHPERFORMANCECOUNTER_H)
#define HIGHPERFORMANCECOUNTER_H
namespace CSC2110
{
class HighPerformanceCounter
{
private:
double micro_spt; //micro_seconds per tick
HighPerformanceCounter();
static HighPerformanceCounter* hpc;
static int getTicksPerSecond();
public:
virtual ~HighPerformanceCounter();
static HighPerformanceCounter* getHighPerformanceCounter();
int getCurrentTimeInTicks();
double getTimeDifferenceInMicroSeconds(int start_time, int end_time);
};
}
#endif
lab08/CSC2110/Integer.h
#if !defined (INTEGER_H)
#define INTEGER_H
namespace CSC2110
{
class Integer
{
private:
int value;
public:
Integer(int val);
virtual ~Integer();
int getValue();
};
}
#endif
lab08/CSC2110/Keyboard.h
#if !defined KEYBOARD_H
#define KEYBOARD_H
#include "Text.h"
using CSC2110::String;
#include <string>
using namespace std;
namespace CSC2110
{
class Keyboard
{
private:
Keyboard();
public:
virtual ~Keyboard();
static Keyboard* getKeyboard();
//pre: the string (character literal) that will prompt the user for input
//post: the input read from the keyboard interpreted as an int is returned
int readInt(string prompt);
int getValidatedInt(string prompt, int min, int max);
//pre: the string that will prompt the user for input
//post: the input read from the keyboard interpreted as a double is returned
double readDouble(string prompt);
double getValidatedDouble(string prom ...
Required to augment the authors Binary Search Tree (BST) code to .docxdebishakespeare
Required to augment the author's Binary Search Tree (BST) code to support these new operations. Method names below are merely suggestions. (The author’s class is attached separately in the file called “authordoc”. I just built a simple test tree in the author’s main method which can be used to test the various operations. )
1. AnyType nthElement(int n) -- returns the n-th element (starting from 1) of the in-order traversal of the BST.
2. int rank( AnyType x ) -- returns the "rank" of x. The rank of an element is its position (starting with 1) in an in-order traversal.
3. AnyType median( ) -- returns the median (middle) element in the BST. If the BST contains an even number of elements, returns the smaller of the two medians.
4. boolean isPerfect( ) -- returns true if the BST is a perfect binary tree.
5. boolean isComplete( ) -- returns true if the BST is a complete binary tree.
6. String toString( int nrLevels ) -- generates the level-order output described in the sample output below.
Most of these operations could easily be implemented by performing an in-order traversal inside the BST and perhaps placing the results in an ArrayList. However, such a method is extremely inefficient. Instead, we are going to achieve faster performance by "augmenting" the BST nodes. You will add a new private integer data member ("tree size") to the BinaryNode which stores the size of the tree rooted at that node (including the root). You must develop your own algorithms for these operations, but obviously you will use the new tree size data member to guide your search. Think before you code and think recursively!
These items cover those topics not addressed elsewhere in the project description. (R) indicates a requirement, (H) indicates a hint, and (N) indicates a note.
1. (R) Although we are only using the BST for integers, the BST must remain a generic class.
2. (R) Duplicate values are not allowed. Attempts to insert a duplicate value should be ignored.
3. (R) Attempts to remove non-existent values should be ignored.
4. (R) From a coding perspective, the easiest way to avoid duplicate insertions or attempting to remove non-existent elements is to first call find( ). However, this technique is NOT permitted for two reasons.
Calling find( ) before each insert/remove doubles the running time for these operations and is therefore inefficient.
Recusively coding the insert/remove methods to handle these situations is a great learning experience.
5. (R) The level order print (PRINT command) outputs the value of each node, the size of the tree rooted at that node, and the value of the node's parent in that order, inside parenthesis, separated by commas. (node value, tree size, parent value). Since the root has no parent, print NULL for the root's parent value. For readability, separate the levels with a blank line and print no more than 6 node/size/parent values per line. If a level requires multiple lines, use consecutive lines (without a blank line between the ...
Please read the comment ins codeExpressionTree.java-------------.pdfshanki7
Please read the comment ins code
ExpressionTree.java
----------------------------------
/**
* This is the class for Expression Tree.
* Used to create Expression Tree and Evaluate it
*/
/**
* Following logic is used to construct a Tree
* Here we use stack for Preparing Tree
* Loop through given Expression String
* If Character is Operand , Create node and push to stack
* If Character is Operator then
* 1)Create Node for Operator
* 2)Pop 2 nodes from Stack and Made
* OpretorNode--> left == first node pop
* OpretorNode--> right == second node pop
* At the end of creation of Expression Tree, Stack have only one node , which is root of
Expression tree
*/
/** Class ExpressionTree **/
class ExpressionTree
{
/** class TreeNode
* Stored Character ==> Digit(0..9) or a Operator +,-,*,/
* Left Node and Right Node
*
* **/
class TreeNode
{
char data;
TreeNode left, right;
/** constructor **/
public TreeNode(char data)
{
this.data = data;
this.left = null;
this.right = null;
}
}
/** class StackNode **/
class StackNode
{
TreeNode treeNode;
StackNode next;
/** constructor **/
public StackNode(TreeNode treeNode)
{
this.treeNode = treeNode;
next = null;
}
}
private static StackNode top;
/** constructor
* Constructor takes input string like \"+-+7*935*82*625\"
* Input should be in Prefix notation
* **/
public ExpressionTree(String expression)
{
top = null;
//Call Method for prepare expression tree
buildTree(expression);
}
/** function to clear tree **/
public void clear()
{
top = null;
}
/** function to push a node **/
private void push(TreeNode ptr)
{
if (top == null)
top = new StackNode(ptr);
else
{
StackNode nptr = new StackNode(ptr);
nptr.next = top;
top = nptr;
}
}
/** function to pop a node
* When it find operator pop 2 elements from Stack
*
* **/
private TreeNode pop()
{
if (top == null)
throw new RuntimeException(\"Underflow\");
else
{
TreeNode ptr = top.treeNode;
top = top.next;
return ptr;
}
}
/** function to get top node **/
private TreeNode peek()
{
return top.treeNode;
}
/** function to insert character **/
private void insert(char val)
{
try
{
//If Operand , Create node and push to Stack
if (isDigit(val))
{
TreeNode nptr = new TreeNode(val);
push(nptr);
}
//If Operator , Create node and popup 2 elements and make them its right and left
else if (isOperator(val))
{
TreeNode nptr = new TreeNode(val);
nptr.left = pop();
nptr.right = pop();
push(nptr);
}
}
catch (Exception e)
{
System.out.println(\"Invalid Expression\");
}
}
/** function to check if digit **/
private boolean isDigit(char ch)
{
return ch >= \'0\' && ch <= \'9\';
}
/** function to check if operator **/
private boolean isOperator(char ch)
{
return ch == \'+\' || ch == \'-\' || ch == \'*\' || ch == \'/\';
}
/** function to convert character to digit **/
private int toDigit(char ch)
{
return ch - \'0\';
}
/** function to build tree from input */
public void buildTree(String eqn)
{
for (int i = eqn.length() - 1; i >= 0; i--)
insert(eqn.charAt(i));
}
/** function to evaluate tree */
public dou.
Write a program that accepts an arithmetic expression of unsigned in.pdfJUSTSTYLISH3B2MOHALI
Write a program that accepts an arithmetic expression of unsigned integers in postfix notation
and builds the arithmetic expression tree that represents that expression. From that tree, the
corresponding fully parenthesized infix expression should be displayed and a file should be
generated that contains the three address format instructions. This topic is discussed in the week
4 reading in module 2, section II-B. The main class should create the GUI shown below:
Pressing the Construct Tree button should cause the tree to be constructed and using that tree, the
corresponding infix expression should be displayed and the three address instruction file should
be generated. The postfix expression input should not be required to have spaces between every
token. Note in the above example that 9+- are not separated by spaces. The above example
should produce the following output file containing the three address instructions:
Add R0 5 9
Sub R1 3
R0 Mul R2 2 3
Div R3 R1 R2
Inheritance should be used to define the arithmetic expression tree. At a minimum, it should
involve three classes: an abstract class for the tree nodes and two derived classes, one for
operand nodes and another for operator nodes. Other classes should be included as needed to
accomplish good object-oriented design. All instance data must be declared as private.
You may assume that the expression is syntactically correct with regard to the order of operators
and operands, but you should check for invalid tokens, such as characters that are not valid
operators or operands such as 2a, which are not valid integers. If an invalid token is detected a
RuntimeException should be thrown and caught by the main class and an appropriate error
message should be displayed. Three Adddress Generator Enter Postfix Expression 359 2 3
Construct Tree Infix Expression ((3-(5 9))/ (2* 3
Solution
#include
#include
#include
#include
#include
struct TREE //Structure to represent a tree
{
char data;
struct TREE *right,*left,*root;
};
typedef TREE tree; /* Stack Using Linked List */
struct Stack //Structure to represent Stack
{
struct TREE *data;
struct Stack *next,*head,*top; //Pointers to next node,head and top
};
typedef struct Stack node;
node *Nw; //Global Variable to represent node
void initialize(node *&n)
{
n = new node;
n -> next = n -> head = n -> top = NULL;
}
void create(node *n)
{
Nw = new node; //Create a new node
Nw -> next = NULL; //Initialize next pointer field
if(n -> head == NULL) //if first node
{
n -> head = Nw; //Initialize head
n -> top = Nw; //Update top
}
}
void push(node *n,tree *ITEM)
{
node *temp = n -> head;
if(n -> head == NULL) //if First Item is Pushed to Stack
{
create(n); //Create a Node
n -> head -> data = ITEM; //Insert Item to head of List
n -> head = Nw;
return; //Exit from Function
}
create(n); //Create a new Node
Nw -> data = ITEM; //Insert Item
while(temp -> next != NULL)
temp = temp -> next; //Go to Last Node
temp -> next = Nw; //Point New node
n -> top = Nw; //Upda.
AnswerThe new program with the required constructor and with a te.pdfnipuns1983
Answer:
The new program with the required constructor and with a test is given below
Code:
#include
#include
using namespace std;
class TNode
{
public:
int data;
TNode *left;
TNode *right;
TNode(int n){ data = n; left = right = 0; }
TNode(int n, TNode *left, TNode *right)
{
data = n;
//Assign the left node address and right node address with the parameters passed
this->left = left;
this->right = right;
}
};
void printTree(TNode *t)
{
if (!t) return;
printTree(t->left);
cout << t->data << \" \";
printTree(t->right);
}
void search_for(int n, TNode *t)
{
cout << \"Searhing for \" << n << endl;
while (t)
{
cout << \"looking at \" << t->data << endl;
if (t->data == n)
{
cout << \"Found it!\";
return;
}
if (n < t->data)
{
cout << \"Going left\ \";
t = t->left;
}
else
{
cout << \"Going right\ \";
t = t->right;
}
}
cout << \"Can\\\'t find it\";
}
// Creates a two node tree
int main()
{
TNode *root = 0;
root = new TNode(5);
cout << root->data << endl;
TNode *one_node = new TNode(1);
TNode *three_node = new TNode(3);
//use the new constructor
TNode *two_node = new TNode(2, one_node, three_node);
root->left = new TNode(3);
printTree(root);
cout << endl;
search_for(3, root);
getchar();
return 0;
}
Solution
Answer:
The new program with the required constructor and with a test is given below
Code:
#include
#include
using namespace std;
class TNode
{
public:
int data;
TNode *left;
TNode *right;
TNode(int n){ data = n; left = right = 0; }
TNode(int n, TNode *left, TNode *right)
{
data = n;
//Assign the left node address and right node address with the parameters passed
this->left = left;
this->right = right;
}
};
void printTree(TNode *t)
{
if (!t) return;
printTree(t->left);
cout << t->data << \" \";
printTree(t->right);
}
void search_for(int n, TNode *t)
{
cout << \"Searhing for \" << n << endl;
while (t)
{
cout << \"looking at \" << t->data << endl;
if (t->data == n)
{
cout << \"Found it!\";
return;
}
if (n < t->data)
{
cout << \"Going left\ \";
t = t->left;
}
else
{
cout << \"Going right\ \";
t = t->right;
}
}
cout << \"Can\\\'t find it\";
}
// Creates a two node tree
int main()
{
TNode *root = 0;
root = new TNode(5);
cout << root->data << endl;
TNode *one_node = new TNode(1);
TNode *three_node = new TNode(3);
//use the new constructor
TNode *two_node = new TNode(2, one_node, three_node);
root->left = new TNode(3);
printTree(root);
cout << endl;
search_for(3, root);
getchar();
return 0;
}.
This presentations gives an introduction to the data structure linked-lists. I discuss the implementation of header-based linked-lists in C. The presentation runs through the code and provides the visualization of the code w.r.t pointers.
Here is the code given in the instructionsclass AVL {.pdfmanjan6
Here is the code given in the instructions:
class AVL {
Node root;
private class Node {
int data;
Node left, right;
int height;
private Node(int D, Node L, Node R, int H) {
data=D;
left=L;
right=R;
height=H; // user has to set height
} // of constructor Node
} //of Node
static private void UpdateHeight(Node T) {
if (T ==null) return;
else T.height = Math.max(HEIGHT(T.left),HEIGHT(T.right)) + 1;
} // UPdate Height
static private int HEIGHT(Node T) {
if (T== null ) return(-1);
else return (T.height);
}
// we need to more our right child up
static private Node LeftRotate(Node T) {
System.out.println(\"left rotate with data \" + T.data);
Node Tr;
Tr=T.right; // right child
T.right=Tr.left; // our right child IS NOW hhh
Tr.left=T; // move T down to the left
UpdateHeight(Tr.left); // update the height of T
UpdateHeight(Tr); // update hte height of the new root
return Tr;
} // of LeftRotate
// we move our immediate left node up.
// in doing so, we are now immediat right of our left child
static private Node RightRotate(Node T) {
Node Tl;
System.out.println(\"left rotate with data \" + T.data);
Tl=T.left; // left child
T.left=Tl.right; // our left child is now what our left was pointing to
Tl.right=T; // move T down to the right
UpdateHeight(Tl.right); // update the height of T
UpdateHeight(Tl); // update hte height of the new root
return Tl;
} // of RightRotate
public AVL() {
root=null;
} // of constructor AVL
// method to allow external entity to insert an element into the tree
public void insert(int D)
{
root=insert_internal(D, root);
} // of insert
private Node insert_internal(int D, Node T) {
if (T==null) return( new Node (D, null, null, 0));
if (T.data == D) return T; // the data is already in there
if ( D < T. data ) // go left
{ if (T.left == null)
{
T.left = insert_internal(D,null);
UpdateHeight(T);
}
else { //interior node
T.left = insert_internal(D, T.left);
}
} // of go left
else // D goes to the right
{ if (T.right == null)
{
T.right = insert_internal(D,null);
UpdateHeight(T);
}
else { //interior node
T.right = insert_internal(D, T.right);
}
} // of go right
// now we have to figure out if things are out of
// balance
int diff= HEIGHT(T.right) - HEIGHT(T.left);
System.out.println(\"difference is \" + diff + \" data is \" + T.data);
if ( Math.abs(diff) <= 1) // we are good to go at this level
{
UpdateHeight(T);
return(T);
}
// only if diff is bigger than 1
if ( diff > 1)// right leaning
{ // look at right child and figure out how it is leaning
} // of right leaning
else // left leaning
{ // look at left child to see how it is leaning
Node child = T.left;
int cdiff;
cdiff = HEIGHT(child.right) - HEIGHT(child.left);
System.out.println(\"cdiff is \" + cdiff);
if ( cdiff < 0 ) // left left lean
{ T=RightRotate(T); }
else
{
System.out.println(\"SHAUN\");
preorder_internal(T);
T.left = LeftRotate(T.left);
System.out.println(\"SHAUN\");
preorder_internal(T);
T=RightRotate(T);
}
} // of left leaning
// at this point we have rotated, so we need to.
I l Show that if X has the discrete topology, then its only conn.pdfarjuncp10
I l
Show that if X has the discrete topology, then its only connected subspaces are point sets.
Solution
Let X have discrete topology.
Any subset Y of X is the union of singletons , each of which is both open and closed (as X has
discrete topology)
So the maximal sets which cannot expressed as a disjoint union of open (closed) subsets are the
singletons.
Hence the connected components of X are the singletons..
In 2006 the CEO of Bear Sterns, James Caynes, received a compensatio.pdfarjuncp10
In 2006 the CEO of Bear Sterns, James Caynes, received a compensation package of $34
million. The following year Bear Sterns cost $2.7 billion to the taxpayers. In 2006, the CEO of
Lehman Brothers received a compensation package of $27 million. On September 15, 2008,
Lehman Brothers filed for bankruptcy. The collapse of Lehman Brothers is seen by many as the
key event that sparked the Global Financial Crisis. In 2006, the CEO of Citigroup, Charles
Prince, received a compensation package of $25 million. Since then the stock price has fallen
from $50 a share to $3.5 a share. The CEO of Countrywide Financial, Angelo Mozilo, did even
better. His compensation package was $43 million. Angelo Mozilo and two other top executives
were charged by the Security and Exchange Commission (SEC) with fraud. According to the
SEC, from 2005 through 2007, Countrywide Financial engaged in an unprecedented expansion
of its underwriting guidelines and was writing riskier and riskier loans, which these senior
executives were warned might ultimately curtail the company\'s ability to sell them. Countrywide
Financial was the third biggest originator of subprime mortgages and the nation\'s leader in
subprime mortgage- backed securities. The tragedy is that these individuals did not make
decisions that were in their companies’ best interest. Why? What went wrong? What caused the
relation between the CEO and the stockholders to go so badly awry? Discuss
Solution
Leaders who lose their way are not necessarily bad people; rather, they lose their moral bearings,
often yielding to seductions in their paths. Very few people go into leadership roles to cheat or
do evil, yet we all have the capacity for actions we deeply regret unless we stay grounded.
Leaders whose goal is the quest for power over others, unlimited wealth, or the fame that comes
with success tend to look to others to gain satisfaction, and often appear self-centered and
egotistical. They start to believe their own press. As leaders of institutions, they eventually
believe the institution cannot succeed without them.
While most people value fair compensation for their accomplishments, few leaders start out
seeking only money, power, and prestige. Along the way, the rewards—bonus checks,
newspaper articles, perks, and stock appreciation—fuel increasing desires for more.
This creates a deep desire to keep it going, often driven by desires to overcome narcissistic
wounds from childhood. Many times, this desire is so strong that leaders breach the ethical
standards that previously governed their conduct, which can be bizarre and even illegal.
Many leaders get to the top by imposing their will on others, even destroying people standing in
their way. When they reach the top, they may be paranoid that others are trying to knock them
off their pedestal. Sometimes they develop an impostor complex, caused by deep insecurities that
they aren\'t good enough and may be unmasked.
To prove they aren\'t impostors, they drive so.
More Related Content
Similar to 1. Add a breadth-first (level-order) traversal function to the binar.pdf
Required to augment the authors Binary Search Tree (BST) code to .docxdebishakespeare
Required to augment the author's Binary Search Tree (BST) code to support these new operations. Method names below are merely suggestions. (The author’s class is attached separately in the file called “authordoc”. I just built a simple test tree in the author’s main method which can be used to test the various operations. )
1. AnyType nthElement(int n) -- returns the n-th element (starting from 1) of the in-order traversal of the BST.
2. int rank( AnyType x ) -- returns the "rank" of x. The rank of an element is its position (starting with 1) in an in-order traversal.
3. AnyType median( ) -- returns the median (middle) element in the BST. If the BST contains an even number of elements, returns the smaller of the two medians.
4. boolean isPerfect( ) -- returns true if the BST is a perfect binary tree.
5. boolean isComplete( ) -- returns true if the BST is a complete binary tree.
6. String toString( int nrLevels ) -- generates the level-order output described in the sample output below.
Most of these operations could easily be implemented by performing an in-order traversal inside the BST and perhaps placing the results in an ArrayList. However, such a method is extremely inefficient. Instead, we are going to achieve faster performance by "augmenting" the BST nodes. You will add a new private integer data member ("tree size") to the BinaryNode which stores the size of the tree rooted at that node (including the root). You must develop your own algorithms for these operations, but obviously you will use the new tree size data member to guide your search. Think before you code and think recursively!
These items cover those topics not addressed elsewhere in the project description. (R) indicates a requirement, (H) indicates a hint, and (N) indicates a note.
1. (R) Although we are only using the BST for integers, the BST must remain a generic class.
2. (R) Duplicate values are not allowed. Attempts to insert a duplicate value should be ignored.
3. (R) Attempts to remove non-existent values should be ignored.
4. (R) From a coding perspective, the easiest way to avoid duplicate insertions or attempting to remove non-existent elements is to first call find( ). However, this technique is NOT permitted for two reasons.
Calling find( ) before each insert/remove doubles the running time for these operations and is therefore inefficient.
Recusively coding the insert/remove methods to handle these situations is a great learning experience.
5. (R) The level order print (PRINT command) outputs the value of each node, the size of the tree rooted at that node, and the value of the node's parent in that order, inside parenthesis, separated by commas. (node value, tree size, parent value). Since the root has no parent, print NULL for the root's parent value. For readability, separate the levels with a blank line and print no more than 6 node/size/parent values per line. If a level requires multiple lines, use consecutive lines (without a blank line between the ...
Please read the comment ins codeExpressionTree.java-------------.pdfshanki7
Please read the comment ins code
ExpressionTree.java
----------------------------------
/**
* This is the class for Expression Tree.
* Used to create Expression Tree and Evaluate it
*/
/**
* Following logic is used to construct a Tree
* Here we use stack for Preparing Tree
* Loop through given Expression String
* If Character is Operand , Create node and push to stack
* If Character is Operator then
* 1)Create Node for Operator
* 2)Pop 2 nodes from Stack and Made
* OpretorNode--> left == first node pop
* OpretorNode--> right == second node pop
* At the end of creation of Expression Tree, Stack have only one node , which is root of
Expression tree
*/
/** Class ExpressionTree **/
class ExpressionTree
{
/** class TreeNode
* Stored Character ==> Digit(0..9) or a Operator +,-,*,/
* Left Node and Right Node
*
* **/
class TreeNode
{
char data;
TreeNode left, right;
/** constructor **/
public TreeNode(char data)
{
this.data = data;
this.left = null;
this.right = null;
}
}
/** class StackNode **/
class StackNode
{
TreeNode treeNode;
StackNode next;
/** constructor **/
public StackNode(TreeNode treeNode)
{
this.treeNode = treeNode;
next = null;
}
}
private static StackNode top;
/** constructor
* Constructor takes input string like \"+-+7*935*82*625\"
* Input should be in Prefix notation
* **/
public ExpressionTree(String expression)
{
top = null;
//Call Method for prepare expression tree
buildTree(expression);
}
/** function to clear tree **/
public void clear()
{
top = null;
}
/** function to push a node **/
private void push(TreeNode ptr)
{
if (top == null)
top = new StackNode(ptr);
else
{
StackNode nptr = new StackNode(ptr);
nptr.next = top;
top = nptr;
}
}
/** function to pop a node
* When it find operator pop 2 elements from Stack
*
* **/
private TreeNode pop()
{
if (top == null)
throw new RuntimeException(\"Underflow\");
else
{
TreeNode ptr = top.treeNode;
top = top.next;
return ptr;
}
}
/** function to get top node **/
private TreeNode peek()
{
return top.treeNode;
}
/** function to insert character **/
private void insert(char val)
{
try
{
//If Operand , Create node and push to Stack
if (isDigit(val))
{
TreeNode nptr = new TreeNode(val);
push(nptr);
}
//If Operator , Create node and popup 2 elements and make them its right and left
else if (isOperator(val))
{
TreeNode nptr = new TreeNode(val);
nptr.left = pop();
nptr.right = pop();
push(nptr);
}
}
catch (Exception e)
{
System.out.println(\"Invalid Expression\");
}
}
/** function to check if digit **/
private boolean isDigit(char ch)
{
return ch >= \'0\' && ch <= \'9\';
}
/** function to check if operator **/
private boolean isOperator(char ch)
{
return ch == \'+\' || ch == \'-\' || ch == \'*\' || ch == \'/\';
}
/** function to convert character to digit **/
private int toDigit(char ch)
{
return ch - \'0\';
}
/** function to build tree from input */
public void buildTree(String eqn)
{
for (int i = eqn.length() - 1; i >= 0; i--)
insert(eqn.charAt(i));
}
/** function to evaluate tree */
public dou.
Write a program that accepts an arithmetic expression of unsigned in.pdfJUSTSTYLISH3B2MOHALI
Write a program that accepts an arithmetic expression of unsigned integers in postfix notation
and builds the arithmetic expression tree that represents that expression. From that tree, the
corresponding fully parenthesized infix expression should be displayed and a file should be
generated that contains the three address format instructions. This topic is discussed in the week
4 reading in module 2, section II-B. The main class should create the GUI shown below:
Pressing the Construct Tree button should cause the tree to be constructed and using that tree, the
corresponding infix expression should be displayed and the three address instruction file should
be generated. The postfix expression input should not be required to have spaces between every
token. Note in the above example that 9+- are not separated by spaces. The above example
should produce the following output file containing the three address instructions:
Add R0 5 9
Sub R1 3
R0 Mul R2 2 3
Div R3 R1 R2
Inheritance should be used to define the arithmetic expression tree. At a minimum, it should
involve three classes: an abstract class for the tree nodes and two derived classes, one for
operand nodes and another for operator nodes. Other classes should be included as needed to
accomplish good object-oriented design. All instance data must be declared as private.
You may assume that the expression is syntactically correct with regard to the order of operators
and operands, but you should check for invalid tokens, such as characters that are not valid
operators or operands such as 2a, which are not valid integers. If an invalid token is detected a
RuntimeException should be thrown and caught by the main class and an appropriate error
message should be displayed. Three Adddress Generator Enter Postfix Expression 359 2 3
Construct Tree Infix Expression ((3-(5 9))/ (2* 3
Solution
#include
#include
#include
#include
#include
struct TREE //Structure to represent a tree
{
char data;
struct TREE *right,*left,*root;
};
typedef TREE tree; /* Stack Using Linked List */
struct Stack //Structure to represent Stack
{
struct TREE *data;
struct Stack *next,*head,*top; //Pointers to next node,head and top
};
typedef struct Stack node;
node *Nw; //Global Variable to represent node
void initialize(node *&n)
{
n = new node;
n -> next = n -> head = n -> top = NULL;
}
void create(node *n)
{
Nw = new node; //Create a new node
Nw -> next = NULL; //Initialize next pointer field
if(n -> head == NULL) //if first node
{
n -> head = Nw; //Initialize head
n -> top = Nw; //Update top
}
}
void push(node *n,tree *ITEM)
{
node *temp = n -> head;
if(n -> head == NULL) //if First Item is Pushed to Stack
{
create(n); //Create a Node
n -> head -> data = ITEM; //Insert Item to head of List
n -> head = Nw;
return; //Exit from Function
}
create(n); //Create a new Node
Nw -> data = ITEM; //Insert Item
while(temp -> next != NULL)
temp = temp -> next; //Go to Last Node
temp -> next = Nw; //Point New node
n -> top = Nw; //Upda.
AnswerThe new program with the required constructor and with a te.pdfnipuns1983
Answer:
The new program with the required constructor and with a test is given below
Code:
#include
#include
using namespace std;
class TNode
{
public:
int data;
TNode *left;
TNode *right;
TNode(int n){ data = n; left = right = 0; }
TNode(int n, TNode *left, TNode *right)
{
data = n;
//Assign the left node address and right node address with the parameters passed
this->left = left;
this->right = right;
}
};
void printTree(TNode *t)
{
if (!t) return;
printTree(t->left);
cout << t->data << \" \";
printTree(t->right);
}
void search_for(int n, TNode *t)
{
cout << \"Searhing for \" << n << endl;
while (t)
{
cout << \"looking at \" << t->data << endl;
if (t->data == n)
{
cout << \"Found it!\";
return;
}
if (n < t->data)
{
cout << \"Going left\ \";
t = t->left;
}
else
{
cout << \"Going right\ \";
t = t->right;
}
}
cout << \"Can\\\'t find it\";
}
// Creates a two node tree
int main()
{
TNode *root = 0;
root = new TNode(5);
cout << root->data << endl;
TNode *one_node = new TNode(1);
TNode *three_node = new TNode(3);
//use the new constructor
TNode *two_node = new TNode(2, one_node, three_node);
root->left = new TNode(3);
printTree(root);
cout << endl;
search_for(3, root);
getchar();
return 0;
}
Solution
Answer:
The new program with the required constructor and with a test is given below
Code:
#include
#include
using namespace std;
class TNode
{
public:
int data;
TNode *left;
TNode *right;
TNode(int n){ data = n; left = right = 0; }
TNode(int n, TNode *left, TNode *right)
{
data = n;
//Assign the left node address and right node address with the parameters passed
this->left = left;
this->right = right;
}
};
void printTree(TNode *t)
{
if (!t) return;
printTree(t->left);
cout << t->data << \" \";
printTree(t->right);
}
void search_for(int n, TNode *t)
{
cout << \"Searhing for \" << n << endl;
while (t)
{
cout << \"looking at \" << t->data << endl;
if (t->data == n)
{
cout << \"Found it!\";
return;
}
if (n < t->data)
{
cout << \"Going left\ \";
t = t->left;
}
else
{
cout << \"Going right\ \";
t = t->right;
}
}
cout << \"Can\\\'t find it\";
}
// Creates a two node tree
int main()
{
TNode *root = 0;
root = new TNode(5);
cout << root->data << endl;
TNode *one_node = new TNode(1);
TNode *three_node = new TNode(3);
//use the new constructor
TNode *two_node = new TNode(2, one_node, three_node);
root->left = new TNode(3);
printTree(root);
cout << endl;
search_for(3, root);
getchar();
return 0;
}.
This presentations gives an introduction to the data structure linked-lists. I discuss the implementation of header-based linked-lists in C. The presentation runs through the code and provides the visualization of the code w.r.t pointers.
Here is the code given in the instructionsclass AVL {.pdfmanjan6
Here is the code given in the instructions:
class AVL {
Node root;
private class Node {
int data;
Node left, right;
int height;
private Node(int D, Node L, Node R, int H) {
data=D;
left=L;
right=R;
height=H; // user has to set height
} // of constructor Node
} //of Node
static private void UpdateHeight(Node T) {
if (T ==null) return;
else T.height = Math.max(HEIGHT(T.left),HEIGHT(T.right)) + 1;
} // UPdate Height
static private int HEIGHT(Node T) {
if (T== null ) return(-1);
else return (T.height);
}
// we need to more our right child up
static private Node LeftRotate(Node T) {
System.out.println(\"left rotate with data \" + T.data);
Node Tr;
Tr=T.right; // right child
T.right=Tr.left; // our right child IS NOW hhh
Tr.left=T; // move T down to the left
UpdateHeight(Tr.left); // update the height of T
UpdateHeight(Tr); // update hte height of the new root
return Tr;
} // of LeftRotate
// we move our immediate left node up.
// in doing so, we are now immediat right of our left child
static private Node RightRotate(Node T) {
Node Tl;
System.out.println(\"left rotate with data \" + T.data);
Tl=T.left; // left child
T.left=Tl.right; // our left child is now what our left was pointing to
Tl.right=T; // move T down to the right
UpdateHeight(Tl.right); // update the height of T
UpdateHeight(Tl); // update hte height of the new root
return Tl;
} // of RightRotate
public AVL() {
root=null;
} // of constructor AVL
// method to allow external entity to insert an element into the tree
public void insert(int D)
{
root=insert_internal(D, root);
} // of insert
private Node insert_internal(int D, Node T) {
if (T==null) return( new Node (D, null, null, 0));
if (T.data == D) return T; // the data is already in there
if ( D < T. data ) // go left
{ if (T.left == null)
{
T.left = insert_internal(D,null);
UpdateHeight(T);
}
else { //interior node
T.left = insert_internal(D, T.left);
}
} // of go left
else // D goes to the right
{ if (T.right == null)
{
T.right = insert_internal(D,null);
UpdateHeight(T);
}
else { //interior node
T.right = insert_internal(D, T.right);
}
} // of go right
// now we have to figure out if things are out of
// balance
int diff= HEIGHT(T.right) - HEIGHT(T.left);
System.out.println(\"difference is \" + diff + \" data is \" + T.data);
if ( Math.abs(diff) <= 1) // we are good to go at this level
{
UpdateHeight(T);
return(T);
}
// only if diff is bigger than 1
if ( diff > 1)// right leaning
{ // look at right child and figure out how it is leaning
} // of right leaning
else // left leaning
{ // look at left child to see how it is leaning
Node child = T.left;
int cdiff;
cdiff = HEIGHT(child.right) - HEIGHT(child.left);
System.out.println(\"cdiff is \" + cdiff);
if ( cdiff < 0 ) // left left lean
{ T=RightRotate(T); }
else
{
System.out.println(\"SHAUN\");
preorder_internal(T);
T.left = LeftRotate(T.left);
System.out.println(\"SHAUN\");
preorder_internal(T);
T=RightRotate(T);
}
} // of left leaning
// at this point we have rotated, so we need to.
I l Show that if X has the discrete topology, then its only conn.pdfarjuncp10
I l
Show that if X has the discrete topology, then its only connected subspaces are point sets.
Solution
Let X have discrete topology.
Any subset Y of X is the union of singletons , each of which is both open and closed (as X has
discrete topology)
So the maximal sets which cannot expressed as a disjoint union of open (closed) subsets are the
singletons.
Hence the connected components of X are the singletons..
In 2006 the CEO of Bear Sterns, James Caynes, received a compensatio.pdfarjuncp10
In 2006 the CEO of Bear Sterns, James Caynes, received a compensation package of $34
million. The following year Bear Sterns cost $2.7 billion to the taxpayers. In 2006, the CEO of
Lehman Brothers received a compensation package of $27 million. On September 15, 2008,
Lehman Brothers filed for bankruptcy. The collapse of Lehman Brothers is seen by many as the
key event that sparked the Global Financial Crisis. In 2006, the CEO of Citigroup, Charles
Prince, received a compensation package of $25 million. Since then the stock price has fallen
from $50 a share to $3.5 a share. The CEO of Countrywide Financial, Angelo Mozilo, did even
better. His compensation package was $43 million. Angelo Mozilo and two other top executives
were charged by the Security and Exchange Commission (SEC) with fraud. According to the
SEC, from 2005 through 2007, Countrywide Financial engaged in an unprecedented expansion
of its underwriting guidelines and was writing riskier and riskier loans, which these senior
executives were warned might ultimately curtail the company\'s ability to sell them. Countrywide
Financial was the third biggest originator of subprime mortgages and the nation\'s leader in
subprime mortgage- backed securities. The tragedy is that these individuals did not make
decisions that were in their companies’ best interest. Why? What went wrong? What caused the
relation between the CEO and the stockholders to go so badly awry? Discuss
Solution
Leaders who lose their way are not necessarily bad people; rather, they lose their moral bearings,
often yielding to seductions in their paths. Very few people go into leadership roles to cheat or
do evil, yet we all have the capacity for actions we deeply regret unless we stay grounded.
Leaders whose goal is the quest for power over others, unlimited wealth, or the fame that comes
with success tend to look to others to gain satisfaction, and often appear self-centered and
egotistical. They start to believe their own press. As leaders of institutions, they eventually
believe the institution cannot succeed without them.
While most people value fair compensation for their accomplishments, few leaders start out
seeking only money, power, and prestige. Along the way, the rewards—bonus checks,
newspaper articles, perks, and stock appreciation—fuel increasing desires for more.
This creates a deep desire to keep it going, often driven by desires to overcome narcissistic
wounds from childhood. Many times, this desire is so strong that leaders breach the ethical
standards that previously governed their conduct, which can be bizarre and even illegal.
Many leaders get to the top by imposing their will on others, even destroying people standing in
their way. When they reach the top, they may be paranoid that others are trying to knock them
off their pedestal. Sometimes they develop an impostor complex, caused by deep insecurities that
they aren\'t good enough and may be unmasked.
To prove they aren\'t impostors, they drive so.
How would a CFE devise a plan to prevent subsequent employee fraud.pdfarjuncp10
How would a CFE devise a plan to prevent subsequent employee fraud?
Solution
ANSWER:
Although the prevention of fraud is always less costly and more effective than fraud detection
(and subsequent investigation), however unfortunately prevention is not always possible. This
the reason, as CFE’s Certified Fraud Examiners (CFE) we must all be heavy promoters (and
supporters) of client internal audit functions
The CFE devise a plan to internal audit that includes the procedures to identify or prevent
significant incomplete, inaccurate, or unauthorized transactions; unreliable financial reporting;
deficiencies in safeguarding assets; and deviations from regulations, laws, and institutional
policies. When effectively designed and implemented, internal audits gives directors and senior
managers with timely information in regard to weaknesses in the internal control system and thus
facilitating timely remedial action and prevent subsequent employee fraud. Each institution is
required to have an internal audit function appropriate to the size and the nature and scope of the
activities.
Hilary rode her horse for 8 miles until it was hurt.Then she walked .pdfarjuncp10
Hilary rode her horse for 8 miles until it was hurt.Then she walked back home to call a vet. She
figures the horse wals twice as fast as she does. the whole trip took 4 hours, so how fast would
Hilary have to walk?
Solution
The equation used in this problem is SpeedXTime=Distance
We know that the entire trip takes 4 hours
Let us designate x as the time that it takes the horse to travel 8 miles
4-x= is designated as the time it takes Hilary to walk back
we also know the ratio of rate 2:1
Let us set up the equation
(Distance/Time)=speed of the horse =8/x
(Distance/Time)=speed of Hilary =8/4-x
We need to make both sides of the eqation equal. In order to do this we need to multiply (8/4-x)
by 1/2 since the horse is going 2x the speed of Hilary
8/x=(1/2)(8/4-x)
Simplify by dividing 8 by 2 so that you get 8/x=4/4-x
Cross multiply to get 8(4-x)=4x
Use the distributive property
32-8x=4x
Add 8x to both sides and get
32=12x
Divide both sides by 12
x=1.33 hours it took the horse
4-x=2.67 hours it took Hilary
2.99 or 3 miles per hour
To double check let\'s plug in values
Speed(Time)=8
(3)2.67)=8.0 miles for Hillary
The horse speed is 8/1.33=6.0 mph
the horse is going 6/3 as fast as Hilary the answer is 2..
Find the admittance Yab in the circuit seen in the figure. Take that.pdfarjuncp10
Find the admittance Yab in the circuit seen in the figure. Take that R1 = 6 , R2 = 6 , R3 = 4 and
R4 = 12.8
Part A
Express Yab in rectangular form.
Express your answer in complex form.
The answer is NOT
Yab = (4+j3)10^(5) mS
Yab = 40+j30 mS
510^(5) e^(j36.86)Yab =
510^(5) e^(j36.86) mS j12.8 n Yab bo 12 j10 n
Solution
Z3=R3||j10=4*j10/(4+j10)
Z2=R2+j12=6+j12
Z1=R1-j2=6-j2
Zequ1=Z1||Z2||Z3=2.1517 +j 0.5793
Z=R4+Zequ1-j12.8=12.8-j12.8+2.1517 + j0.5793=14.9517 -j12.2207
Y=1/Z=1/14.9517 -j12.2207
Y=0.0401 + j0.0328
convert rect to polar
a=sqrt((0.0401^2)+(0.0328^2))=0.0518
b=tan-1(-0.0328/0.0401)=- 0.6856 in radins, if conver to degree=-39.2
ans:
0.051806*expj-39.2.
Diversity Paper Each student will complete a diversity research assig.pdfarjuncp10
Diversity Paper Each student will complete a diversity research assignment. Students will
choose one of the populations below and have the selection approved by the instructor. The
assignment explores the resiliency of elders of (African American antic/Latino. Asian American
Indian) or the status of older women in society compared to older men. Students will research the
economic status, health, social supports, living situations marry of one of the special populations
chosen by the student. They will also research specific cultural values and beliefs regarding life,
acceptance of help, and death. Students are encouraged to use the text and at least 3 other reliable
sources to gather information. Sources should be documented in APA style of referencing
Length is 5 pages of content, double-spaced in 12 point font. Paper is due the 7th week of class
and is worth so points. No late submissions will be accepted. The due date is Friday, February
24, by 11:00pm Central Start Date Due Date is Friday, February 24, by 11:00 pm central Time.
Solution
DIVERSITY RESEARCH ASSIGNMENT
Age and Socioeconomic Status
Socioeconomic status (SES) is often measured as a combination of education, income and
occupation. It is commonly conceptualized as the social standing or class of an individual or
group. When viewed through a social class lens, privilege, power and control are emphasized.
Furthermore, an examination of SES as a gradient or continuous variable reveals inequities in
access to and distribution of resources. SES is relevant to all realms of behavioural and social
science, including research, practice, education and advocacy.
SES Affects Our Society
SES affects overall human functioning, including our physical and mental health. Its effects can
be observed across the life span. Variance in socioeconomic status such as disparities in the
distribution of wealth, income and access to resources mitigate social problems that ultimately
affect everyone. All benefit from an increased focus on the foundations of socioeconomic
inequalities and efforts to reduce the deep gaps in socioeconomic status observed today in the
United States and abroad.
While older and retired U.S. residents may enjoy a higher standard of living than their
predecessors, older Americans remain among the most economically vulnerable groups. Of
major concern is whether older Americans will outlive their financial resources. Psychologists
and other social and behavioural science professionals possess the tools necessary to study and
identify strategies to alleviate these disparities at both individual and societal levels.
SES Impacts the Lives of Older Adults
The United States is facing unprecedented increases in the older adult population. Americans age
65 and over comprise nearly 13 percent of the U.S. population, and their proportion is estimated
to increase to 20 percent of the population in the next 25 years. As the percentage of older
Americans rises, so does concern for their econom.
Detailed solutions please 1. Let R and S be commutative rings and le.pdfarjuncp10
Detailed solutions please: 1. Let R and S be commutative rings and let sigma: R right arrow S be
a homomorphism. Prove that if sigma is one to one and b in R is a zero divisor of R, then
sigma(b) is a zero divisor of S.
Solution
we are given that R--->S is a homomorphism
A homomorphism is a map that preserves selected structure between two algebraic structures,
with the structure to be preserved being given by the naming of the homomorphism
the set R and S are the same as they form a homomorphic relation.
now b E R that is b lies with the set R
and since R and S are homomorphic so b will also lie in the ser S
since sigma is one to one function threfore the entire domain of sigma will be mapped .
its also gven that sigma(b) is a zero divisor of R
and since b E S as well
so sigma(b) is a zero divisor of S as well
hence proved..
Describe the mechanisms of asexual reproduction inProkaryotesPr.pdfarjuncp10
Describe the mechanisms of asexual reproduction in:
Prokaryotes
Protists
Plants-
Animals
Solution
Prokaryotes reprodue asexually by BINARY FISSION mehanism. In this the genetic material is
replicated as same as the parent genome the cell devides in two parts and give rise to new
progeny so no geneti diversity is formed.
protists- they also reprodue asexually through binary fission, BUDDING In this new organism
grow from the body of parent.
PLANT- VEGETATIVE reproduction is the main asexual reproduction in which a plant part
give rise of new plant same as the parent, such as growing tips of RHIZOME.
ANIMALS- they also reproduce asexually through budding,fission,fragmentation.In case of stick
inset, bees PARTHENOGENESIS our in whih unfertilised egg give rise to new individual it is a
type of AGAMOGENESIS..
Define intermediate phenotype and then imagine some intermediate phe.pdfarjuncp10
Define intermediate phenotype and then imagine some intermediate phenotypes (e.g. RNA,
metabolite, etc) for Down’s Syndrome.
Solution
intermediate phenotype :
it depicts a living being that shows a mix of the phenotypic characteristics that its parents
expressed.
. In the event that a red blossom cross-pollinates a white bloom, and the subsequent offspring are
pink, the posterity portrayed as a intermediate phenotype .
It happen when the traits under investigation are neither dominant or recessive.
Down disorder (DS or DNS), otherwise called trisomy 21, is a hereditary issue brought about by
the nearness of all or some portion of a third duplicate of chromosome 21. It is commonly
connected with physical development delays, trademark facial elements and mellow to direct
learned incapacity.
Down disorder is brought on by having three duplicates of the qualities on chromosome 21, as
opposed to the standard two.The guardians of the influenced individual are ordinarily
hereditarily ordinary
Those who have one tyke with Down disorder have around a 1% danger of having a moment
youngster with the disorder, if both guardians are found to have typical karyotypes.
The additional chromosome substance can emerge through a few distinctive ways.
The most widely recognized cause (around 92–95% of cases) is an entire additional duplicate of
chromosome 21, bringing about trisomy 21. In 1.0 to 2.5% of cases, a portion of the phones in
the body are typical and others have trisomy 21, known as mosaic Down syndrome.
The other basic systems that can offer ascent to Down disorder include: a Robertsonian
translocation, isochromosome, or ring chromosome.
These contain extra material from chromosome 21 and happen in around 2.5% of cases. An
isochromosome comes about when the two long arms of a chromosome isolate together as
opposed to the long and short arm isolating together amid egg or sperm improvement.
Trisomy 21 is known by the karyotype 47,XX,+21 for females and 47,XY,+21 for guys) is
brought about by a disappointment of the 21st chromosome to isolate amid egg or sperm
development.As an outcome, a sperm or egg cell is delivered with an additional duplicate of
chromosome 21; this cell therefore has 24 chromosomes.
At the point when joined with a typical cell from the other parent, the child has 47 chromosomes,
with three duplicates of chromosome 21.
Around 88% of instances of trisomy 21 result from nonseparation of the chromosomes in the
mother, 8% from nonseparation in the father, and 3% after the egg and sperm have combined.
Translocation : The additional chromosome 21 material may likewise happen due to a
Robertsonian translocation in 2–4% of cases. In this circumstance, the long arm of chromosome
21 is joined to another chromosome, regularly chromosome 14.
In a male influenced with Down disorder, it brings about a karyotype of 46XY,t(14q21q). This
might be another transformation or already display in one of the guardians.
The parent with such a translocation i.
Consider a population of lizards living on the coast of Africa. A sto.pdfarjuncp10
Consider a population of lizards living on the coast of Africa. A storm creates piles of debris
that the lizards use to raft to a faraway uninhabited island. Which evolutionary process is
happening? mutation selection balance the founder effect frequency-dependent selection
coalescence
Solution
Answer is. \"Founder effect\".
The lizards completely moved to new place where they never I habited before, and hence they
found new environment to adjust, which will create some environmental difference. This is
known as founder effect..
Can “discovery science” (for example, the discovery of a new species.pdfarjuncp10
Can “discovery science” (for example, the discovery of a new species of fossil, or a new species
of organism that is alive today) contribute to our understanding of evolution? Give examples.
Solution
Scientists seek natural causes for natural phenomena. This is the most basic description of what a
scientist aims to do every day. Their focus is limited to what they can physically observe and
measure directly, sometimes with the help of tools such as a microscope. They do not seek to
explain the supernatural as it is outside the bounds of science, but instead what is all around
them. There are basic methods of gaining knowledge that are common to all of science.
Biology uses discovery science , and hypothesis-based science . While discovery science is
mostly about describing nature, hypothesis-based science attempts to explain nature. The pair of
inquiries are widely used together in research. Observations that can be measured and verified
are the data of discovery science. In the study of life, discovery science is used to describe both
the simplest of life, and the most complex. From the building blocks of atoms and molecules all
the way up to the ecosystems and biosphere, discovery science describes it all. Discovery
science is based on the logic of inductive reasoning . Inductive reasoning uses numerous specific
observations to make a general statement.
For example: all living things are made of cells. This comes after the numerous discoveries of
cells in every specimen observed by biologists over two centuries. another example we can take
\"humans\". today we found most of the fossils of human lives who lived thousands of years
back and with help of that fossils we can understand growth and evolution human life..
C++Write a function void headEnqueue(Queue q, int key) which enqu.pdfarjuncp10
C++
Write a function void headEnqueue(Queue *q, int key) which enqueues the key such that, at
function exit, it is positioned at the head of the queue rather than the tail; and the order and
integrity of the queue is otherwise maintained.
Solution
struct node
{
int data;
node* next;
};
class Queue //linked_list class
{
private:
node* front;
node* rear;
public:
Queue();
void insert(int);
headEnqueue(Queue *q, int key);
};
Queue::Queue()
{
front = rear = NULL;
}
void Queue::insert(int val)
{
node* temp = new node;
temp->data = val;
temp->next = NULL;
if (front == NULL)
front= rear = temp;
else {
node* temp1 = front;
while (temp1->next)
temp1 = temp1->next;
temp1->next = temp;
}
}
void Queue::headEnqueue(Queue *q, int key)
{
node* temp = new node;
temp->data = key;
temp->next=q->front;
q->front=temp;
}.
All of the following are features or functions of nanobodies except _.pdfarjuncp10
All of the following are features or functions of nanobodies except ______________. small,
monomeric, lack disulfide bonds, and resistance to denaturation high affinity to the antigen
recognize protruding and recessed paratopes cannot be humanized consist of only the VHH
domain of heavy chain antibodies
Solution
d)cannot be humanized
because we have many humanized antibodies that are available .example-CyaA-Hly specific
humanized antibody.
A girl running at a constant speed of 1.4ms in a straight line thro.pdfarjuncp10
A girl running at a constant speed of 1.4m/s in a straight line throw a ball directly upward at 4.7
m/s. How far will she travel before the ball drops back into her hand? Ignore air fiction.
Solution
First find out how long the ball will be in the air,
t = seconds
Gravitational constant: -4.9 m/sec^2
Upward velocity: +4.7 m/s
:
-4.9t^2 + 4.7t = 0
t(-4.9t + 4.7) = 0.
You have a rural dial-up customer who complains that a large number .pdfarjuncp10
You have a rural dial-up customer who complains that a large number of phone calls have been
made to “dangerous” sites on the Internet from his computer but he didn’t make these calls. You
investigate his computer and discover what type of malware?
A. Adware
B. Dialer
C. Keystroke logger
D. Spim
Solution
B. Dialers are types of malicious programs installed on computers that cause the dialup modem
to call dangerous or pay-per-call locations on the Internet, often resulting in extremely high
phone bills for the customer..
You are given a mixed culture containing a anaerobic thermophile, ae.pdfarjuncp10
You are given a mixed culture containing a anaerobic thermophile, aerobic thermophile and
anaerobic hyperthermophile bacteria. How will you separate these into pure cultures?
Solution
In natural environments, microorganisms usually exist as mixed populations. A pure culture is
one by which all organisms are descendants of the exact same organism. A sterile medium is the
one which is free of all life forms. It is often sterilized by heating it to a temperature at which all
contaminating microorganisms are destroyed. Eventually, in functioning with microorganisms,
we ought to have a way of transferring growing organisms from a pure culture to a sterile
medium without introducing any undesirable outside contaminants. This approach of stopping
unwanted microorganisms from developing accessibility is termed aseptic technique.
Microorganisms whose optimal temperature for development is near 0oC are called
psychrophiles. The ones that grow optimally between 20oC and 45eC are called mesophiles.
These growing most useful at large conditions, 55oC to ~ 70oC and larger, are called
thermophiles. Prokaryotes that live at quite high conditions (up to 113oC ) are
hyperthermophiles. An organism that will require air for development is called aerobic. An
organism whose development can\'t arise in the presence of air is anaerobic. An organism that
may grow under either aerobic or anaerobic conditions is a facultative anaerobe. Microaerophilic
organisms involve free air but at a limited concentration. Based on this, the plates are incubated
at different temperatures with aerobic and anerobic conditions for enhancing the growth of
thermophiles and hyperthermophilc bacteria..
Woyld removing phenylethyl alcohol from PEA alter the mediumsS.pdfarjuncp10
Woyld removing phenylethyl alcohol from PEA alter the medium\'s
Solution
Phenylethyl alcohol agar (PEA) medium is a selective media that inhibit the growth of gram-
negative bacteria and allows the growth of gram-positive bacteria only. The phenyl ethyl alcohol
is responsible for preventing the growth of gram-negative bacteria. So, removing phenyl ethyl
alcohol from PEA alter the medium\'s specificity againstgram positivebacteria..
Which abstraction uses slates, state transitions, inputs and outputs .pdfarjuncp10
Which abstraction uses slates, state transitions, inputs and outputs to model a complex system?
How is the order of the entries in a linked list determined?
Solution
7)
State Machines are used states, state transistion diagrams, and inpuit & output systems. State
Machines outputs are depending on the entire history if theire inputs..
What is the target cell for the hormone AngiotensionogenSolut.pdfarjuncp10
What is the target cell for the hormone Angiotensionogen?
Solution
Answer: zona glomerulosa cells of the adrenal cortex in the adrenal gland on kidney
Reason:
Primarily low blood pressure trigger the release of precursor, angiotensinogen peptide, a serpin
family from the liver cells followed by formation of angiotensin I finally to angiotensin II in the
presence of angiotensin converting enzyme (ACE). This angiotensin II active form is going to
act on the \"zona glomerulosa cells of the adrenal cortex in the adrenal gland on kidney\" to
trigger release of aldosterone to act on kidney cells finally to the reabsorption of sodium.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
1. Add a breadth-first (level-order) traversal function to the binar.pdf
1. 1. Add a breadth-first (level-order) traversal function to the binary tree code.
2. Add a function to find the height of a tree.
3. Re-implement one of the depth-first traversal methods using a stack instead of recursion.
4. Add a link to each nodes parent node.
#include
#include
#include
using namespace std;
template < typename T >
class TreeNode
{
public:
T element; //
TreeNode < T > * left; //
TreeNode < T > * right; //
TreeNode * next;
TreeNode() //
{
left = NULL;
next = NULL;
}
TreeNode(T element) // Constructor
{
this->element = element;
left = NULL;
right = NULL;
}
};
template < typename T >
class BinaryTree
{
public:
BinaryTree();
BinaryTree(T elements[], int arraySize);
2. bool insert(T element);
void inorder();
void preorder();
void postorder();
int getSize();
bool search(T element);
void breadthFirstTraversal();
int depth();
private:
TreeNode < T > * root;
int size;
void inorder(TreeNode < T > * root);
void postorder(TreeNode < T > * root);
void preorder(TreeNode < T > * root);
bool search(T element, TreeNode < T > * root);
int depth(TreeNode * root);
};
template < typename T >
BinaryTree < T >::BinaryTree()
{
root = NULL;
size = 0;
}
template < typename T >
BinaryTree < T >::BinaryTree(T elements[], int arraySize)
{
root = NULL;
size = 0;
for (int i = 0; i < arraySize; i++)
{
insert(elements[i]);
}
}
template < typename T >
bool BinaryTree < T >::insert(T element)
{
3. if (root == NULL)
root = new TreeNode < T > (element); // Create a new root
else
{
// Locate the parent node
TreeNode < T > * parent = NULL;
TreeNode < T > * current = root;
while (current != NULL)
if (element < current->element)
{
parent = current;
current = current->left;
}
else if (element > current->element)
{
parent = current;
current = current->right;
}
else
return false; // Duplicate node not inserted
// Create the new node and attach it to the parent node
if (element < parent->element)
parent->left = new TreeNode < T > (element);
else
parent->right = new TreeNode < T > (element);
}
size++;
return true; // Element inserted
}
/* Inorder traversal */
template < typename T >
void BinaryTree < T >::inorder()
{
inorder(root);
}
/* Inorder traversal from a subtree */
4. template < typename T >
void BinaryTree < T >::inorder(TreeNode < T > * root)
{
if (root == NULL) return;
inorder(root->left);
cout << root->element << " ";
inorder(root->right);
}
/* Postorder traversal */
template < typename T >
void BinaryTree < T >::postorder()
{
postorder(root);
}
/** Inorder traversal from a subtree */
template < typename T >
void BinaryTree < T >::postorder(TreeNode < T > * root)
{
if (root == NULL) return;
postorder(root->left);
postorder(root->right);
cout << root->element << " ";
}
/* */
template < typename T >
void BinaryTree < T >::preorder()
{
preorder(root);
}
/* */
template < typename T >
void BinaryTree < T >::preorder(TreeNode < T > * root)
{
if (root == NULL) return;
cout << root->element << " ";
preorder(root->left);
5. preorder(root->right);
}
/**/
template < typename T >
int BinaryTree < T >::getSize()
{
return size;
}
template < typename T >
bool BinaryTree < T >::search(T element)
{
return search(element, root);
}
template < typename T >
bool BinaryTree < T >::search(T element, TreeNode < T > * root)
{
if (root == NULL)
return false;
else if (root->element == element)
return true;
else if (root->element > element)
return search(element, root->right);
else
return search(element, root->left);
}
int main()
{
BinaryTree < string > tree1;
tree1.insert("George");
tree1.insert("Michael");
tree1.insert("Tom");
tree1.insert("Adam");
tree1.insert("Jones");
tree1.insert("Peter");
tree1.insert("Daniel");
7. left = NULL;
next = NULL;
}
TreeNode(T element) // Constructor
{
this->element = element;
left = NULL;
right = NULL;
}
};
template < typename T >
class BinaryTree
{
public:
BinaryTree();
BinaryTree(T elements[], int arraySize);
bool insert(T element);
void inorder();
void preorder();
void postorder();
int getSize();
bool search(T element);
void breadthFirstTraversal();
int depth();
void BFS();
private:
TreeNode < T > * root;
int size;
void inorder(TreeNode < T > * root);
void postorder(TreeNode < T > * root);
void preorder(TreeNode < T > * root);
bool search(T element, TreeNode < T > * root);
int depth(TreeNode * root);
void printLevelOrder(TreeNode < T > * root);
void printGivenLevel(TreeNode < T > * root, int level);
8. };
template < typename T >
int BinaryTree < T >::depth()
{
depth(root);
}
template < typename T >
void BinaryTree < T >::BFS()
{
printLevelOrder(root);
}
template < typename T >
void BinaryTree < T >::printLevelOrder(TreeNode < T > * root)
{
int h = depth(root);
int i;
for (i=1; i<=h; i++)
printGivenLevel(root, i);
}
/* Print nodes at a given level */
template < typename T >
void BinaryTree < T >::printGivenLevel(TreeNode < T > * root, int level)
{
if (root == NULL)
return;
if (level == 1)
cout<<" "<element;
else if (level > 1)
{
printGivenLevel(root->left, level-1);
printGivenLevel(root->right, level-1);
}
}
template < typename T >
int BinaryTree < T >::depth(TreeNode < T > * element)
9. {
if (element==NULL)
return 0;
else
{
int lDepth = depth(element->left);
int rDepth = depth(element->right);
// use the larger one
if (lDepth > rDepth)
return(lDepth+1);
else return(rDepth+1);
}
}
template < typename T >
BinaryTree < T >::BinaryTree()
{
root = NULL;
size = 0;
}
template < typename T >
BinaryTree < T >::BinaryTree(T elements[], int arraySize)
{
root = NULL;
size = 0;
for (int i = 0; i < arraySize; i++)
{
insert(elements[i]);
}
}
template < typename T >
bool BinaryTree < T >::insert(T element)
{
if (root == NULL)
10. root = new TreeNode < T > (element); // Create a new root
else
{
// Locate the parent node
TreeNode < T > * parent = NULL;
TreeNode < T > * current = root;
while (current != NULL)
if (element < current->element)
{
parent = current;
current = current->left;
}
else if (element > current->element)
{
parent = current;
current = current->right;
}
else
return false; // Duplicate node not inserted
// Create the new node and attach it to the parent node
if (element < parent->element)
parent->left = new TreeNode < T > (element);
else
parent->right = new TreeNode < T > (element);
}
size++;
return true; // Element inserted
}
/* Inorder traversal */
template < typename T >
void BinaryTree < T >::inorder()
{
inorder(root);
}
/* Inorder traversal from a subtree */
template < typename T >
11. void BinaryTree < T >::inorder(TreeNode < T > * root)
{
if (root == NULL) return;
inorder(root->left);
cout << root->element << " ";
inorder(root->right);
}
/* Postorder traversal */
template < typename T >
void BinaryTree < T >::postorder()
{
postorder(root);
}
/** Inorder traversal from a subtree */
template < typename T >
void BinaryTree < T >::postorder(TreeNode < T > * root)
{
if (root == NULL) return;
postorder(root->left);
postorder(root->right);
cout << root->element << " ";
}
/* */
template < typename T >
void BinaryTree < T >::preorder()
{
preorder(root);
}
/* */
template < typename T >
void BinaryTree < T >::preorder(TreeNode < T > * root)
{
if (root == NULL) return;
cout << root->element << " ";
preorder(root->left);
preorder(root->right);
12. }
/**/
template < typename T >
int BinaryTree < T >::getSize()
{
return size;
}
template < typename T >
bool BinaryTree < T >::search(T element)
{
return search(element, root);
}
template < typename T >
bool BinaryTree < T >::search(T element, TreeNode < T > * root)
{
if (root == NULL)
return false;
else if (root->element == element)
return true;
else if (root->element > element)
return search(element, root->right);
else
return search(element, root->left);
}
int main()
{
BinaryTree < string > tree1;
tree1.insert("George");
tree1.insert("Michael");
tree1.insert("Tom");
tree1.insert("Adam");
tree1.insert("Jones");
tree1.insert("Peter");
tree1.insert("Daniel");
cout << "Inorder (sorted): ";
tree1.inorder();