LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-02-2013, 04:37 AM   #1
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep: Reputation: 51
self-balanced binary tree: insertion order


Does anyone happen to know off-hand: What is order ("Big-O") of the insertion algorithm on a self-balanced binary tree? I know that the search order is O(log(n)). But I am wondering how badly the insert operation is effected by the balancing operation.
 
Old 11-02-2013, 05:44 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
see ntubski's link below

Last edited by kbp; 11-02-2013 at 04:32 PM. Reason: Failed to read the question.. :(
 
Old 11-02-2013, 09:45 AM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
You probably want to look at the Self-balancing binary search tree article:

Quote:
In the asymptotic ("Big-O") sense, a self-balancing BST structure containing n items allows the lookup, insertion, and removal of an item in O(log n) worst-case time...
 
Old 11-02-2013, 02:04 PM   #4
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
Quote:
Originally Posted by hydraMax View Post
Does anyone happen to know off-hand: What is order ("Big-O") of the insertion algorithm on a self-balanced binary tree? I know that the search order is O(log(n)). But I am wondering how badly the insert operation is effected by the balancing operation.
Since you would have to wander back up to the root node fixing the imbalances as you go, the timing of any insertion or deletion is still O(log n).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the difference strict binary tree nad extended binary tree . tushar_pandey Programming 1 07-18-2012 11:30 AM
binary tree hollyj Programming 9 12-17-2011 03:29 PM
Binary tree in C spank Programming 20 04-25-2006 10:45 AM
Binary search tree insertion in java ksgill Programming 6 02-12-2004 05:11 PM
Printing a binary tree in c? JMC Programming 5 09-26-2003 11:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration