I have a Graph that I'm making using an adjacency matrix to hold edge values. The noEdge value is zero and all edgeweights are positive integers. I have to delete a node from this graph and I'm having trouble figuring out how to update the Adjacency matrix after the deletion of the label from my labels vector. I know I have to shift the values but I can't quite figure out in code/algorithm format.

Any idea on a good way to implement this in code/an algorithm?

Thanks

I'm working in the confines of a binary search tree and an AVL tree, doing some operations to find different statistics for these trees when given large random values. For instance some of my functions include finding the average leaf node depth, find the shallowest leaf node, etc.

My question is what is the best way to go through these trees and calculate such values, noting which level things are found, etc. I was considering a level order traversal but I'm not sure the implementation.

Any hints or advice will help, Thanks!

Edit: Any tips about keeping a height variable with that would be helpful too.

We have to do a level order traversal of a max-heap and I'm having some trouble. Of course a regular level order traversal in a heap is easy as can be (it's an array of course) but now I have to print it in a sort of tree structure. For example if I have a heap with the following values [9, 5, 6, 4, 3, 2] I have to print it as follows:

9
5 6
4 3 2

Right now here's my code for a simple level order:
[ICODE]template<class ItemType>
void BinaryHeap<ItemType>::PrintLevel(ostream &out)
{
out << endl;
for(int i=1; i <= currentSize; i++)
{
out << BHeap[i] << " ";
}
}[/ICODE]

Anybody have any ideas or tips on how to do this? I just can't seem to figure out the logic on when I'm going to need to do and endl;... Let me know if you can, Thanks!

I'm trying to do an analysis of buildHeap vs. inserting an array of n values one at a time into a heap. I have a random case, best, and worst case. I was wondering if anyone knows what would actually be in an array to make the best and worst of a min heap?

For example, with n values, what would be in my array to give the slowest possible time to both buildheap and the insert function when creating a heap?

I understand the analysis but I just can't figure out what would give that worst case scenario.

Thanks in advance.

I'm a new member and this is my first post, so be gentle ;)

It's been a while since I've gotten a chance to practice with recursion so to say I'm a bit rusty is an understatement. Not to mention I've never implemented it with a linked list. My current problem is transforming an iterative INSERT function for a linked list into a recursive function without changing the driver.

The following is my iterative function.
[CODE] NodeType<ItemType> nodePTR, traverse;

traverse = head;
if(head == NULL)
{
    head = new NodeType<ItemType>(item);
    length++;
    return true;
}
else
{
    while(traverse != NULL)
    {
        if(traverse->info == item)
        {
            return false;
        }
        traverse = traverse->next;
    }
    nodePTR = new NodeType<ItemType>(item);
    nodePTR->next = head;
    head = nodePTR;
    length++;
      }
      return true;
}[/CODE]

I'm mostly confused about the actual traversal of the list and simple insertion before I worry about the check. Any help is greatly appreciated, I'm sure it's partially a problem with my own mental logic. I'm unfortunately operating on a somewhat basic level.

If any other threads could be referenced that help with general linked list-recursion techniques that too would be appreciated (I did not see any that helped me much).