473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

binary tree?

is there any algorithm to create a breadth-first order binary tree?

Nov 13 '05 #1
20 4124
"pc_newbie" <ay@computermail.net> wrote in message
news:3f**********@news.iprimus.com.au...
is there any algorithm to create a breadth-first order binary tree?


Yes. If I wanted one, I'd probably follow
the google-brick road.

-Mike
Nov 13 '05 #2
Mike Wahler wrote:
"pc_newbie" <ay@computermail.net> wrote in message
news:3f**********@news.iprimus.com.au...
is there any algorithm to create a breadth-first order binary tree?

Yes. If I wanted one, I'd probably follow
the google-brick road.

-Mike

where can i find it?

Nov 13 '05 #3
pc_newbie wrote:
Mike Wahler wrote:
"pc_newbie" <ay@computermail.net> wrote in message
news:3f**********@news.iprimus.com.au...
is there any algorithm to create a breadth-first order binary tree?


Yes. If I wanted one, I'd probably follow
the google-brick road.

-Mike

where can i find it?


Bookmark this link:

http://www.google.com

--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c

Nov 13 '05 #4
In 'comp.lang.c', pc_newbie <ay@computermail.net> wrote:
is there any algorithm to create a breadth-first order binary tree?


Since when is an algorithm question a C-question?

--
-ed- em**********@noos.fr [remove YOURBRA before answering me]
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
<blank line>
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 13 '05 #5
Morris Dovey wrote:
pc_newbie wrote:
Mike Wahler wrote:
"pc_newbie" <ay@computermail.net> wrote in message
news:3f**********@news.iprimus.com.au...

is there any algorithm to create a breadth-first order binary tree?


Yes. If I wanted one, I'd probably follow
the google-brick road.

-Mike

where can i find it?

Bookmark this link:

http://www.google.com

can't find any information about it yet

Nov 13 '05 #6
pc_newbie writes:
Morris Dovey wrote:
pc_newbie wrote:
Mike Wahler wrote:

"pc_newbie" <ay@computermail.net> wrote in message
news:3f**********@news.iprimus.com.au...

> is there any algorithm to create a breadth-first order binary tree?


Yes. If I wanted one, I'd probably follow
the google-brick road.

-Mike
where can i find it?

Bookmark this link:

http://www.google.com

can't find any information about it yet


Very few people that say "use google" have actually tried their advice in
the case at hand. It is just an adult's answer to "why is the sky blue,
daddy?". Look it up, kid. I can't be bothered. If there *is* an answer
it's probably on google, it doesn't follow that the answer can be found with
a reasonable expenditure of effort. Or that the questioner knows the right
buzz words to actually find the answer. You need a tool kit of jargon and
catchy phrases and a certain amount of experience to google successfully.

This may help.

http://www.wikipedia.org/wiki/Breadth_first_recursion

Post any follow ups to comp.programming, this is the wrong newsgroup for
your question.
Nov 13 '05 #7
pc_newbie wrote:
Morris Dovey wrote:
pc_newbie wrote:
Mike Wahler wrote:

"pc_newbie" <ay@computermail.net> wrote in message
news:3f**********@news.iprimus.com.au...

> is there any algorithm to create a breadth-first order binary tree?

Yes. If I wanted one, I'd probably follow
the google-brick road.

-Mike

where can i find it?


Bookmark this link:

http://www.google.com

can't find any information about it yet


My apologies. I should have provided more info.

[1] Go to http://www.google.com
[2] Run a search on "binary tree"
[3] Click on link "Search within these results"
[4] Run subsearch on "breadth-first"
[5] Puzzle out a new subsearch because 12300 results seem like
too much to read. 8-)

--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c

Nov 13 '05 #8
Morris Dovey writes:
[5] Puzzle out a new subsearch because 12300 results seem like
too much to read. 8-)


Yes, that's the rub, what *is* the next step? Remember that the OP has used
up *all* his knowledge at this point. I have no desire to pursue this
particular example, this may yield a useful result at this point, it may
not. But I have been there many times in the past with similar problems
and the next step is far from clear. I know of no way of eliminating course
outlines, vu-graphs, and syllabuses from the list of hits. The cases where
I actually did this for myself were full of useless dreck. The best answer
is filtered through a human mind. Perhaps if he reposts as I suggested he
will still get a meaningful answer before the sun bloats up and kills us
all.
Nov 13 '05 #9
pc_newbie wrote:
Mike Wahler wrote:
Yes. If I wanted one, I'd probably follow
the google-brick road.
where can i find it?


www.google.com
--
Martin Ambuhl

Nov 13 '05 #10
"osmium" <r1********@comcast.net> wrote in message
news:bk************@ID-179017.news.uni-berlin.de...

Post any follow ups to comp.programming, this is the wrong newsgroup for
your question.


Exactly. My reply was a (apparently too subtle)
indication of this.

-Mike
Nov 13 '05 #11
On Sun, 21 Sep 2003 13:13:34 -0700, in comp.lang.c , "osmium"
<r1********@comcast.net> wrote:
Morris Dovey writes:
[5] Puzzle out a new subsearch because 12300 results seem like
too much to read. 8-)
Yes, that's the rub, what *is* the next step?


a) random selection
b) start from the top.

Either seems reasonable.
Remember that the OP has used up *all* his knowledge at this point.


Then (and no offense to the OP) further use of the internet seems
highly unlikely to be useful. For is it not said "go not to the elves
for counsel, and also the internet, innit?" . Using the net for basic
understanding requires a high level of well, understanding, first....

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
Nov 13 '05 #12
On Sun, 21 Sep 2003 10:23:53 -0700, in comp.lang.c , "osmium"
<r1********@comcast.net> wrote:

Very few people that say "use google" have actually tried their advice in
the case at hand.


I can. I almost always find the answer, be it "is suchandsuch a make
of children's building bricks compatible with lego" or "whats
ankylosing spondylitis and can you recover from it". (answers are yes
and no, in either order).

What is required is a bit of common sense, and some understanding of
googling. To get the latter, learn. To get the former..

FWIW My own search turned up seve ral relevant references in page 1,
including some code samples.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
Nov 13 '05 #13
Mark McIntyre writes:
Remember that the OP has used up *all* his knowledge at this point.


Then (and no offense to the OP) further use of the internet seems
highly unlikely to be useful.


Not at all. There are a great many things I can do if someone will open the
book up at the right page for me. But I will be damned if I know how to
*find* that page. I have no reason to believe I am unusual in that respect.
Nov 13 '05 #14
osmium wrote:
Morris Dovey writes:
[5] Puzzle out a new subsearch because 12300 results seem
like too much to read. 8-)
Yes, that's the rub, what *is* the next step?


<much snipped>
The best answer is filtered through a human mind.


Exactly so. My own next step was to do a subsearch on "C source"
(quoted) which reduced the number of entries substantially; but
reflected my own interests, rather than the OP's stated interest
(algorithms).

My rationale was that at least a subset of available algorithms
can be extracted from source codes; and that at least a rough
estimate of quality can be made by skimming each reference's C code.

[Somebody's Law: "Ninety percent of everything is crud."]

On the other hand, if the OP was looking for some in-depth
discussion (prose) dealing with "breadth-first order binary
trees" my approach would probably not be terribly productive.
--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c

Nov 13 '05 #15
Morris Dovey <mr*****@iedu.com> writes:
[...]
[Somebody's Law: "Ninety percent of everything is crud."]


Sturgeon's. (That's Theodore Sturgeon, the late science fiction
author.)

--
Keith Thompson (The_Other_Keith) ks*@cts.com <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 13 '05 #16
pc_newbie wrote:
is there any algorithm to create a breadth-first order binary tree?

thanks a lot all guys

Nov 13 '05 #17
pc_newbie wrote:
is there any algorithm to create a breadth-first order binary tree?

you all guys are misunderstanding what i asked, what i want is how to
create a breadth-first order binary, not to travel a binary tree with
breadth first order. but thanks a lot anyway, i should find the way by
myself.
that's what i want
1
2 3
4 5 6 7

normal binary is
4
3 5
1 2 6 7

Nov 13 '05 #18
"pc_newbie" <ay@computermail.net> wrote:
that's what i want
1
2 3
4 5 6 7

normal binary is
4
3 5
1 2 6 7


#include <stdio.h>
#include <stdlib.h>

struct tree {
int value;
struct tree *left;
struct tree *right;
};

struct tree *create(int start, int max)
{
struct tree *new = NULL;

/* If this node should exist: */
if(start < max)
{
/* First, create it: */
new = malloc(sizeof *new);
if(!new)
{
fprintf(stderr, "Error allocating memory\n");
exit(EXIT_FAILURE);
}
new->value = start;

/* Then create its children: */
new->left = create(start * 2, max);
new->right = create(start * 2 + 1, max);
}
return new;
}

Call it with create(1, 8) for your example tree.

C:\prog\c>gcc -std=c99 -pedantic -Wall -W -O2 bftree.c -o bftree

C:\prog\c>bftree 32
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

My tree pretty-printing routine is quite interesting.

--
Simon.
Nov 13 '05 #19
pc_newbie wrote:
pc_newbie wrote:
is there any algorithm to create a breadth-first order binary
tree?

you all guys are misunderstanding what i asked, what i want is
how to create a breadth-first order binary, not to travel a
binary tree with breadth first order. but thanks a lot anyway,
i should find the way by myself.

that's what i want
1
2 3
4 5 6 7

normal binary is
4
3 5
1 2 6 7


Now you have actually described your problem, assuming the digits
above are indexes of entry order and not keys. I have no idea
what you consider "normal binary".

BTW, your postings would be much more understandable if you used
upper case letters where appropriate, such as the start of
sentences or the pronoun I.

As others have pointed out, this is OT for c.l.c, but quite
topical for comp.programming. I have cross-posted this and set
follow-ups, so any further discussion should be there.

--
Replies should be to the newsgroup
Chuck Falconer, on vacation.
Nov 13 '05 #20
Simon Biber wrote:
"pc_newbie" <ay@computermail.net> wrote:
that's what i want
1
2 3
4 5 6 7

normal binary is
4
3 5
1 2 6 7

#include <stdio.h>
#include <stdlib.h>

struct tree {
int value;
struct tree *left;
struct tree *right;
};

struct tree *create(int start, int max)
{
struct tree *new = NULL;

/* If this node should exist: */
if(start < max)
{
/* First, create it: */
new = malloc(sizeof *new);
if(!new)
{
fprintf(stderr, "Error allocating memory\n");
exit(EXIT_FAILURE);
}
new->value = start;

/* Then create its children: */
new->left = create(start * 2, max);
new->right = create(start * 2 + 1, max);
}
return new;
}

Call it with create(1, 8) for your example tree.

C:\prog\c>gcc -std=c99 -pedantic -Wall -W -O2 bftree.c -o bftree

C:\prog\c>bftree 32
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

My tree pretty-printing routine is quite interesting.

Thank you very much :) it works very well

Nov 13 '05 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jerry Khoo | last post by:
hello, everybody, i am kinda new here, nice to meet u all. Now, i am > cs students and are now facing difficult problems in understanding > what a binary tree is, how it works, and the algorithm...
8
by: Jerry Khoo | last post by:
hello, everybody, i am kinda new here, nice to meet u all. Now, i am cs students and are now facing difficult problems in understanding what a binary tree is, how it works, and the algorithm to...
11
by: jova | last post by:
Is there a difference between a Binary Tree and a Binary Search Tree? If so can someone please explain. Thank You.
4
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working,...
5
by: pembed2003 | last post by:
Hi, I have a question about how to walk a binary tree. Suppose that I have this binary tree: 8 / \ 5 16 / \ / \ 3 7 9 22 / \ / \ / \
15
by: Foodbank | last post by:
Hi all, I'm trying to do a binary search and collect some stats from a text file in order to compare the processing times of this program (binary searching) versus an old program using linked...
4
by: Ken | last post by:
I have a binary tree in VB NET and insertions seem to be slow. The program receives data from one source and inserts it into the tree. The program receives data from another source and...
3
by: piotrek | last post by:
Hi I would like to ask you a question. Ian creating app. that download from server directory structure ( whole tree ) and those data are placed in proper places into my treeview control. I...
1
by: hn.ft.pris | last post by:
I have the following code: Tree.h defines a simple binary search tree node structure ########## FILE Tree.h ################ #ifndef TREE_H #define TREE_H //using namespace std; template...
7
by: Vinodh | last post by:
Started reading about Binary Trees and got the following questions in mind. Please help. Definition of a Binary Tree from "Data Structures using C and C++ by Tanenbaum" goes like this, "A...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.