Top and Bottom in Dsuc
Top and Bottom in Dsuc
Top and Bottom in Dsuc
The basic idea in top-down approach is to break a complex algorithm or a problem into
smaller segments called modules, this process is also called as modularization. The modules
are further decomposed until there is no space left for breaking the modules without
hampering the originality. The uniqueness of the problem must be retained and preserved.
The decomposition of the modules is restricted after achieving a certain level of modularity.
The top-down way of solving a program is step-by-step process of breaking down the
problem into chunks for organising and solving the sole problem. The C- programming
language uses the top-down approach of solving a problem in which the flow of control is in
the downward direction.
Bottom-Up Approach
As the name suggests, this method of solving a problem works exactly opposite of how the
top-down approach works. In this approach we start working from the most basic level of
problem solving and moving up in conjugation of several parts of the solution to achieve
required results. The most fundamental units, modules and sub-modules are designed and
solved individually, these units are then integrated together to get a more concrete base to
problem solving.
This bottom-up approach works in different phases or layers. Each module designed is tested
at fundamental level that means unit testing is done before the integration of the individual
modules to get solution. Unit testing is accomplished using low-level functions, that is
another topic we will talk about later.
Let us now see a comparative study of both the strategies and try to understand what are
common and odds among them.
A well-established communication is
Communication among steps is mandatory.
not required.
The individual modules are
Works on the concept of data-hiding and encapsulation.
thoroughly analysed.
Conclusion
After having a sound discussion on this we all should now have got a clear understanding of
the two approaches. The top-down approach is the conventional approach in which
decomposition of higher level system into lower level system takes place respectively.
Talking about the bottom-up mechanism for algorithm designing, starting from designing
lower abstraction modules and then integrating them to higher level provides better
efficiency.
We have seen the modules in top-down approach aren’t connected in a manner so that they
can communicate well, so giving rise to redundancies, whereas in the later case the
redundancies are omitted to large extent. The feature of information hiding and reusability
provided by bottom-up approach makes this mechanism even more popular.
Take a step-up from those "Hello World" programs. Learn to implement data structures like
Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to
start learning today.
On the contrary, in the Assembly languages like Microprocessor 8085, etc, the statements do
not get executed in a structured manner. It allows jump statements like GOTO. So the
program flow might be random.
The structured program mainly consists of three types of elements:
Selection Statements
Sequence Statements
Iteration Statements
The structured program consists of well structured and separated modules. But the entry and
exit in a Structured program is a single-time event. It means that the program uses single-
entry and single-exit elements. Therefore a structured program is well maintained, neat and
clean program. This is the reason why the Structured Programming Approach is well
accepted in the programming world.
Advantages of Structured Programming Approach:
1. Easier to read and understand
2. User Friendly
3. Easier to Maintain
4. Mainly problem based instead of being machine based
5. Development is easier as it requires less effort and time
6. Easier to Debug
7. Machine-Independent, mostly.
Disadvantages of Structured Programming Approach:
1. Since it is Machine-Independent, So it takes time to convert into machine code.
2. The converted machine code is not the same as for assembly language.
3. The program depends upon changeable factors like data-types. Therefore it needs to
be updated with the need on the go.
4. Usually the development in this approach takes longer time as it is language-
dependent. Whereas in the case of assembly language, the development takes lesser time
as it is fixed for the machine.
The theoretical basis for structured programming goes back to the 1950s, with the emergence
of the ALGOL 58 and 60 languages. Up to then, code clarity was reduced by the need to
build condition/action tests by having programmers write linked tests and actions explicitly
(using the goto statement or its equivalent), resulting in what was often called spaghetti code.
ALGOL included block structure, where an element of code included a condition and an
action.
Structured programs and modules typically have a header file or section that describes the
modules or libraries referenced and the structure of the parameters and module interface. In
some programming languages, the interface description is abstracted into a separate file,
which is then implemented by one or more other units of code.
2. It promotes code reuse, since even internal modules can be extracted and made
independent, residents in libraries, described in directories and referenced by many other
applications.
3. It's widely agreed that development time and code quality are improved through
structured programming.
These advantages are normally seen as compelling, even decisive, and nearly all modern
software development employs structured programming.
Structured programming can also be applied incorrectly if the type of structure selected isn't
right for the task at hand. The best-known example is the solving of math problems. RPL is
an efficient way to state and solve a math problem because it eliminates the need to explicitly
state execution order and eliminates recursion in code. However, if that problem were to be
posed in structured programming procedural or object form, the resulting code would be
much less efficient than the RPL version.