data structures using top-down vs bottom-up approach whether the top-down strategy should be followed or bottom-up is question that can be answered depending on the application at hand while top-down approach follows stepwise refinement by decomposing the algorithm into manageable modulesthe bottom-up approach on the other hand defines module and then groups together several modules to form new higher level module top-down approach is highly appreciated for ease in documenting the modulesgeneration of test casesimplementation of codeand debugging howeverit is also criticized because the sub-modules are analysed in isolation without concentrating on their communication with other modules or on reusability of components and little attention is paid to datathereby ignoring the concept of information hiding although the bottom-up approach allows information hiding as it first identifies what has to be encapsulated within module and then provides an abstract interface to define the module' boundaries as seen from the clients but all this is difficult to be done in strict bottom-up strategy some top-down activities need to be performed for this all in alldesign of complex algorithms must not be constrained to proceed according to fixed pattern but should be blend of top-down and bottom-up approaches control structures used in algorithms an algorithm has finite number of steps some steps may involve decision-making and repetition broadly speakingan algorithm may employ one of the following control structures(asequence(bdecisionand (crepetition step input first number as step input second number as step set sum + step print sum step end sequence by sequencewe mean that each step of an algorithm is executed in specified order let us write an algorithm to add two numbers this algorithm performs the steps in purely sequential orderas shown in fig decision decision statements are used when the execution of process depends on the outcome of some condition for exampleif ythen print equal so the general form of if construct can be given asfigure algorithm to add two numbers if condition then process condition in this context is any statement that may evaluate to either true value or false value in the above examplea variable can be either equal to or not equal to howeverit cannot be both true and false if the condition is truethen the process is executed decision statement can also be stated in the following mannerif condition then process else process this form is popularly known as the if-else construct hereif the condition is truethen process is executedelse process is executed figure shows an algorithm to check if two numbers are equal repetition repetitionwhich involves executing one or more steps for number of timescan be implemented using constructs such as whiledo-whileand for loops these loops execute one or more steps until some condition is true figure shows an algorithm that prints the first natural numbers