Sponsored Content
Top Forums Programming Binary search tree questions. Please help =) Post 302879215 by Jill Ceke on Wednesday 11th of December 2013 10:11:39 AM
Old 12-11-2013
Binary search tree questions. Please help =)

I have some questions about certain placement of child nodes since I'm just learning BSTs and it's quite confusing even after reading some sources and doing some online insertion applets. Let's say I want to add nodes 5,7,3,4 to an empty basic BST.

Image


Ok I understand that the left child must be less than the parent AND less than or equal to the right child from that same parent. I follow it until we add the 4 node. How do we determine that the insertion of 4 goes to the bottom right leaf position of 3 instead of the bottom left leaf position? Also, doing a AVL insertion of nodes 5,18,3,7,11 yielded some surprising position placements. Inserting the fourth node, 7, went down through 18 instead of 3. Is there a particular reason why? Assuming that is the correct way, inserting 11 would switch the 11 and 18 spots, but wouldn't having 18 as the parent node, 7 as left child, and 11 as right child adhere to the principle of left child smaller than parent and smaller or equal to right child? I'm confused! I would appreciate any help. Thank you!

insert 7

Image

insert 11

Image
 

10 More Discussions You Might Find Interesting

1. Programming

Directory tree search???

Hi all, I've got a problem, what function do i use to list the contents of all the directory tree (simular to "find")? Any other suggestions? Thank you all (3 Replies)
Discussion started by: solvman
3 Replies

2. Shell Programming and Scripting

Creating breadth traversal binary tree

I almost have the entire script written. however the problem is how would i assign the global variable to terminate the process from the bottom up to ensure the child terminates so the parent can. ex. I am proccess 1 I am proccess 2 etc Here is the code $ cat tree.c ... (3 Replies)
Discussion started by: slurpeyatari
3 Replies

3. Shell Programming and Scripting

Create a binary tree

I need to create a binary tree like structure of directories using shell script... does anyone know of any algorithm for this ? i tried doing a recursive algorithm function CreateDir { level=$1 dirname=$2 mkdir $dirname/sub1/ mkdir $dirname/sub2/ let level=level-1 ... (2 Replies)
Discussion started by: macvijay1985
2 Replies

4. UNIX for Dummies Questions & Answers

Binary Tree Creation Using fork()

Hi, I am working on a program and kind of a stuck,nt getting it done. "The program should take one command line arguments: number of hierarchy level. The hierarchy of your program should of that level and each node have two child processes." Can anyone give me the C code using fork() of this... (1 Reply)
Discussion started by: learneros
1 Replies

5. Shell Programming and Scripting

How to search for string and return binary result?

Hi, I have a problem that I am sure someone will know the answer to. Currently I have a script which returns a binary output if it finds a certain search string (in this case relating to a DRBD cluster) as follows: searchstring="cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate" && echo... (3 Replies)
Discussion started by: almightybunghol
3 Replies

6. Programming

Binary Tree

I have just been researching this topic and I was wondering what type of application might a binary tree be used for. For instance what type of application would be a good showcase for a binary tree that I could write as an example? (5 Replies)
Discussion started by: sepoto
5 Replies

7. Programming

Binary Search Tree Search problem

I am writing code for a binary search tree search and when I compile it i am getting strange errors such as, " /tmp/ccJ4X8Xu.o: In function `btree::btree()': project1.cpp:(.text+0x0): multiple definition of `btree::btree()' " What does that mean exactly? tree.h #ifndef TREE_H #define... (1 Reply)
Discussion started by: meredith1990
1 Replies

8. UNIX for Dummies Questions & Answers

To do directory tree search

Hello Everyone, I need to find the file / directory with the maximum timestamp in a directory tree having many files / directories. Could you please help. Thanks, H squared (3 Replies)
Discussion started by: H squared
3 Replies

9. UNIX for Dummies Questions & Answers

Binary search and replace

Hello again. I have two problems - is it possible to solve them? 1. I want to replace a few bytes after specific hex-string. i.e.: I want to replace two bytes after AA AB AC: AA AB AC 00 00 AA AA AA so the expected result should be: AA AB AC FF FF AA AA AA 2. I want to replace three bytes... (9 Replies)
Discussion started by: useretail
9 Replies

10. Web Development

Problem in printing binary tree using php and mysql

Database Structure Root Table ID Root_ Node Level 1 A 0 2 B 1 3 C 1 Child Table ID Left_Node Right_Node Root_Node Root_ID 1 B C A 1 ... (1 Reply)
Discussion started by: Deepak Tiwari
1 Replies
DPKG-PRECONFIGURE(8)						      Debconf						      DPKG-PRECONFIGURE(8)

NAME
dpkg-preconfigure - let packages ask questions prior to their installation SYNOPSIS
dpkg-preconfigure [options] package.deb dpkg-preconfigure --apt DESCRIPTION
dpkg-preconfigure lets packages ask questions before they are installed. It operates on a set of debian packages, and all packages that use debconf will have their config script run so they can examine the system and ask questions. OPTIONS
-ftype, --frontend=type Select the frontend to use. -pvalue, --priority=value Set the lowest priority of questions you are interested in. Any questions with a priority below the selected priority will be ignored and their default answers will be used. --terse Enables terse output mode. This affects only some frontends. --apt Run in apt mode. It will expect to read a set of package filenames from stdin, rather than getting them as parameters. Typically this is used to make apt run dpkg-preconfigure on all packages before they are installed. To do this, add something like this to /etc/apt/apt.conf: // Pre-configure all packages before // they are installed. DPkg::Pre-Install-Pkgs { "dpkg-preconfigure --apt --priority=low"; }; -h, --help Display usage help. SEE ALSO
debconf(7) AUTHOR
Joey Hess <joeyh@debian.org> 2018-02-28 DPKG-PRECONFIGURE(8)
All times are GMT -4. The time now is 11:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy