Because G is a true programming language, LabVIEW programmers can and should apply the elements of computer science. This chapter presents a brief introduction to one of those elements: the analysis of computer algorithms and the accompanying metrics and notations. Several common types of problems will be discussed and several algorithms for each problem type will be presented and analyzed.
An algorithm is a well-defined sequence of steps that is guaranteed to terminate with a correct solution. Multiple algorithms may be available to solve a given problem, but one may have advantages over another. The size and nature of the input often determine the most effective algorithm. Convenient data structures and limitations on time and space can also favor one algorithm over another. Real-time systems require algorithms that are more efficient in their use of time. To choose the best algorithm, a programmer needs some metrics to evaluate the possible choices.
Analysis of Algorithms
Algorithms for a given problem can be evaluated and compared to determine the best solution. Common operations in the different algorithms can be identified and counted to evaluate the algorithms fairly. An algorithm performs many operations on its input but some fundamental operation(s) take up the bulk of the run time. The fundamental operation in a sorting routine can be the comparisons between elements or the swapping of elements, since an array cannot be sorted without comparing all elements and possibly moving...
Copyright The McGraw-Hill Companies, Inc. 1998 under license agreement with Books24x7