How Programmers Design, Analyze and Choose Procedures for Organizing and Searching Information
Learn how programmers design, analyze and choose algorithms and data structures for efficient searching, sorting, storage and software performance.
The manner in which data are processed (the procedures) impacts software performance more so than does the hardware capabilities of the computer. Pupils tend to "learn by rote" a piece of code which sorts or searches, rather than understanding why some procedures are more efficient than others when scaled up. This article shows the relationship among procedures and storage structures, assessing efficiency, commonly used design patterns, and how the student can practice to maintain knowledge of the concepts after he/she takes his/her examination.
Procedures and Storage Go Hand in Hand to Its Detriment.
Information is stored on a device and a program is used for working with this information. These two will not exist independently. An array allows quick retrieval of individual items from an array using index numbers. But it will take more time to add newcomers to an array if the items are being added near the middle of it than if the items are being added to a linked list. However, a linked list can easily append new elements to the linked list anywhere in the list. However, it takes a much longer amount of time to find particular items in the linked list than does an array. So, whenever learning algorithm in data structure , students should be stressing about the efficiency of the operations of each of those storage structures.
Measuring Efficiency
A program's running time depends on the speed of the computer, so the analyst computes the amounts of work that must be done for a given unit of input size. Big O notation is used to get the amount of extra work needed to process for each input size. If the size of the input is in the thousands the time of a procedure that is linear is around one thousand times the time of a procedure that is quadratic with the size of the input. Memory (space) usage should also be taken into account, particularly for systems with a limited amount of memory.
Linear Structures in Practice
The basic structures are - Array, Linked List, Stack and Queue. Stacks follow the last-in, first-out principle and can be used to make functions like "undo," or "expression evaluation," etc. A queue is a data structure with FIFO (first in, first out) properties that can be utilized for "scheduling" or "buffering". Programming in a structured way to solve a simple problem like reversing a list, or verifying that parentheses are balanced, is a simple example of how the algorithm used in a data structure can simplify a problem's solution.
Searching and Sorting
Linear search sequentially checks the elements of the array. Binary search halves the size of the search space each time it makes a comparison. The array must be sorted for a binary search to work, however. Some of the simplest sorting algorithms are bubble sort and insertion sort. Both relatively time consuming in terms of sorting, but extremely easy to understand. Merge sort and quicksort are much faster than either of those two sorting algorithms. Each type of sorting algorithm will be tested with the same sets of data to see how effective they are. By comparing the speed at which both these sorting algorithms sort the same sets of data, it will be possible to say which has a better performance in terms of time, space, and stability.
Trees and Hierarchies
Data that is hierarchical like files and organisation charts will be represented as a tree. Tree structures can be used to access data in a rapid way, but only when they are balanced. If a tree becomes unbalanced (i.e. it may become after many insertions or deletions), then the required time to find an item in a tree is approximately the time required to search for the item in a linear array. Balanced trees (AVL trees, red black trees) will help solve this problem and heap data structures will enable him to implement the priority queuing. When comparing two algorithms having two classes of data structures, it would be wise to do, by hand, all the insertions in the two types of data structures. Hand-made insertions also will show you the changes that are occurring to the data structure, something you'll not be able to do with only code.
Graphs and Relationships
A graph is a collection of many roads, many relationships etc etc., that create the road network, relationship network etc. To investigate all of the connections in a graph there are two major searching techniques. Breadth first search (BFS) and Depth first search (DFS) are two techniques used. Another application is using either BFS or DFS to find the optimal path between two nodes. It is very important to properly represent your graphs. Adjacency lists would be best for sparse graphs as this would use less storage than matrices. In the case of matrices things get much easier and you'll be able to check easily if there is an edge between two nodes or not. Once you have defined the problem some problems that are found in the real world can be solved by using graphing (such as routing and scheduling).
Conclusion
Structures for storing data, methods for manipulating this data and the knowledge of a sound understanding comes from relating one to the other, assessing the costs with honesty and practicing solving problems that involve linear, hierarchical, network problems. As experience is gained, strategies for designing software systems will be learned. When writing out explanations of how to solve a problem, some places of misunderstanding will become evident that you may not notice when writing the actual code quickly. If students think about running fast-functions when they study algorithms in data-structures, their skills will remain useful long beyond after exams.
0 comments
Log in to leave a comment.
Be the first to comment.