; TeX output 1996.03.06:1131soJDtGGcmr17The7t߆TG cmtt12newalgPqackageuXQ cmr12RicrkFVarnbach2K cmsy8=缻PraulFVurnanz2y%ȍiMarcrh6,1996.!Kt : cmbx9Abstractэoo cmr9TheXpac9k|ragecontainsthede nitionsthatareneededtotypAesetcode balgorithmsDinaprett9yway:.`?TheFormattedalgorithmsfollo9wthestylesetbforthxinthebAookx\In9troductiontoAlgorithms"b9yCorman,LeisersonandbRiv9est.!čINff cmbx12ContentsI"V cmbx101XIn9troQduction1I2XUserTIn9terface1 XK`y cmr102.1oTheUUm#R cmss10algorithmenvironmentu.......................V1X2.2oFlowUUControlEnvironmentsԤ......................V2X2.3oMacrosэ..................................V4X2.4oAdditionalUUkeywordsandsymbGols?3...................V4I3XF utureTWork ek4I1aLIntros3ductionIThe10L5ffٓRcmr7A͉TU>'ExXmacroswhicharedescribGedhereallowdescriptionsofalgorithmstoIbGetypesetinaprettyway*.jThisisveryusefulforfunctionalspGeci cationsforaIsoftwareUUpro8jectortodoGcumentanalgorithmforawhitepaper.XTheideaforthismacropackqagecomesfromthebGook\IntroductiontoAlgo-Irithms"CkbyCormen,GLeiserson,andCkRivest.kAnyexamplesinthisdoGcumentcomeIdirectly4fromthatbGook4andshouldnotbGereproducedwithoutproperattribution.I2aLUserffInterfaceIN cmbx122.1gThe kAH cmssbx10algo"rithmenvironmentuTIUseothealgorithmenvironmenttotypGesetalgorithmcode.%TThisenvironmentomakesy!ߤN cmtt9algorithmIX-ffr @ -:q% cmsy6L|{Ycmr8Email: ricÎkffЎ^farnbach@mentorg.com [-:yLܼEmail: paulffЎ^furnanz@menÎtrog.com1*soIseveralnewcommandsavqailablethathelpintypGesettingcodealgorithms.T.Theal- Igorithm"environmentusesmathmoGdeandthearrayenviromenttodothetypGeset-Iting.] Everything%typGedisinterpretedinmathmoGde.] T*oleavemathmoGdeusetheItext Fcommand.`HereisanexampleoftheoutputproGducedbyusingthealgorithmIenvironment.L s2N "- cmcsc10AllocaUTte-ObjectkK()Que1`ugifk b> cmmi10frGee=nilQue2kthenZerrorj\outUUofspace"Que3kelseZx !", cmsy10 frGeeQue4ZfrGee next[x]Que5Zreturn.4x \begin{algorithm}{Allocate-Object}{}  \begin{IF}{free=\NIL}0\ERROR{outofspace} \ELSE0x\=free\\0free\=next[x]\\0\RETURNx \end{IF}\end{algorithm}SsI2.2gFlowControlEnvironmentsuTIUseRztheenvironmentRzIFR8toformatanifstatement.WheninsidetheIFenvironment,4IFItheELSE²macrobGecomesavqailabletoshowtheelseclause.BMTheenvironmenttakesIone66argumentthatistheconditionfortheifstatement.jF*oranexampleofitsIusage,UUseetheabGoveUUexample.XUse6theFORenvironment6toformataforloGopandtakesoneargument.RThere/>FORIareV)twokindsofforloGopssupportedbythismacro.tBThe rsttypGeofforloopIis2generallyknowasthe#': cmti10for-e}'achOloGop. ThistypGeofloopisusedtoiterateIoverzMthevqaluesofsomeset.ThesyntaxfortheargumenttotheenvironmentIis$\$\IN".TheothertypGeofloopsupportedisusedtoas-Isignavqariabletoarangeofvalues.ThesyntaxfortheargumentinthiscaseisI\?\=\TO".qHereUUisanexampleusage.dX䍍s2OcqGreedy-AUctivity-SelectorH3(s;f)R1aȵn l2`eng[th[s]R2aȵA 1R3aȵjY 1R4aforsi 2Tto㈵nRƲ5adoqif|The!|SWITCHIenvironment8islikeanitemizeenvironment.Usethecommand\item{}ItoCcreateanewcaselabGel.kTheconditionscanbeanything,GNILIavvqariablethathasnovalueassinged.A*Usethetext\=tosignalassinment.This4\=IcommandUUproGducesthissymbolintheformattedtext,\ ".!čI3aLFfutureffWorkIThecurrentimplementationofthealgorithmenvironmentissensitivetothepropGerIplacementkof\\inthetext.Seetheexamplesforthis.TheenvironmentskshouldIworkwithoutbGeingsofussyonthispoint.(Sometimeyouneeda\\attheendIofUUandenvironment,UUsometimesyoudon't).XIwould9likethesyntaxoftherepGeatlooptobethesameasthewhileloop.IIwashavingsometroublegettingthestackcommandstowork,GsothatIcouldIsaveoftheargument.PThisenvironmentisnotveryconsistentwiththerestoftheIalgorithmUUenvironments.4$soXThereisprobablyabGetterwaytodotheformattingthenusingthearray Ienvironment.CurrentlyL5ffA͉TU>'ExXisformattingthealgorithmsbyusingthearrayIenvironment.qThisUUisprettysilly*,bGecausethisisnotreallyanarray*.XY*oucannotcenterthealgorithmenvironment.ThisisprobablybGecaseitisIbGeingwimplementedasanarray*.,ThecurrentworkqaroundforthisproblemistoIincludethealgorithmina\begin{minipage}{1pt}...nN\end{minipage}.SeemsItoUUworkineverycasethatIhavecomeaccross.XThereisprobablyabGetterwaytomakeamodethatislikemathmodethatIdoGesUUnotinsert$characterseverywhere.XI1am1notveryexpGeriencedinwritingmodesforL5ffA͉TU>'ExX,8soifyouhaveanysug-IgestionsVforimprovementsVorknowhowtosolveanyoftheabGovelistedproblems,IpleaseUUsendmeemail.qTheaddressisonthefrontpageofthisdoGcument.51; $ cmmi10 0ercmmi7K`y cmr10ٓRcmr76