Hi I am a beginner in game programming and would like to make a rocketmania clone using opengl, the display and interaction part is done. I also have a classes named gameboard and tiles with their properties. but I am having problems on game logic, where the fuel flows into a pipe opening, then fuel spreads to adjacent pipes with opening. can anyone tell me what traversal algorithm should I use? any help or clues would be appreciated.

Member Avatar
Member Avatar
+0 forum 9

Hi.here is a question I got for assignment.I am stuck in this for hours and couldnt com up with any logic.Any help will be highly appreciated.Thanks Depth-First-Search Q.No.1 The undirected unweighted graph with one selected vertex is given. Find the number of vertices in the connected component where the selected vertex belong (including the selected one). Specifications Input The first line contains two integers n and s (1 ≤ s ≤ n ≤ 100), where n - the number of vertices of the graph, and s - chosen vertex. The following n lines contains n numbers - the adjacency matrix …

Member Avatar
Member Avatar
+0 forum 3

Hello All, So I'm working on hand-coding a forum-like website, just for the experience, and I want to have a similar feature as you'll see above where a thread will have its ancestors linked: "Web Development > JSP > Parent traversal of tree-like Structure" I have several beans for different things, post, thread, category, forum and so on, all have a name property and all (will shortly, still adding) have a parent property. I know I could do this all in Java code inside a tag handler that would just print the whole thing, but I'd rather do it in …

Member Avatar
Member Avatar
+0 forum 2

I am doing huffman coding and I have made the tree. Now I am required to traverse the tree to create bit strings associated with the characters. Then I will put the bit string and char into a map to use with encode/decode. I have been working on this for days and could really use some help. Thanks for any help you can offer! map<char, string> build_encoding_map(freq_info*& huffman_root) { map<char, string> ret; string char_code; char symbol; if (huffman_root->left == NULL && huffman_root->right == NULL) { cout << "Your tree is empty." << endl; } else { while (huffman_root->is_leaf = false) …

Member Avatar
Member Avatar
+0 forum 1

I'm writing maze traversal for a school assignment, and I've got an issue. The X will move through most of the maze, but then it will get stuck at a position and keep cycling through. This is probably because I'm not checking properly to see if it hasn't been to a spot already. Here's my code: /* Name: Ryan Frappier Date: Program: Recursively moves an X through a maze Signature:____________________ */ #include "stdafx.h" #include <iostream> using namespace std; void printArray(char*[12], int); void mazeTraverse(char*[12], int, int, int, int); int _tmain(int argc, _TCHAR* argv[]) { // array of pointers char *maze[12]; // …

Member Avatar
Member Avatar
+0 forum 3

Can anybody share the algorythm to perform inorder traversal of a binary search tree using parent node(without stack or recursion)

Member Avatar
Member Avatar
+0 forum 4

Hi! I made a program that accepts random numbers, create a binary tree from it, then traverse it using in-order, pre-order and post-order traversal. The program is working well but my instructor added something else, when the user input numbers, it should be arranged just like an actual tree. The output should be like this: Enter number of nodes: 5 What are the nodes? 12 22 18 5 3 [press enter] 12 5 22 3 18 Choices are: [A] In Order traversal [B] Pre Order traversal [C] Post Order traversal [D] Exit Enter your choice: B 12 , 5, 3, …

Member Avatar
Member Avatar
+0 forum 2

Hello, everybody! I've been struggling on implementing the Binary Tree data structure with some standard functions in it. After reading information from many sources and some work on my own, I've came up to this: [url]http://pastebin.com/B6Gtjb61[/url] Problems occur in the main funciton. What I can't understand is why does the postorder traversal just reverses the input values? Why size, height and depth are equal since when I sketch the tree on a sheet, it's much more different? I think I make some great mistakes in the insertion of the elements and the whole idea about the root node ... but …

Member Avatar
Member Avatar
+0 forum 2

This snippet defines a function walk() which generically performs a depth-first traversal of a tree, using preorder, inorder or postorder rules. Here, genericity means here that there are no hypotheses on what the tree nodes are or the implementation of the tree. Walk() only needs an arbitrary object used as a root node and a function generating children 'nodes' for a given 'node'. At any moment during the walk, it exposes the path from the root node to the visited node. Finally, the implementation is fully non recursive, allowing very deep trees to be traversed. IMPORTANT: this snippet needs class …

Member Avatar
Member Avatar
+2 forum 2

[CODE]void inorder(struct node *r) { if(r!=NULL) { inorder(r->left); printf("\t %d",r->data); inorder(r->right); } }[/CODE] in the above code when the last element is reached i.e r->left becomes null then when inorder(r->left) is called it will send a null value to the function and if condition becomes false so the it'll come out of the function. But the problem is that instead of coming out of the loop it executes the printf("\t %d",r->data); statement when it comes to the last element. Please explain me(if you don't understand the question plz read it twice i need your help) Thanks

Member Avatar
Member Avatar
+1 forum 6

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) { …

Member Avatar
Member Avatar
+0 forum 1

I'm having trouble formatting a binary tree. In my program, the tree format should print every output as such: 35 30 29 25 24 20 15 This is the code that I have thus far. [CODE]public void treeFormatTraversal(){//begin int level = 0; if(root !=null) treeFormatHelper(root, level); else System.out.println("\nTree is Empty\n"); } private void treeFormatHelper(TreeNode<T> tree, Integer indentSpaces){ if(tree==null) return; treeFormatHelper(tree.rightNode,indentSpaces+1); for(int x=1;x<indentSpaces;x++) System.out.print("\t"); System.out.printf("%s",tree.data); treeFormatHelper(tree.leftNode,indentSpaces+1); } [/CODE] Any help is appreciated on how to implement the display format. Thanks

Member Avatar
Member Avatar
+0 forum 1

I am currently attempting to write a single [B]recursive[/B] method (per instruction) whereas the items in a binary tree are displayed in a horizontal hierarchical manner (level order traversal). The UML describes the method as: levelOrderTraversal(TreeNode<T> tree, Integer indent) - tree: a node in the binary tree - indent: describes the indentation required for the node The following is a example of the output that should be produced when levelOrderTraversal is called: [CODE] 199 77 64 62 60 40 38 22 11[/CODE] As mentioned, the instructions require that the method strictly use recursion (and thus implicitly am not allowed to …

Member Avatar
Member Avatar
+0 forum 3

hi, i'm currently learning C on my own. i explicitly made a binary tree just to see if my postorder procedure works. i have no idea why but at the end of running the program, before it does the last procedure, this appears: [IMG]http://i56.tinypic.com/2nb52xx.jpg[/IMG] everything else works fine. i know it must be the [B]postorder[/B] which has the problem but i have no idea why. please help me. below is my code: [CODE]#include <stdio.h> #include<stdlib.h> #include<conio.h> struct node { struct node *LeftNode; char data; struct node *RightNode; }; node *makeNode(char c); void visit(struct node *N); void postorder (struct node *N); …

Member Avatar
Member Avatar
+0 forum 5

Hello, I'm getting quite flustered with this program and the errors are starting to get harder to debug. This is my tree.java file: [CODE]package TreePkg; import java.io.FileNotFoundException; import java.lang.SecurityException; import java.util.Scanner; import java.util.NoSuchElementException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.Serializable; import java.io.EOFException; class TreeNode<T extends Comparable <T>> { T data; TreeNode<T> leftNode; TreeNode<T> rightNode; public TreeNode (T item){ data = item; leftNode=rightNode=null; } } public class Tree <T extends Comparable <T> & Serializable> { private TreeNode<T> root; Scanner input = new Scanner(System.in); public void Tree (){ root=null; } public void insertItem (T item){ if( root == null …

Member Avatar
Member Avatar
+0 forum 1

Hello, I'm doing a full traversal of a binary search tree structure looking for a node by a field that is not the sort key. If the node i'm looking for is the root node, no problem. If it's any other node then the function has a Seg Fault. Anyone know what is going on? I'm pretty sure the problem is in my logic in what i'm returning from Find_Trav_Subtree, but cannot pinpoint it. gdb debugger gives me this, but i'm not sure if it helps. Breakpoint 1, BSTClass::Print_Node (this=0x80537a4, NodePtr=0xb7f1e888) at bstree.cpp:227 227 { (gdb) next 228 cout << …

Member Avatar
Member Avatar
+0 forum 3

The End.