Comparison of Array Based Stacks in C and Ada
Comparison of Array Based Stacks in C and Ada The stack is one of the simplest data structures. Array-based stacks can be implemented in all languages supporting arrays, even including early versions of Fortran which did not support pointers. This comparison is based upon C code published at http://www-cs.ccny.cuny.edu/~peter/dstest.html The C code published at http://www-cs.ccny.cuny.edu/~peter/dstest.html supports the book Advanced Data Structures authored by Peter Braß and published by Cambridge University Press. The Ada code uses Ada2012, which added aspect specifications, pre and post conditions, type invariants and subtype predicates to the Ada language. Descriptions of these and other features added in the Ada 2012 version are available at The Ada 2012 Rationale Array Stack The C code for Array Stack is shown below. Example 1 ArrayStack.c #include <stdio.h> #include <stdlib.h> typedef int item_t; typedef struct ...