Beruflich Dokumente
Kultur Dokumente
DATA STRUCTURES
AND ALGORITHMS
ISBN 978-80-7478-568-9
9 788074 785689
Názov projektu:
Data structures
and algorithms
2014
Example of citation:
SCHINDLER, Frank. Data structures and algorithms. 1st ed. Prague: Wolters Kluwer,
2014. ISBN 978-80-7478-568-9.
This publication has been published with the financial support of European Union
within Operational Programme Education as a result of the project under the name
“Quality Education at the Pan-European University with International Cooperation”.
This publication reflects the views only of the author, and the European Union cannot be
held responsible for any use which may be made of the information contained therein.
First edition
ISBN 978-80-7478-568-9
CONTENtS
1 INTRODUCTION.......................................................................................... 7
7 SECURITY IN PROGRAMMING................................................................. 67
7.1 Introduction.............................................................................................. 68
7.2 Information Hiding................................................................................... 69
7.3 Defensive Programming............................................................................. 69
7.4 Assuming the Impossible........................................................................... 70
7.5 Programming Examples............................................................................. 71
7.5.1 Buffer Overflows............................................................................. 71
7.5.2 Missing Initialization of Variables.................................................... 72
7.5.3 Cryptic Code................................................................................... 72
7.5.4 Program Ignoring Error Messages.................................................... 72
7.5.5 Missing Null-Condition Restrictions............................................... 73
7.5.6 Dangling Pointers............................................................................ 73
7.5.7 Assertions........................................................................................ 74
7.5.8 Work with Library Functions.......................................................... 74
7.5.9 Paradoxes – Testing the Impossible (Variant of “Y2K Bug”)............. 75
7.6 Concluding Remarks................................................................................. 75
BIBLIOGRAPHY.................................................................................................. 77
1 INTRODUCTION
Life today: it’s much more complicated that it was a thousand years ago. It is
a well-known fact that beyond some limit the human mind is unable to cope
with too much complexity. Therefore there is an urgent need to use some sort of
a simple tool, let us call it an abstraction, to separate the essentials of an object or
an idea from its details which overwhelm us in the given moment of time. With
the concept of abstraction we focus on the “what”, not the “how”.
A simple example of this could be the postal delivery system. For an unbiased
viewer, it simply delivers letters and packages from senders to recipients. We
should not care so much about details on how this is done. Another interesting
example comes from programming itself.
We often use identifiers to denote variables, constants, functions and any other
complicated data type or object. It is just another form of a very useful abstrac-
tion. A well-chosen variable name can hide the details how the data values are
stored in memory of the computer and instead it stresses what is being stored
there.
Top-down design may also be looked at as an abstraction. At the top-most level
the problem solution may be imagined as the most abstract. Each next level con-
tains more and more details, in such a way that it should stay not too complex
at any specific level.
The functional abstraction is separating the function‘s behaviour from its imple-
mentation. By invoking a built-in function in the expression
sqrt (7*a + b)
the programmer should only know the function’s specification in the form of
a textual description of what the function sqrt does. Usage of such a function
8 CHAPTER 1
does not require any knowledge of its implementation details. One functional
abstraction can be layered at the top of another functional abstraction. A func-
tion FuncA can invoke FuncB that in turn may call further functions. This is
a quite typical case for the top-down design of larger software programs.
The abstraction approach should be applied to data as well. Data abstraction sep-
arates properties of a data type from details of its implementation. The data type
implementation involves a concrete data representation for the abstract values,
along with implementation of all its allowable operations in terms of program-
ming instructions in a chosen programming language. Data representation is
often done in multiple layers of abstraction. Each of them is more abstract than
the layer below it. More importantly the user of such a data abstraction only
needs to know its defining properties, not its implementation details. This con-
siderably reduces data complexity and the user is shielded from possible future
changes in the data implementation.
Recognition of the importance of data abstraction becomes fundamental in
modern software design. In our book, we will explore the use of abstraction
during program design, coding, testing and any modification process. The use
of abstraction techniques in this textbook does not prove all of its benefits right
away. However it may drastically simplify the big jump from writing small com-
puter programs into huge software projects. Without these abstraction tools we
would not be able to master such complex software programs that we are now
using in our everyday life. The book is concluded by a final chapter that relates
to safe programming techniques, that includes pinpointing typical programming
errors that C++ programmers make when they write programs and large software
projects.
BIBLIOGRAPHY
Arulanandham, J. J. – Calude, C. S. – Dinneen, M. J.: A fast natural algo-
rithm for searching. In: Theoretical Computer Science, 2004, Vol. 320, No. 1, p. 3-13.
ISSN 0304-3975
Bishop, M. – Frincke, D.: Teaching Robust Programming. In: IEEE Security and
Privacy, 2004, Vol. 2, No. 2, p. 54-57.
Blaha, M.: A Copper Bullet for Software Quality Management. In: Computer, 2004,
Vol. 37, No. 2, p. 21-25.
Booch, G. – Maksimchuk, R. A. – Engel, M. W. – Zouny, B. J. –
Conallen, J. – Houstin, K. A.: Object-Oriented Analysis and Design with
Applications. 3rd Ed. MA, Reading : Addison-Wesley, 2007.
Carrano, F. M. – Henry, T.: Data Abstraction and Problem Solving with C++: Walls
and Mirrors. New Jersey : Prentice Hall, 2013. ISBN 0132923726
Choppy, C. – Bidoit M.: Recent Trends in Data Type Specification: 8th Workshop on
Specification of Abstract Data Types joint with the 3rd COMPASS Workshop. Heidel-
berg : Springer Verlag, 1993, 360 p. ISBN 540563792
Cormen, T. – Lieserson, C. – Rivest, R.: Introduction to Algorithms. Cam-
bridge, Mass. : MIT Press, 1993, 1048 p. ISBN 0-262-03141-8
Cunto, W. – Gascon, J.: Improving Time and Space Efficiency in Generalized
Binary Search Trees. In: Acta Informatica, 1987, Vol. 24, No. 5, p. 583-594.
DALE, N.: C++ Plus Data Structures. Jones and Barlett Learning, 2013, 804 p. ISBN
1-449-64675-1
Dijkstra, E.: Go to statement considered harmful. In: Communications of the ACM,
1968, Vol. 11, No. 3, p. 147–148.
Dobosiewicz, W.: Optimal Binary Search Trees. In: International Journal of Com-
puter Mathematics, 1986, Vol. 19, No. 2, p. 135-151.
78 BIBLIOGRAPHY
Ehring, H. – Orejas, F.: Recent Trends in Data Type Specification: 9th Workshop on
Specification of Abstract Data Types Joint with the 4th COMPASS Workshop. Heidel-
berg : Springer Verlag, 1994, 364 p. ISBN 3540578676
Esakov, J. – Weiss, T.: Data Structures – An Advanced Approach using C. New Jersey :
Prentice Hall, 1989, 372 p. ISBN 0-13-198847-6
Ferguson, N. – Schneier, B.: Practical Cryptography. Indianapolis, Indiana :
Wiley Publishing, 2003, 410 p. ISBN 0-471-22357-3
Goldberg, D.: What every computer scientist should know about floating-point
arithmetic. In: ACM Computing Surveys, 1991, Vol. 23, No. 1, p. 5-48. ISSN 0360-0300
Goodrich, M. T. – Tamassia, R. – Mount, D. M.: Data Structures and Algorithms
in C++. New Jersey : John Wiley and Sohn, 2011, 736 p. ISBN 978-0-470-38327-8
Headington, M. R. – Riley, D. D.: Data Abstraction and Structures using C++.
Lexington, Massachusetts : D. C. Heath and Company, 1994, 661 p. ISBN 0-669-
-29220-6
Horowitz, E. – Sahni, S. – Rajasekaran, S.: Computer Algorithms C++. New
York : Computer Science Press, 1997, 777 p. ISBN 0716783169
Josuttis, N. M.: The C++ Standard Library: A Tutorial and Reference. MA, Reading :
Addison-Wesley, 1999, 799 p. ISBN 0-201-37926-0
Klemens, B.: Modeling with Data: Tools and Techniques for Scientific Computing. New
Jersey : Princeton University Press, 2008, 472 p. ISBN 9780691133140
Knuth, D. E.: The Art of Computer Programming. Volume 3: Searching and Sorting.
2nd Ed. MA, Reading : Addison-Wesley, 1998, 800 p. ISBN 0201896850
Kochan, S. G.: Programming in C. 3rd Ed. Indianapolis : Sams Publishing, 2004,
576 p. ISBN 0672331411
Koffman, E. B. – Wolfgang, P. A. T.: Objects, Abstraction, Data Structures and
Design: Using C++. New Jersey : John Wiley and Sohn, 2006, 832 p. ISBN 0-471-
-46755-3
Main, M.: Data Structures and Other Objects using C++. New Jersey : Prentice Hall,
2010, 848 p. ISBN 0-132-12948-5
Main, M. – Savitch, W.: Data Structures and other Objects using C++. New Jersey :
Prentice Hall, 2011. ISBN 0132129485
Malik, D. S.: Data Structures Using C++. Boston, MA : Course Technology, 2009,
912 p. ISBN 0-324-78201-2
BIBLIOGRAPHY 79
DATA STRUCTURES
AND ALGORITHMS
First edition
ISBN 978-80-7478-568-9