Professional Documents
Culture Documents
1 Introduction
1 Introduction
Fatima Bahjat
- Interface − Each data structure has an interface. Interface represents the set of
operations that a data structure supports. An interface only provides the list of
supported operations, type of parameters they can accept and return type of these
operations.
- Implementation − Implementation provides the internal representation of a data
structure. Implementation also provides the definition of the algorithms used in the
operations of the data structure.
Data structures are used in almost every program or software system. Data structures provide
a means to manage huge amounts of data efficiently, such as large databases and internet
indexing services. Usually, efficient data structures are a key to designing efficient algorithms.
Some formal design methods and programming languages emphasize data structures, rather
than algorithms, as the key organizing factor in software design.
Anything that can store data can be called as a data structure, hence Integer, Float, Boolean,
Char etc, all are data structures. They are known as Primitive Data Structures.
Non-primitive data structures are more complicated data structures and are derived
from primitive data structures. They emphasize on grouping same or different data items
with relationship between each data item. Arrays, Lists and Files come under this category.
Then we also have some complex Data Structures (Derived Data Type), which are
used to store large and connected data. Some examples of Abstract Data Structure
are: Linked List, Tree, Graph, Stack, Queue etc.
The data structures can also be classified on the basis of the following characteristics
Characteristic Description
Static data structures are those whose sizes and structures associated
Static
memory locations are fixed, at compile time. Example: Array
An abstract data type (ADT) is the realization of a data type as a software component. The
interface of the ADT is defined in terms of a type and a set of operations on that type. The
behavior of each operation is determined by its inputs and outputs. An ADT does not specify
how the data type is implemented. These implementation details are hidden from the user of
the ADT and protected from outside access, a concept referred to as encapsulation. While a
data structure is the implementation for an ADT.
Data types have both a logical and a physical form. The definition of the data type in terms of
an ADT is its logical form. The implementation of the data type as a data structure is its physical
form.
What is an Algorithm?
Pseudocode is a mixture of C++ (or some other programming language) and English (or
some other natural language). Pseudocode is used to express algorithms so that you are not
distracted by details of C++ syntax.
1. Time Complexity
2. Space Complexity
Space Complexity
It’s the amount of memory space required by the algorithm, during the course of its execution.
Space complexity must be taken seriously for multi-user systems and in situations where
limited memory is available.
Time Complexity
Time Complexity is a way to represent the amount of time needed by the program to run till its
completion. The time complexity of algorithms is most commonly expressed using the big O
notation. Time Complexity is most commonly estimated by counting the number of
elementary functions performed by the algorithm. And since the algorithm's performance may
vary with different types of input data, hence for an algorithm we usually use the worst-case
Time complexity of an algorithm because that is the maximum time taken for any input size.
When you write a complete function definition, you specify how the function performs its
computation. However, when you are using a function, you only need to think about what the
function does. You need not think about how the function does its work. For example, suppose
you are writing the temperature conversion program and you are told that a function is
available for you to use, as described here:
A precondition is a statement giving the condition that is required to be true when a function
is called. The function is not guaranteed to perform as it should unless the precondition is true.
A postcondition is a statement describing what will be true when a function call is completed.
If the function is correct and the precondition was true when the function was called, then the
function will complete, and the postcondition will be true when the function call is completed.