xAbhishek

Archive for 'College'

August 6, 2008

Hierarchy and Ego

For the first time in college today, I lost control of myself. Here is Group A of students(including me) trying to organise a welcoming party for the freshers(students joining this year) with the planning process going on for half a month. Group A had a couple of students(not including me) confident of being elected to [...]

May 4, 2008

Samir’s new HP Pavilion

Samir came home today with his new notebook which has the same shape and size as the MacBook Pro but is slightly lighter. It was some limited edition copper-red design that’s was available this month in the HP stores. 250GB HDD, 3GB RAM, 1.83 C2D and NVIDIA 8400GS with Home Premium.
Samir didn’t listen to my [...]

April 25, 2008

Data Structures

Have my Data Structures paper tomorrow today. Am slightly terrified. Not because I don’t know anything. Actually I know a lot more than I expected. I’m terrified because a lot of code we’ve done this semester is redundant as I have realized in the past two days and I don’t know whether I should write [...]

April 23, 2008

Breadth-First Binary Tree Traversal

This explanation is excellent.
So is this code:
void breadthFirst()
{
 Queue q;
 tree_node *p=root;
 if(p!=0)
 {
  q.push(p);
  while(!q.empty())
  {
  p= q.pop();
  cout<<p->info<<” “;
  if(p->left!=0)
  q.push(p->left);
  if(p->right!=0)
  q.right(p->right);
  }
 }
}

Mirror of a Binary Tree

Creating a mirror of a Binary Tree(or Binary Search Tree)

void BinaryTree::mirror(tree_node* node) { 
  if (node==NULL) {
    return;
  }
  else {
    tree_node* temp;
    // do the subtrees
    mirror(node->left);
    mirror(node->right);

    // swap the pointers in this node
    temp = node->left;
    node->left = node->right;
    node->right = temp;
  } [...]

« The Recent Past