Complete Data Structure and How They Are Used

A data structure is a collection of variables, may be of different data types, connected in various ways. This includes the simple array and complex ones like linked lists, stacks, queues, graphs, trees, adjacency matrix, etc. Complex data structure is essential in programming especially when you need to create an instance of an object with multiple properties. For the purpose of illustrating clearly how essential data structures are, we will use the syntax of the C programming language to discuss it. In C, you can create a variable with a user-defined type that can contain multiple simple data types (int, char, float, etc) using the keyword  struct .

Other complex data structures such as stacks and queues, also referred as Abstract Data Types, are used in different algorithms. Stack is one of the basic data structures used widely from simple applications up to intricate ones. It follows the  last in, first out  manner. A simple program that converts binary string to its equivalent decimal number can be implemented by using a stack. First, push every digit of the binary number to the stack from left to right. The top of the stack will be occupied by the ones digit. Next, pop the top of stack and compute its decimal equivalent in ones digit. Then, pop the current top of stack, compute for its decimal equivalent in tens digit and so on until the stack becomes empty. Sum all the computed values and that will be the final decimal equivalent of the input binary string. In the other hand, another data structure called queue follows the  first in, first out  manner and has proven to be useful in many applications.

Complex data structures are also used in searching algorithms. Depth-first search (DFS) algorithm uses stack while Breadth-first search (BFS) uses queue. These two searching algorithms are used in route finding or computing the minimum cost route from the current node to a target node. They are also used in algorithm for solving puzzles. One classic example is the Eight Puzzle where the possible moves are determined using BFS or DFS.

In general, complex data structure is needed since most simple data types are insufficient to create a fully functional program or implement algorithms in a shorter time.

Array is one of the simplest data structure. It is a group of objects of the same data type that can be accessed by indexing. It can be one-dimensional or multi-dimensional. It can also be categorized as either be static or dynamic. A static array has fixed memory allocation while a dynamic array allows you to keep the size of the array unspecified in the declaration and specify it during the run time. Computations and processes on array usually used loops. Array can be used in different sorting algorithms such as bubble sort, selection sort, merge sort, insertion sort, quick sort, etc. and searching algorithms such as linear search and binary search.

The most obvious reason why array is very convenient to use is that it simplifies programming. It makes a program code shorter and neat. Let us say we have a program that computes the average grade of 100 students. The program asks the user to input the grades of 100 students. This can be implemented with or without the use of array. To implement this without array, 100 different variables must be declared. The program will prompt the user to enter grades 100 times manually. The code has 100  scanf()  tags(assuming the programming language used is C) for asking the user for input. Adding the variables is tedious for the programmer since he has to write all the 100 variables to sum them all. The result of not using arrays is a very long and messy code. It is appropriate and practical to use an array in this type of problem. With array, you can just simply declare one variable to store the 100 inputs from the user, e.g. array100. Using loop, it is possible to prompt user 100 times using only a single line of code. The same goes when adding the values of the inputs. The programmer need not to write all the variables used to store the data. He or she will have to use loop and add the variables while the index increments.

Modular design is an approach that breaks down a problem into smaller parts or modules which are designed individually. This mechanism gives many benefits for the programmers. Since application programs, in reality, become bigger in size and more complex, operation and processes in the program must be properly managed to avoid messy codes and lousy implementation of algorithms.

The benefits of modular design can be seen in projects done by team. It coordinates the work of many people and manages the interdependencies between those works or modules. An application may have several functionalities, possibly related to each other. It would be better to use modules to independently create those functionalities. In this manner, if one of the functionalities failed it will not affect the other functionalities since they are designed individually.

Another benefit would be a clearer and organized code. Since modular design allows you to divide your code according to its functionalities, you can easily determine in which part of the code you put the functionalities.

Modular programming enhances the readability of your code. With a more readable code, a programmer can easily fix the bugs within the program.

With modules, developers can easily maintain the program as it gives more flexibility in maintenance and enhance it. Since the program code is easy to understand, maintenance will not be a problem. If there is a need to change the system, it will be done easily since the affected modules only will be modified. Enhancing the program may be done by adding modules for additional features or functionalities.

Generally, modular design helps programmers to build robust application. These were basically made to handle a program s intricacy. Applications that process real-world problems are very complex in structure. With such complexity, there s really a need to practice modular programming in order to resolve such.

0 comments:

Post a Comment