SlideShare a Scribd company logo
1 of 17
hw1.docxCS 211 Homework #1
Please complete the homework problems on the following page
using a separate piece of paper. Note that this is an individual
assignment and all work must be your own. Be sure to show
your work when appropriate. This assignment is due in lab on
Monday, October 10, 2016.
1. [3] Given the following pre-order and in-order traversals,
reconstruct the appropriate binary tree. NOTE: You must draw
a single tree that works for both traversals.
Pre-order: A, E, D, G, B, F, I, C
In-order: D, E, B, G, A, F, I, C
2. [3] Starting with an empty BST, draw each step in the
following operation sequence. Assume that all removals come
from the left subtree when the node to remove is full.
Insert(5), Insert(10), Insert(2), Insert(9), Insert(1), Insert(3),
Remove(5).
3. [3] Starting with an empty BST, draw each step in the
following operation sequence. Assume that all removals come
from the right subtree when the node to remove is full.
Insert(10), Insert(5), Insert(23), Insert(4), Insert(19), Insert(7),
Insert(9), Insert(6), Remove(5).
4. Given the following binary tree:
A. [1] What is the height of the tree?
B. [1] What is the depth of node 90?
C. [1] What is the height of node 90?
D. [3] Give the pre-order, in-order, and post-order traversal of
this tree.
5. Given the following two functions:
int f(int n)
{
if(n <= 0)
{
Return 0;
}
return 1 + f(n - 1);
}
int g(int n)
{
int sum = 0;
for(int i = 0; i < n; i++)
{
sum += 1;
}
Return sum;
}
A. [2] State the runtime complexity of both f() and g()
B. [2] State the memory complexity for both f() and g()
C. [4] Write another function called "int h(int n)" that does the
same thing but has a more efficient runtime complexity.
Requirements:
This abstract and outline is for your individual paper that you
will be handing in on finals week. Same topic as with your
team, but you will write a one paragraph abstract describing
your topic, and how you plan to treat it. While you will be
walking through all the steps of the Systems Process (which I
understand we havent covered in full yet) you may in your
abstract and outline want to mention parts that will have more
emphasis based on your knowledge of the background of your
problem. The outline should obviously include all the steps of
the systems process with extra elements based your what you
think will have heavier emphasis.
Idea:
So as you know, Elon Musk has just announced SpaceX plan to
colonize Mars in the upcoming decades and we thought this
would be an interesting topic to research through the 13 steps of
the systems engineering process.
Links:
Full Video: https://www.youtube.com/watch?v=IAZ-Xbn5hr0
Short
Abbreviated: https://www.youtube.com/watch?v=Yzw6_V7LGe
Y
Our group idea: after people went to Mars, they will build a
system
these ideas supposed to be I think or depends on you:
Buildings, spaces to live, water, and other elements required for
life, write in an engineering way.
13 steps:
MMMM7.cbp
MA7.docxCS 211 Micro Assignment #7
For this micro assignment, you must implement the following
two functions inside BinarySearchTree.h: int getHeight()
Returns the height of the tree. Note that you are allowed to
solve this iteratively or recursively. If you go the recursive
route, you'll probably need to create a helper function, similar
to the tree's addElementHelper. Here's the relevant slide from
the powerpoint presentation:
int getSize()
Returns the total number of nodes present in the tree. Note that
I purposely took out the _size variable from the tree's
implementation. You are not allowed to use a counter variable.
Instead, like getHeight, you must calculate the tree's height
either iteratively or recursively.
Grading
Your submission will be graded based on the following:
1. [7] Your solution passes the test cases
2. [3] Your code contains good style. For example,
· You provide meaningful variable names
· You provide sufficient and meaningful comments
· Your code is well structured
Due Date
This assignment must be submitted through Canvas no later than
1:00 PM on Tuesday, October 11, 2016. Submit your solution
to Canvas in a ZIP file that contains all code and project files
(either Visual Studio or Codeblocks).
TreeNode (2).h
#ifndef TREE_NODE_H
#define TREE_NODE_H
template <typename T>
class TreeNode
{
private:
TreeNode<T> *_left_child = nullptr;
TreeNode<T> *_right_child = nullptr;
T _value;
public:
TreeNode(TreeNode<T> *left_child = nullptr, TreeNode<T>
*right_child = nullptr)
{
_left_child = left_child;
_right_child = right_child;
}
TreeNode<T> *getLeftChild()
{
return _left_child;
}
void setLeftChild(TreeNode<T> *child)
{
_left_child = child;
}
TreeNode<T> *getRightChild()
{
return _right_child;
}
void setRightChild(TreeNode<T> *child)
{
_right_child = child;
}
T getValue()
{
return _value;
}
void setValue(T value)
{
_value = value;
}
};
#endif // TREE_NODE_H
main (2).cpp
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <initializer_list>
#include "StringSplitter.h"
#include "BinarySearchTree.h"
using namespace std;
void bstTest(initializer_list<int> values, int expected_height,
int expected_size)
{
BinarySearchTree<int> bst{};
for (auto value : values)
{
bst.addItem(value);
}
cout << "Height: " << bst.getHeight() << " (expected: " <<
expected_height << ")" << endl;
cout << "Size: " << bst.getSize() << " (expected: " <<
expected_size << ")" << endl;
}
int main()
{
bstTest({ 1, 2, 3, 4, 5 }, 4, 5);
bstTest({ 5, 2, 3, 4, 1 }, 2, 5);
bstTest({ 10, 7, 15, 12 }, 2, 4);
return 0;
}
StringSplitter (2).h
#ifndef STRING_SPLITTER_H
#define STRING_SPLITTER_H
#include <string>
#include <vector>
#include <queue>
using namespace std;
class StringSplitter
{
public:
//Breaks apart the supplied text based on the given delimiter
//static function do not affect the internal state
//(e.g. variables) of a given class instance
static queue<string> splitQ(string text, string delimiter)
{
//vectors are dynamically expanding arrays
queue<string> pieces;
//find the first delimiter
int location = text.find(delimiter);
//we are starting at the beginning of our string
int start = 0;
//go until we have no more delimiters
while (location != string::npos)
{
//add the current piece to our list of pieces
string piece = text.substr(start, location - start);
pieces.push(piece);
//update our index markers for the next round
start = location + 1;
location = text.find(delimiter, start);
}
//at the end of our loop, we're going to have one
trailing piece to take care of.
//handle that now.
string piece = text.substr(start, location - start);
pieces.push(piece);
//now, return the completed vector
return pieces;
}
};
#endif // STRING_SPLITTER_H
BinarySearchTree (2).h
#ifndef BINARY_SEARCH_TREE_H
#define BINARY_SEARCH_TREE_H
#include "TreeNode.h"
/*
Incomplete BST. We will fill this out more in future lectures.
*/
template <typename T>
class BinarySearchTree
{
private:
TreeNode<T> *_root = nullptr;
protected:
virtual TreeNode<T> *findLargestRec(TreeNode<T>
*root)
{
//base case: root has no right child or root is null
if (root == nullptr || root->getRightChild() == nullptr)
{
return root;
}
return findLargestRec(root->getRightChild());
}
virtual TreeNode<T> *findLargestIter(TreeNode<T>
*root)
{
while (root != nullptr || root->getRightChild() !=
nullptr)
{
root = root->getRightChild();
}
return root;
}
virtual TreeNode<T> * addItemHelper(TreeNode<T> *root,
T item)
{
//BASE CASE: null root
if (root == nullptr)
{
//allocate new space, store value, then return.
root = new TreeNode<T>{};
root->setValue(item);
return root;
}
//RECURSIVE CASE: root is not null
if (item >= root->getValue())
{
//CASE 1: belongs on the right side of root
TreeNode<T> *right = addItemHelper(
root->getRightChild(),
item
);
//update right side with reconfigured state
root->setRightChild(right);
}
else
{
//CASE 2: belongs on the left side of root
TreeNode<T> *left = addItemHelper(
root->getLeftChild(),
item
);
root->setLeftChild(left);
}
return root;
}
public:
virtual void addItem(T value)
{
_root = addItemHelper(_root, value);
}
//MA #7 TODO: implement!
//Gets the height of the tree.
int getHeight()
{
return 0;
}
//MA #7 TODO: implement!
//Note: You cannot use a "counter variable" to track
height. Your function must
//calculate the height manually (probably w/ recursion).
int getSize()
{
return 0;
}
};
#endif // BINARY_SEARCH_TREE_H

More Related Content

Similar to hw1.docxCS 211 Homework #1Please complete the homework problem.docx

Dancing Links: an educational pearl
Dancing Links: an educational pearlDancing Links: an educational pearl
Dancing Links: an educational pearlESUG
 
Standard Template Library (STL) in Object Oriented Programming
Standard Template Library (STL) in Object Oriented ProgrammingStandard Template Library (STL) in Object Oriented Programming
Standard Template Library (STL) in Object Oriented ProgrammingMandeep Singh
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxfredharris32
 
Layout planning
Layout planningLayout planning
Layout planning8979473684
 
Web-IT Support and Consulting - dBase exports
Web-IT Support and Consulting - dBase exportsWeb-IT Support and Consulting - dBase exports
Web-IT Support and Consulting - dBase exportsDirk Cludts
 
Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...
Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...
Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...Dirk Cludts
 
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docxCMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docxmary772
 
Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02auswhit
 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5thConnex
 
Using-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUadAccount
 
05-transformers.pdf
05-transformers.pdf05-transformers.pdf
05-transformers.pdfChaoYang81
 
CS 112 PA #4Like the previous programming assignment, this assignm.docx
CS 112 PA #4Like the previous programming assignment, this assignm.docxCS 112 PA #4Like the previous programming assignment, this assignm.docx
CS 112 PA #4Like the previous programming assignment, this assignm.docxannettsparrow
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfkarymadelaneyrenne19
 
computer notes - Linked list inside computer memory
computer notes - Linked list inside computer memorycomputer notes - Linked list inside computer memory
computer notes - Linked list inside computer memoryecomputernotes
 
OverviewUsing the C-struct feature, design, implement and .docx
OverviewUsing the C-struct feature, design, implement and .docxOverviewUsing the C-struct feature, design, implement and .docx
OverviewUsing the C-struct feature, design, implement and .docxalfred4lewis58146
 

Similar to hw1.docxCS 211 Homework #1Please complete the homework problem.docx (20)

Dancing Links: an educational pearl
Dancing Links: an educational pearlDancing Links: an educational pearl
Dancing Links: an educational pearl
 
Standard Template Library (STL) in Object Oriented Programming
Standard Template Library (STL) in Object Oriented ProgrammingStandard Template Library (STL) in Object Oriented Programming
Standard Template Library (STL) in Object Oriented Programming
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
C sharp chap6
C sharp chap6C sharp chap6
C sharp chap6
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docx
 
CPP homework help
CPP homework helpCPP homework help
CPP homework help
 
Layout planning
Layout planningLayout planning
Layout planning
 
A01
A01A01
A01
 
Web-IT Support and Consulting - dBase exports
Web-IT Support and Consulting - dBase exportsWeb-IT Support and Consulting - dBase exports
Web-IT Support and Consulting - dBase exports
 
Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...
Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...
Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...
 
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docxCMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
 
React native
React nativeReact native
React native
 
Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02
 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5th
 
Using-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptx
 
05-transformers.pdf
05-transformers.pdf05-transformers.pdf
05-transformers.pdf
 
CS 112 PA #4Like the previous programming assignment, this assignm.docx
CS 112 PA #4Like the previous programming assignment, this assignm.docxCS 112 PA #4Like the previous programming assignment, this assignm.docx
CS 112 PA #4Like the previous programming assignment, this assignm.docx
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
 
computer notes - Linked list inside computer memory
computer notes - Linked list inside computer memorycomputer notes - Linked list inside computer memory
computer notes - Linked list inside computer memory
 
OverviewUsing the C-struct feature, design, implement and .docx
OverviewUsing the C-struct feature, design, implement and .docxOverviewUsing the C-struct feature, design, implement and .docx
OverviewUsing the C-struct feature, design, implement and .docx
 

More from wellesleyterresa

Hw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docx
Hw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docxHw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docx
Hw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docxwellesleyterresa
 
HW in teams of 3 studentsAn oil remanufacturing company uses c.docx
HW in teams of 3 studentsAn oil remanufacturing company uses c.docxHW in teams of 3 studentsAn oil remanufacturing company uses c.docx
HW in teams of 3 studentsAn oil remanufacturing company uses c.docxwellesleyterresa
 
HW 5.docxAssignment 5 – Currency riskYou may do this assig.docx
HW 5.docxAssignment 5 – Currency riskYou may do this assig.docxHW 5.docxAssignment 5 – Currency riskYou may do this assig.docx
HW 5.docxAssignment 5 – Currency riskYou may do this assig.docxwellesleyterresa
 
HW#3 – Spring 20181. Giulia is traveling from Italy to China. .docx
HW#3 – Spring 20181. Giulia is traveling from Italy to China. .docxHW#3 – Spring 20181. Giulia is traveling from Italy to China. .docx
HW#3 – Spring 20181. Giulia is traveling from Italy to China. .docxwellesleyterresa
 
HW 2Due July 1 by 500 PM.docx
HW 2Due July 1 by 500 PM.docxHW 2Due July 1 by 500 PM.docx
HW 2Due July 1 by 500 PM.docxwellesleyterresa
 
HW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docx
HW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docxHW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docx
HW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docxwellesleyterresa
 
HW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docx
HW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docxHW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docx
HW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docxwellesleyterresa
 
HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
HW 5-RSAascii2str.mfunction str = ascii2str(ascii)        .docxHW 5-RSAascii2str.mfunction str = ascii2str(ascii)        .docx
HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docxwellesleyterresa
 
HW 3 Project Control• Status meeting agenda – shows time, date .docx
HW 3 Project Control• Status meeting agenda – shows time, date .docxHW 3 Project Control• Status meeting agenda – shows time, date .docx
HW 3 Project Control• Status meeting agenda – shows time, date .docxwellesleyterresa
 
HW 1January 19 2017Due back Jan 26, in class.1. (T.docx
HW 1January 19 2017Due back Jan 26, in class.1. (T.docxHW 1January 19 2017Due back Jan 26, in class.1. (T.docx
HW 1January 19 2017Due back Jan 26, in class.1. (T.docxwellesleyterresa
 
Hussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docx
Hussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docxHussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docx
Hussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docxwellesleyterresa
 
HUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docx
HUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docxHUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docx
HUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docxwellesleyterresa
 
HW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docx
HW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docxHW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docx
HW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docxwellesleyterresa
 
HW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docx
HW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docxHW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docx
HW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docxwellesleyterresa
 
Hunters Son Dialogue Activity1. Please write 1-2 sentences for e.docx
Hunters Son Dialogue Activity1. Please write 1-2 sentences for e.docxHunters Son Dialogue Activity1. Please write 1-2 sentences for e.docx
Hunters Son Dialogue Activity1. Please write 1-2 sentences for e.docxwellesleyterresa
 
HW 2 - SQL The database you will use for this assignme.docx
HW 2 - SQL   The database you will use for this assignme.docxHW 2 - SQL   The database you will use for this assignme.docx
HW 2 - SQL The database you will use for this assignme.docxwellesleyterresa
 
Humanities Commons Learning Goals1. Write about primary and seco.docx
Humanities Commons Learning Goals1. Write about primary and seco.docxHumanities Commons Learning Goals1. Write about primary and seco.docx
Humanities Commons Learning Goals1. Write about primary and seco.docxwellesleyterresa
 
HURRICANE KATRINA A NATION STILL UNPREPARED .docx
HURRICANE KATRINA  A NATION STILL UNPREPARED   .docxHURRICANE KATRINA  A NATION STILL UNPREPARED   .docx
HURRICANE KATRINA A NATION STILL UNPREPARED .docxwellesleyterresa
 
Humanities 115Short Essay Grading CriteriaExcellentPassing.docx
Humanities 115Short Essay Grading CriteriaExcellentPassing.docxHumanities 115Short Essay Grading CriteriaExcellentPassing.docx
Humanities 115Short Essay Grading CriteriaExcellentPassing.docxwellesleyterresa
 
HUMAN RESOURCES’ ROLE IN SUCCESSION PLANNING Succession planni.docx
HUMAN RESOURCES’ ROLE IN SUCCESSION PLANNING Succession planni.docxHUMAN RESOURCES’ ROLE IN SUCCESSION PLANNING Succession planni.docx
HUMAN RESOURCES’ ROLE IN SUCCESSION PLANNING Succession planni.docxwellesleyterresa
 

More from wellesleyterresa (20)

Hw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docx
Hw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docxHw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docx
Hw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docx
 
HW in teams of 3 studentsAn oil remanufacturing company uses c.docx
HW in teams of 3 studentsAn oil remanufacturing company uses c.docxHW in teams of 3 studentsAn oil remanufacturing company uses c.docx
HW in teams of 3 studentsAn oil remanufacturing company uses c.docx
 
HW 5.docxAssignment 5 – Currency riskYou may do this assig.docx
HW 5.docxAssignment 5 – Currency riskYou may do this assig.docxHW 5.docxAssignment 5 – Currency riskYou may do this assig.docx
HW 5.docxAssignment 5 – Currency riskYou may do this assig.docx
 
HW#3 – Spring 20181. Giulia is traveling from Italy to China. .docx
HW#3 – Spring 20181. Giulia is traveling from Italy to China. .docxHW#3 – Spring 20181. Giulia is traveling from Italy to China. .docx
HW#3 – Spring 20181. Giulia is traveling from Italy to China. .docx
 
HW 2Due July 1 by 500 PM.docx
HW 2Due July 1 by 500 PM.docxHW 2Due July 1 by 500 PM.docx
HW 2Due July 1 by 500 PM.docx
 
HW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docx
HW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docxHW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docx
HW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docx
 
HW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docx
HW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docxHW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docx
HW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docx
 
HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
HW 5-RSAascii2str.mfunction str = ascii2str(ascii)        .docxHW 5-RSAascii2str.mfunction str = ascii2str(ascii)        .docx
HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
 
HW 3 Project Control• Status meeting agenda – shows time, date .docx
HW 3 Project Control• Status meeting agenda – shows time, date .docxHW 3 Project Control• Status meeting agenda – shows time, date .docx
HW 3 Project Control• Status meeting agenda – shows time, date .docx
 
HW 1January 19 2017Due back Jan 26, in class.1. (T.docx
HW 1January 19 2017Due back Jan 26, in class.1. (T.docxHW 1January 19 2017Due back Jan 26, in class.1. (T.docx
HW 1January 19 2017Due back Jan 26, in class.1. (T.docx
 
Hussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docx
Hussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docxHussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docx
Hussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docx
 
HUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docx
HUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docxHUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docx
HUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docx
 
HW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docx
HW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docxHW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docx
HW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docx
 
HW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docx
HW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docxHW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docx
HW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docx
 
Hunters Son Dialogue Activity1. Please write 1-2 sentences for e.docx
Hunters Son Dialogue Activity1. Please write 1-2 sentences for e.docxHunters Son Dialogue Activity1. Please write 1-2 sentences for e.docx
Hunters Son Dialogue Activity1. Please write 1-2 sentences for e.docx
 
HW 2 - SQL The database you will use for this assignme.docx
HW 2 - SQL   The database you will use for this assignme.docxHW 2 - SQL   The database you will use for this assignme.docx
HW 2 - SQL The database you will use for this assignme.docx
 
Humanities Commons Learning Goals1. Write about primary and seco.docx
Humanities Commons Learning Goals1. Write about primary and seco.docxHumanities Commons Learning Goals1. Write about primary and seco.docx
Humanities Commons Learning Goals1. Write about primary and seco.docx
 
HURRICANE KATRINA A NATION STILL UNPREPARED .docx
HURRICANE KATRINA  A NATION STILL UNPREPARED   .docxHURRICANE KATRINA  A NATION STILL UNPREPARED   .docx
HURRICANE KATRINA A NATION STILL UNPREPARED .docx
 
Humanities 115Short Essay Grading CriteriaExcellentPassing.docx
Humanities 115Short Essay Grading CriteriaExcellentPassing.docxHumanities 115Short Essay Grading CriteriaExcellentPassing.docx
Humanities 115Short Essay Grading CriteriaExcellentPassing.docx
 
HUMAN RESOURCES’ ROLE IN SUCCESSION PLANNING Succession planni.docx
HUMAN RESOURCES’ ROLE IN SUCCESSION PLANNING Succession planni.docxHUMAN RESOURCES’ ROLE IN SUCCESSION PLANNING Succession planni.docx
HUMAN RESOURCES’ ROLE IN SUCCESSION PLANNING Succession planni.docx
 

Recently uploaded

KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 

Recently uploaded (20)

KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 

hw1.docxCS 211 Homework #1Please complete the homework problem.docx

  • 1. hw1.docxCS 211 Homework #1 Please complete the homework problems on the following page using a separate piece of paper. Note that this is an individual assignment and all work must be your own. Be sure to show your work when appropriate. This assignment is due in lab on Monday, October 10, 2016. 1. [3] Given the following pre-order and in-order traversals, reconstruct the appropriate binary tree. NOTE: You must draw a single tree that works for both traversals. Pre-order: A, E, D, G, B, F, I, C In-order: D, E, B, G, A, F, I, C 2. [3] Starting with an empty BST, draw each step in the following operation sequence. Assume that all removals come from the left subtree when the node to remove is full. Insert(5), Insert(10), Insert(2), Insert(9), Insert(1), Insert(3), Remove(5). 3. [3] Starting with an empty BST, draw each step in the following operation sequence. Assume that all removals come from the right subtree when the node to remove is full. Insert(10), Insert(5), Insert(23), Insert(4), Insert(19), Insert(7), Insert(9), Insert(6), Remove(5). 4. Given the following binary tree: A. [1] What is the height of the tree? B. [1] What is the depth of node 90? C. [1] What is the height of node 90? D. [3] Give the pre-order, in-order, and post-order traversal of this tree. 5. Given the following two functions: int f(int n)
  • 2. { if(n <= 0) { Return 0; } return 1 + f(n - 1); } int g(int n) { int sum = 0; for(int i = 0; i < n; i++) { sum += 1; } Return sum; } A. [2] State the runtime complexity of both f() and g() B. [2] State the memory complexity for both f() and g() C. [4] Write another function called "int h(int n)" that does the same thing but has a more efficient runtime complexity. Requirements: This abstract and outline is for your individual paper that you will be handing in on finals week. Same topic as with your team, but you will write a one paragraph abstract describing your topic, and how you plan to treat it. While you will be walking through all the steps of the Systems Process (which I understand we havent covered in full yet) you may in your
  • 3. abstract and outline want to mention parts that will have more emphasis based on your knowledge of the background of your problem. The outline should obviously include all the steps of the systems process with extra elements based your what you think will have heavier emphasis. Idea: So as you know, Elon Musk has just announced SpaceX plan to colonize Mars in the upcoming decades and we thought this would be an interesting topic to research through the 13 steps of the systems engineering process. Links: Full Video: https://www.youtube.com/watch?v=IAZ-Xbn5hr0 Short Abbreviated: https://www.youtube.com/watch?v=Yzw6_V7LGe Y Our group idea: after people went to Mars, they will build a system these ideas supposed to be I think or depends on you: Buildings, spaces to live, water, and other elements required for life, write in an engineering way. 13 steps: MMMM7.cbp MA7.docxCS 211 Micro Assignment #7 For this micro assignment, you must implement the following two functions inside BinarySearchTree.h: int getHeight()
  • 4. Returns the height of the tree. Note that you are allowed to solve this iteratively or recursively. If you go the recursive route, you'll probably need to create a helper function, similar to the tree's addElementHelper. Here's the relevant slide from the powerpoint presentation: int getSize() Returns the total number of nodes present in the tree. Note that I purposely took out the _size variable from the tree's implementation. You are not allowed to use a counter variable. Instead, like getHeight, you must calculate the tree's height either iteratively or recursively. Grading Your submission will be graded based on the following: 1. [7] Your solution passes the test cases 2. [3] Your code contains good style. For example, · You provide meaningful variable names · You provide sufficient and meaningful comments · Your code is well structured Due Date This assignment must be submitted through Canvas no later than 1:00 PM on Tuesday, October 11, 2016. Submit your solution to Canvas in a ZIP file that contains all code and project files (either Visual Studio or Codeblocks). TreeNode (2).h #ifndef TREE_NODE_H #define TREE_NODE_H template <typename T> class TreeNode
  • 5. { private: TreeNode<T> *_left_child = nullptr; TreeNode<T> *_right_child = nullptr; T _value; public: TreeNode(TreeNode<T> *left_child = nullptr, TreeNode<T> *right_child = nullptr) { _left_child = left_child; _right_child = right_child; } TreeNode<T> *getLeftChild() { return _left_child; }
  • 6. void setLeftChild(TreeNode<T> *child) { _left_child = child; } TreeNode<T> *getRightChild() { return _right_child; } void setRightChild(TreeNode<T> *child) { _right_child = child; } T getValue() {
  • 7. return _value; } void setValue(T value) { _value = value; } }; #endif // TREE_NODE_H main (2).cpp #include <iostream> #include <string> #include <vector> #include <queue> #include <initializer_list> #include "StringSplitter.h" #include "BinarySearchTree.h"
  • 8. using namespace std; void bstTest(initializer_list<int> values, int expected_height, int expected_size) { BinarySearchTree<int> bst{}; for (auto value : values) { bst.addItem(value); } cout << "Height: " << bst.getHeight() << " (expected: " << expected_height << ")" << endl; cout << "Size: " << bst.getSize() << " (expected: " << expected_size << ")" << endl; } int main() {
  • 9. bstTest({ 1, 2, 3, 4, 5 }, 4, 5); bstTest({ 5, 2, 3, 4, 1 }, 2, 5); bstTest({ 10, 7, 15, 12 }, 2, 4); return 0; } StringSplitter (2).h #ifndef STRING_SPLITTER_H #define STRING_SPLITTER_H #include <string> #include <vector> #include <queue> using namespace std; class StringSplitter { public:
  • 10. //Breaks apart the supplied text based on the given delimiter //static function do not affect the internal state //(e.g. variables) of a given class instance static queue<string> splitQ(string text, string delimiter) { //vectors are dynamically expanding arrays queue<string> pieces; //find the first delimiter int location = text.find(delimiter); //we are starting at the beginning of our string int start = 0; //go until we have no more delimiters while (location != string::npos) {
  • 11. //add the current piece to our list of pieces string piece = text.substr(start, location - start); pieces.push(piece); //update our index markers for the next round start = location + 1; location = text.find(delimiter, start); } //at the end of our loop, we're going to have one trailing piece to take care of. //handle that now. string piece = text.substr(start, location - start); pieces.push(piece); //now, return the completed vector return pieces; }
  • 12. }; #endif // STRING_SPLITTER_H BinarySearchTree (2).h #ifndef BINARY_SEARCH_TREE_H #define BINARY_SEARCH_TREE_H #include "TreeNode.h" /* Incomplete BST. We will fill this out more in future lectures. */ template <typename T> class BinarySearchTree { private: TreeNode<T> *_root = nullptr;
  • 13. protected: virtual TreeNode<T> *findLargestRec(TreeNode<T> *root) { //base case: root has no right child or root is null if (root == nullptr || root->getRightChild() == nullptr) { return root; } return findLargestRec(root->getRightChild()); } virtual TreeNode<T> *findLargestIter(TreeNode<T> *root) { while (root != nullptr || root->getRightChild() != nullptr) {
  • 14. root = root->getRightChild(); } return root; } virtual TreeNode<T> * addItemHelper(TreeNode<T> *root, T item) { //BASE CASE: null root if (root == nullptr) { //allocate new space, store value, then return. root = new TreeNode<T>{}; root->setValue(item); return root; } //RECURSIVE CASE: root is not null if (item >= root->getValue())
  • 15. { //CASE 1: belongs on the right side of root TreeNode<T> *right = addItemHelper( root->getRightChild(), item ); //update right side with reconfigured state root->setRightChild(right); } else { //CASE 2: belongs on the left side of root TreeNode<T> *left = addItemHelper( root->getLeftChild(), item ); root->setLeftChild(left);
  • 16. } return root; } public: virtual void addItem(T value) { _root = addItemHelper(_root, value); } //MA #7 TODO: implement! //Gets the height of the tree. int getHeight() { return 0; }
  • 17. //MA #7 TODO: implement! //Note: You cannot use a "counter variable" to track height. Your function must //calculate the height manually (probably w/ recursion). int getSize() { return 0; } }; #endif // BINARY_SEARCH_TREE_H