You are on page 1of 1

Insert 6 between 3&4

reads strings from stdin, inserts them in a set container, and prints them sorted on stdout.

Same as above but vector version


stack alone

stack implemented in vector


Bad derived container

Good derived container

overloaded >> and <<


public:
friend std::istream& operator>>std::istream&,rhs&);
friend std::ostream& o <<(std::ostream&, const rhs&
std::istream& operator>>(std::istream& in, Walker
&walker)
{
int xTemp, yTemp;
in >> xTemp >> yTemp;
walker.setCoordinate(xTemp, yTemp);
return in;
}

try-error
try{
throw invalid_argument( error );
}catch ( invalid_argument &e ){
cout << e.what() << endl;
}

make_heap : rearrange elements in range [first,last) to form a heap


push_heap : given a heap in range [first,last), this changed the last to (last-1)
pop_heap : rearrange elements in the heap range [first,last) in such a way that part considered heap is shortened by one, element
with highest value is moved to (last-1)
sort_heap : sorts into ascending order using operator < for first version compare for second, which shall be same as used to
construct the heap
std::ostream& operator<<(std::ostream& out, const Walker &walker)
{
out << "(" << walker.x_coordinate <<"," << walker.y_coordinate << ")" ;
return out; }

traversing a tree
-preorder : 1) visit current node 2) visit left subtree 3) visit right subtree
-inorder: 1) visit left subtree 2) visit current node 3) visit right subtree
-postorder: 1) visit left subtree 2) visit right subtree 3) visit current node

New Section 1 Page 1

You might also like