49 Topics

Member Avatar for
Member Avatar for Roger_2

I am having trouble implementing a solution using a binary search tree that returns the key of the node based on it's rank in O(N) worst case running time. Every idea i have (listed below) results in O(N^2) or sends me to a dead end. This almost seems impossible. i …

Member Avatar for AssertNull
0
1K
Member Avatar for ali11

*getting following error. duplicate found Exception in thread "main" java.lang.NullPointerException at binarysearchtree.main(binarysearchtree.java:185) Java Result: 1 here is my code* public class node<T> { public node<T> root ; public T data; public node left; public node right; public node (T newData) { data = newData; left = null; right = null; …

Member Avatar for Taywin
0
411
Member Avatar for Pyler

I'm implementing a generi method that's supposed to traverse a binary tree in PostOrder but when I attempt to use it, the Iterator doesn't work as It should when I attempt to use ot on a Binary Tree, can anyone spot my mistake in the code? Thanks. The method makes …

Member Avatar for iamthwee
0
216
Member Avatar for xXFalcoPunchXX

I need help in building a binary tree and putting integers in it. I need to write an add method in my MyArrayBinaryTree class (that extends ArrayBinaryTree) that allows me to place the element to be added in the very next available slot in the array. I also need to …

Member Avatar for JamesCherrill
0
359
Member Avatar for tingwong

Hi everyone I am having trouble finding the nth node of a binary search tree in an inorder traversal. I am getting NullPointerExceptions for any numbers other than 2 and 3 and even those print out the wrong values. If anyone could help it would be greatly appreciated. The method …

0
129
Member Avatar for dreday92

I am having a few compiling errors due to the syntax confusion on some the functions, Im confused to what im doing wrong, I know its a simple solution I've just been looking at this for hours and cant figure it out. //Header File #ifndef BST_H #define BST_H #include <iostream> …

Member Avatar for rubberman
0
252
Member Avatar for next_tech

Hi Guys, I am working on a binary search tree and I've been stuck on some code for the last couple of days. There are 2 issues that I can't seem to figure out how to fix. 1) I have a file that has a list of names and ID's …

Member Avatar for bguild
0
406
Member Avatar for gtkesh

Hello everybody. Here is my remove method for bst. As you all know, there are 3 cases to consider while removing a node from bst. For the last case, when a node (which is to be removed) has 2 children, I want to use predecessor instead of successor to change …

0
119
Member Avatar for deepecstasy

As you know how avl should be balanced after deletion of a node, I'll get to point. For starting, Im considering deleteing a node with no children. For Example a Tree: 10 / \ 5 17 / \ / \ 2 9 12 20 \ \ 3 50 Lets say …

Member Avatar for nitin1
-1
178
Member Avatar for deepecstasy

So Im creating Simple Binary Tree, not BST. Im having problem in deletewith 2 child. Method for deletion is DELETE WITH COPYING. After deleteing, when I traverse the tree, it shows run time error, **Unhandled exception at 0x008B5853 in binarytree.exe: 0xC0000005: Access violation reading location 0xFEEEFEEE.** Here is the function: …

Member Avatar for mrnutty
0
256
Member Avatar for ariel930

Hello again.I recently have been doing a assignment which asks us to write a function to check whether a tree is perfectly balanced.I know the concept of Perfectly balanced tree but I just cant make out how to write this function.Any help in right direction will be highly welcome.

Member Avatar for yde
0
853
Member Avatar for serdar.ilarslan

Hey guys i am in trouble about BST Tree exercise.. i need to create an array that can take number of elements user want and the user has to enter integers but the program need to get this number in one line ... Here is code that i already wrote …

Member Avatar for serdar.ilarslan
0
319
Member Avatar for sobias

Hi, Very fast question guys, since tomorrow is my quiz and I have to sleep now. I stompled upon an old question asking to ** remove the root of the AVL Tree** . I never tried that before, after a very fast search, I found this PDF File https://www.student.cs.uwaterloo.ca/~cs240/s10/handouts/tree-examples.pdf ** …

Member Avatar for Taywin
0
7K
Member Avatar for suhrud.l

For an array of n int variables, When does binary search perform better than ternary search?? Also, reverse case, ie when does ternary search perform better than binary search? Why is binary search a more preferred method of searching for integers entered in an array??

Member Avatar for c1c2c3c4c
0
240
Member Avatar for cody.reddoor

public void inOrderTraversal(TreeNode node) { if(node == null) { return; } inOrderTraversal(node.getLeft()); System.out.print(node.getKey() + " "); inOrderTraversal(node.getRight()); } I wrote this code for going through a binary search tree and printing out the items in order from low to high. it works just fine but i need to get it …

Member Avatar for Taywin
0
279
Member Avatar for starkk

#include<stdio.h> #include<stdlib.h> int input(int *a) { int n,i; printf("enter the no of elements:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter the element:"); scanf("%d",a++); } return n; } int key_input(int *a,int key) { int k; printf("enter the key value which have to be searched in the array of no's provided:"); scanf("%d",&k); return k; } …

Member Avatar for Ancient Dragon
0
189
Member Avatar for ilovejava

This is my code for adding and removing from a binary tree but apparently its not complete can anyone tell me what to do to make it complete tree? [CODE] public void add(IBinaryTreeNode<E> e) { if (getRoot() == null) { setRoot(e); } else { //SAME HERE IBinaryTreeNode<E> node = getLastNode(); …

Member Avatar for ztini
0
248
Member Avatar for infantheartlyje

Hi folks, I did a program to find a number at a lower bound position and upper bound position. For example, this is my array values 1 1 2 3 5 5 5 5 7 8 9 10 if i search lower position for 5 , it will return 4 …

Member Avatar for histrungalot
0
4K
Member Avatar for ahoysailor

Hey, I'm trying to search a List for a substring, but even if it does exist the result is coming out as negative (not present) using the BinarySearch. The idea is that once the file has been loaded into the list I search to see if substrings exist (i.e. IDS_STRING1 …

Member Avatar for ahoysailor
0
203
Member Avatar for jkembo

I am stuck, I know how binary tree works, but I don't have any clue how to add data recursively in a binary tree. The user needs to enter a formula with logical operators. If the user presses to a button e.g NOT(unary operator), then it should display at follow …

Member Avatar for jkembo
0
281
Member Avatar for jaclynkinsey

I am having trouble writing a binary search code to search through my string array. I have the user enter the name of a search engine (engine) they want to locate and my binary search function searches through my string array. Here is my code... [CODE] //****************************************************************************** //This function uses …

Member Avatar for Narue
0
354
Member Avatar for BoBok2002

I am trying to build a binary search tree. The elements in my input file is printing, but with junk. The problem is with the sentinel in the while loop. I'm not sure of what else to try. I've tried: while (infile) while (count != 14 && infile.good()) while (strcmp(Str, …

0
127
Member Avatar for maryam ahmad

i'm working on visual studio 2008. I'm trying use fopen to open txt files and it does not give any errors but its not doing the required task either. i've to submit this project on monday! please help here's part of the code: [CODE]#include <stdio.h> #include<iostream> #include <conio.h> #include <string> …

Member Avatar for maryam ahmad
0
1K
Member Avatar for dolfan55aj

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 …

Member Avatar for mazzica1
0
202
Member Avatar for C++newbie chick

Hello guys, I've tried searching the internet on how to cout a struct in an array via a binary search, but with no success. I've only learned how to do a linear search and I sort of understand how to do a binary search but: how do I cout the …

Member Avatar for C++newbie chick
0
2K
Member Avatar for Anil2447

Here is the codes for Binary Search and Linear Search. [B]Binary Search[/B] [CODE] #include<stdio.h> int main(){ int a[10],i,n,m,c=0,l,u,mid,j,x; //variable assigning printf("Enter the size of an array->"); //Entering the size of the array scanf("%d",&n); printf("\nEnter the elements of the array->");//Entering the array elements for(i=0;i<n;i++){ scanf("%d",&a[i]); } for(i=0;i<n;i++) { //loop to sort …

0
113
Member Avatar for gotjeff5

I am trying to build a binary tree in c++ when I compile I get an error that says: [code] Undefined first referenced symbol in file Btree::destroy_tree(node*) /var/tmp//cc1bssfK.o Btree::remove(int, node*) /var/tmp//cc1bssfK.o Btree::insert(int, node*) /var/tmp//cc1bssfK.o Btree::search(int, node*) /var/tmp//cc1bssfK.o Btree::~Btree() /var/tmp//cc1bssfK.o Btree::Btree() /var/tmp//cc1bssfK.o ld: fatal: Symbol referencing errors. No output written to …

Member Avatar for mike_2000_17
0
99
Member Avatar for ARaza110

Hi, I wanted to understand a java code that i picked from a website RoseIndian.net. It is about Binary Search three implementation in java. Can someone please explain how the retrieval of the node values [node.value] in the method "[B]printInOrder(Node node){}[/B]" being done, because the node.values are not being stored …

Member Avatar for ARaza110
0
203
Member Avatar for poonamjadav

hello, i m a student and working on a mlm project and want to generate a binary tree. please can any one send me the code for it in C#.net please help me.

Member Avatar for ddanbe
0
97
Member Avatar for shimooli

I''ve got a struct like this: struct Node { int n; Node *left; Node *right; } I build up a binary tree from this struct. Now, how can i save the binary tree onto the hard disk, and how can i rebuild it from the hard disk ?

Member Avatar for Narue
0
168

The End.