BST atau Binary Search Tree adalah sebuah algoritmaFull description
Full description
Tutorial on binary search from TopcoderFull description
C program for Binary Search Tree TraversalFull description
C program for Binary Search TreeFull description
Full description
Full description
phineas newborn transcriptionFull description
disney pdf piano
Drums
starategi dalam trading binaryFull description
Make money using binary optionsDescripción completa
Binary LiquidFull description
Make money using binary options
wetgwsagsdfFull description
reflectionDescrição completa
Mulan Reflection, piano part
DisneyDescripción completa
Ma. Nikkie Evalla
Mr. Ezra Anglo
BSIT2-6
Data Structure
Reflection Paper on Data structures: Binary Search Tree
In the the foll follow owin ingg ae aerr I will will !i"c !i"cu" u""" what what I have have lear learne ne!! fro# fro# watc watchi hing ng an info infor# r#at ativ ivee vi!e vi!eoo $% mycodeschool entitle! entitle! Data structures: Binary Search Tree. Tree . The uro"e of thi" reflection aer an! of the "ource vi!eo a" to how I "ee" it i" to e&lain the Binar% Search Tree. I !eci!e! to inclu!e a co#ari"on of an arra%' linke! li"t an! $inar% "earch tree running ti#e for certain oeration" which i" of cour"e I al"o learnt fro# the "ai! vi!eo to further e&lain the toic. A" "tate! fro# our "ource' Binar% "earch tree i" a special kind of binary tree that organizes data for quick search and update. update. Thi" i" (u"t an intro!uction intro!uction #uch like giving #eaning to our #ain toic. Thi" Thi" i" followe! followe! $% the overview of two well-known !ata "tructure u"e! for "toring #o!ifia$le collection na#el%) an arra% an! linke! li"t. *"e an arra% or linke! li"t a" a #o!ifia$le collection to $e a$le to "earch' in"ert an! re#ove an ele#ent Before an%thing el"e the "ource ha! a co#ari"on a#ong"t the two well-known !ata "tructure together with the $inar% "earch tree. +e will co#ute the running ti#e for the"e oeration") "earching' in"erting' an! re#oval of recor!" of the two. Starting off with the arra%' how integer" will $e "tore! in it i" "hown. Thi" i" !one $% creating a large enough arra% to "tore the recor!" marking the end of the list to to !eter#ine if an in!e& "till contain" a recor! an! "o a" to "a% that tho"e after the #ark are availa$le "ace or e#t% in!e&e". ,or e&a#le' if we have in!e& #arke! a" the en! then that #ean" we have / recor!" 0of cour"e 1 i" inclu!e!. To "earch let "a% varia$le 3 x x 4 in the recor!" we have to "can the arra% fro# in!e& 1 u to the #arke! en!' if what we are "earching for unfortunatel% i" in the en! a" to what I un!er"too! fro# the vi!eo i" that we nee! to look through all the ele#ent" in the arra%. So let 3 n4 $e the nu#$er of ele#ent" we have in our arra% therefore the running ti#e of an arra% for the oeration of "earching will $e roortional to the nu#$er of ele#ent" 3n 3 n4 in it. The larger the arra% the higher the ti#e it will con"u#e to "earch for a given x given x . The "ource !enote! thi" a" Search(ŋ)= o(ŋ) 5ur reviou"l% reviou"l% !one #arker en! will $e ver% vital in the roce"" of in"erting in"erting a new recor! to the arra%) a" "tate! a$ove tho"e in!e& that follow" the #aker en! are all availa$le "ace. Thi" i" where we will $e a!!ing the new recor!' thi" i" !one $% incre#enting the #arker en!. After incre#enting we can now a!! the new recor! which i" an integer in the ca"e "hown in the "ource vi!eo. ,or thi" oeration 0which i" in"erting ti#e taken will not !een! on the nu#$er of ele#ent" in"tea! it i" con"tant. It can $e !enote! a" Insert(ŋ)= Insert(ŋ)= o(1)
The ne&t oeration !eleting i" uite a crucial one. Sa% for e&a#le we want to re#ove the recor! in in!e& 7' in or!er to !o that we4ll have to "hift all recor!" to the right of in!e& 7 one in!e& to the left. 8a"tl% we will !ecre#ent our #arker en! thu" re"ulting to a running oeration of Remove(ŋ)= o(ŋ). Moving forwar! to linke! li"t thi" !ata "tructure runs almost the same as an array therefore the running ti#e of the oeration "earch i" al"o Search(ŋ)= o(ŋ) $ut in thi" ca"e we are ertaining to nu#$er of no!e" in the linke! li"t. In or!er to "earch we will have to traver"e all the recor!" of the whole li"t "a#e a" to an arra% we #a% nee! to look through all the no!e" in the linke! li"t. +hile the co"t of in"ertion in a linke! li"t ha" two roce"" either Insertion(ŋ)= o(1) if it4" at the hea! or Insertion(ŋ)= o(ŋ) at the tail. It i" a!vi"e! to in"ert at the hea! to kee the running co"t low an! con"tant. In the roce"" of re#oval we #a% have to traver"e the linke! li"t an! "earch the recor! checking at all the no!e" Remove(ŋ)= o(ŋ). +e #a% think of the"e two a" a "uita$le !ata "tructure for "earching' in"erting an! re#oving. Even #e I woul! think of u"ing it $ut after watching the fir"t 9 #inute" of the "ource vi!eo I !ou$t if %ou "till have %our initial oinion regar!ing thi". It ha" $een clearl% "tate! that in realit% any of the two is not a practical method to use although in"ertion $etween the# i" fa"t. 5ne oint that we #a% not have notice! i" that the"e #a% con"u#e a relativel% large a#ount of ti#e if we have large collection of recor!". :ow a$out a recor! for a $aranga% with 111 fa#ilie" #o"t of the# con"i"ting of 7 #e#$er" gaining a total of 7111 in!ivi!ual recor!"; If we will go for an e"ti#ate! "econ! er "earch then we will en! u con"u#ing 7111 "econ!" "earching for that certain x .
three oeration" in lowe"t value o""i$le that i" o(logŋ) for average ca"e" an! will hit a" low a" o(ŋ) for it" wor"t ca"e". 5f cour"e we can a" #uch a" o""i$le avoi! wor"t ca"e "cenario" $% #aking "ure that the tree i" alwa%" $alance!. Moving on let4" tackle fir"t how co"t of $inar% "earch tree oeration" are #ini#ize!. B% !efinition' $inar% "earch tree i" a $inar% tree in which for each no!e' value of all the no!e" in left "u$ tree i" le""er or eual 0to han!le !ulicate" an! value of all the no!e" in right "u$ tree i" greater. In $inar% tree each no!e can have at #o"t two chil!ren. The "ource vi!eo illu"trate! $inar% "earch tree a" a circle on to $ranching out to two #ore circle" 0one on the left an! one on the right which in return al"o $ranche" out into two #ore circle". The illu"tration ha" the !ata t%e of integer with nu#$er 9 lace! on the to#o"t circle. To check if the illu"tration i" correct we !ivi!e the tree into two) left an! right after that we check if all the value" of the circle on the left "i!e i" lower or eual" the value on the to#o"t of the tree 0in our ca"e it4" 9. The value" on the right "i!e i" a" follow") 1' an! 2 the"e are le"" than 9 "o the left "i!e of the tree i" correct. Ne&t i" the "a#e a" the left "i!e $ut thi" ti#e we have to #ake "ure that the value" in right "i!e are alwa%" greater than 9. The illu"tration contain" 21' = an! 29 o$viou"l% the"e are greater than 9 "o the right "i!e of the tree i" al"o correct. B% the wa% the "ource vi!eo "tate" that the to#o"t value 09 in our illu"tration i" calle! the root. :ow i" it reall% o""i$le for $inar% "earch tree to have a co"t of running a" o(logŋ) for "earching' in"erting an! !eleting; ,ir"t let4" !i"cu"" "earch' thi" oerate" $% co#aring what %ou are "earching for with the root. 8et4" u"e the reviou" illu"tration for thi". I woul! like for u" to tr% an! "earch for 2 "o co#aring 2 to 9 it i" le""er in thi" ca"e we will continue "earching for 2 on the left "u$ tree "ince we4ve known that left "u$ tree contain value" le""er than the root. The a!vantage of thi" i" that we can re!uce the ele#ent" we nee! to "earch through a" we are #oving to the ne&t "te" #aking it a lot fa"ter. The ne&t root i" 1 "o !o the "a#e "te" again' 2 i" greater than 1 rocee! the "earch to right "u$ tree we have root 2 in there an! it" eual to what we are "earching for "o the "earch en!". +e can e&erience the wor"t ca"e if the tree i" un$alance! hence re!ucing onl% one ele#ent" fro# the "earch "ace. It onl% work" a" if it i" "o#ewhat a linke! li"t "o we e&erience #uch "lower "earching. The "a#e goe" for in"erting a new recor! to the $inar% tree' we "tart off co#aring the root to the value we will a!!. If it i" greater then rocee! to right el"e rocee! to left "u$ tree. If there i" "till a chil! continue co#aring until %ou reache! where it "houl! $e a!!e! lace it a" a chil! either to the left or to the right. 8a"tl% for the !eletion it i" #uch like "earching with (u"t a little $it of a!(u"t#ent of no!e" or link". !ata "tructure" that can $e u"e! for "earching' in"erting an! !eleting recor!") an arra%' linke! li"t an! $inar% "earch tree. It i" a!vi"a$le to u"e $inar% "earch tree a#ong the# $ecau"e it ha" lower co"t of running oeration". Binar% "earch tree encounter" wor"t ca"e wherein the co"t of running oeration" ro"e to a higher level an! to avoi! thi" we "houl! make sure that the tree is always
balanced . In"erting an! !eleting recor!" cau"e" $inar% "earch tree to $e un$alance! all we have to !o i" to restore the balancing.