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 |
+0 forum
1 | ||

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 … |
+0 forum
1 | ||

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; … |
+0 forum
1 | ||

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 … |
+0 forum
1 | ||

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) { … |
+0 forum
1 |

The End.