You are on page 1of 5

Data structures

3.1 Arrays
3.2 Stacks
3.3 Queues
3.4 Lists and linked lists
3.5 Trees
3.6 Hash tables

introduction
The way for structurally organizing the data in memory to achieve the high efficiency for
carrying out operation on information is called data structure. Data structure is the physical
implementation of ADT. For example, the data structure for customer entity may contains the
customer ID, name, address, birth date, balance etc. Data structures are divided into several types
each of which correspond to a special method in computer program design and electronic
processing and can be classified as the following three types: linear data structures, tree data
structures and graphs data structures.
- The linear data structure is dealing with stacking data within the memory on a single line and
these include: arrays, string, records, tables, lists, stack and queues
- The tree data structure is concerned with the hierarchical data structures like the tree
representation of data set for a large family or an organizational structure of a company
- Graphics data structure is concerned with graphics and in other words, if any element of a
lower level in the tree data structure linked with more than one element at a higher level is
referred to by name data graphics structures.

3.1 Arrays
Arrays are defined as a set of similar elements, and these elements can be a numeric value,
symbolic value, combinations of numeric value and string, or a set of records, and they are
classified in terms of the dimensions into two classes: one dimensional array and multiple
dimensional array.
For example, if the student scores in database systems, mathematics, operating systems, software
engineering, Delphi language and data structure courses are 80, 75, 68, 90, 76, and 83
respectively, we can create an array of six elements to store these values as in Fig (1). The data
for student scores are stored in array of six elements and their corresponding addresses started
from 0 to 5. The values can be inserted or retrieved from arrays according to these addresses and
in our example here if we named this array by studScores then we denote any of the array
elements by the array name followed by the respective index such as studScores(1) to refer to
mathematics and studScores(5) to refer to data structures course and so on. That means the
studScores array is represented by studScores[n] where n is the index that referencing the array
elements.

3.2 Stacks
Stacks are more abstract data structure than arrays and any other data storage and their
implementation mechanisms are not visible to users. Stack is a special container for temporarily
storing data and accessing it through a specific mechanism. As Goodrich and Tamassia defined
its purpose "A stack is a collection of objects that are inserted and removed according to the lastin first-out (LIFO) principle", (2006). Stacks allow accessing only one item at a time, the last
item inserted is accessed first, or in other words the Last-In-First-Out (LIFO) mechanism and the
item next to the last item can be accessed when removing the last item and so on. The stack is
actually like the pistol, where the last bullet is fired first and when it is released, the bullet which
followed become ready to be shot the next, and so on until we fired at last the first bullet inserted
i.e. the insertion and deletion is doing at the highest by using pushing and popping functions
respectively and the top pointer i.e. doing the top one first as shown in Fig (1). Stacks are used
for temporary storage for addresses and data while the program is running.
Fig (1)- Stacks structures
The most benefits of using stacks are represented in finding the values of arithmetic expressions,
using for the recursion purposes and calling of sub-programs. The pointer top holds the index
value -1 when the stack is empty and this value is incremented by one whenever a new value is
inserted in the stack until filled. During the out process the stack pointer value is decremented by
one until its value becomes -1 which indicate that the stack is empty.
For example, suppose that we have the values a, b and c stored in stack and we need to store a
new value d, and after that we decide to pull a value from the stack, it will be the last value
entered The methods used for representing stack elements in memory with putting into account
the ways for storing and retrieving values can be classified as in the two following points:
- Interconnected ring representation of stack elements in memory as a list
- Compact representation of stack elements in memory in the form as a one-dimensional array.

3.3 Queues
The queue Is a type of linear data structures and it resembles the stack in term of temporary
storage of data while different from the organization that applied to input and output data while
differ in the operation of input and output mechanism, the queue uses the First-In-First-Out FIFO
mechanism. As Harris and Ross defined it, "a queue is a collection of objects that are inserted
and removed according to the first-in first-out (FIFO) principle".

/
.
.

linked list
In computer science, a linked list is a data structure consisting of a group of nodes which
together represent a sequence. Under the simplest form, each node is composed of a data and a
reference (in other words, a link) to the next node in the sequence; more complex variants add
additional links. This structure allows for efficient insertion or removal of elements from any
position in the sequence
Linked lists are among the simplest and most common data structures. They can be used to implement
several other common abstract data types, including lists (the abstract data type), stacks, queues,
associative arrays, and S-expressions, though it is not uncommon to implement the other data
structures directly without using a list as the basis of implementation.

The advantages and disadvantages of using linked lists are as follows:Advantages:

Linked lists are a dynamic data structure, allocating the needed memory while the
program is running.
Insertion and deletion node operations are easily implemented in a linked list.

Linear data structures such as stacks and queues are easily executed with a linked list.
They can reduce access time and may expand in real time without memory overhead.

Disadvantages:

They have a tendency to waste memory due to pointers requiring extra storage space.
Nodes in a linked list must be read in order from the beginning as linked lists are
inherently sequential access.
Nodes are stored incontiguously, greatly increasing the time required to access individual
elements within the list.
Difficulties arise in linked lists when it comes to reverse traversing. Singly linked lists are
extremely difficult to navigate backwards, and while doubly linked lists are somewhat
easier to read, memory is wasted in allocating space for a back pointer.

tree
In computer science, a tree is a widely used abstract data type (ADT) or data structure
implementing this ADT that simulates a hierarchical tree structure, with a root value and subtrees
of children, represented as a set of linked nodes.
A tree data structure can be defined recursively (locally) as a collection of nodes (starting at a
root node), where each node is a data structure consisting of a value, together with a list of
references to nodes (the "children"), with the constraints that no reference is duplicated, and none
points to the root.
Alternatively, a tree can be defined abstractly as a whole (globally) as an ordered tree, with a
value assigned to each node. Both these perspectives are useful: while a tree can be analyzed
mathematically as a whole, when actually represented as a data structure it is usually represented
and worked with separately by node (rather than as a list of nodes and an adjacency list of edges
between nodes, as one may represent a digraph, for instance).
For example, looking at a tree as a whole, one can talk about "the parent node" of a given node,
but in general as a data structure a given node only contains the list of its children, but does not
contain a reference to its parent (if any).

hash table
In computing, a hash table (hash map) is a data structure used to implement an associative
array, a structure that can map keys to values. A hash table uses a hash function to compute an
index into an array of buckets or slots, from which the correct value can be found.
Ideally, the hash function will assign each key to a unique bucket, but this situation is rarely
achievable in practice (usually some keys will hash to the same bucket). Instead, most hash table
designs assume that hash collisionsdifferent keys that are assigned by the hash function to the
same bucketwill occur and must be accommodated in some way.
In a well-dimensioned hash table, the average cost (number of instructions) for each lookup is
independent of the number of elements stored in the table. Many hash table designs also allow
arbitrary insertions and deletions of key-value pairs, at (amortized)constant average cost per
operation
In many situations, hash tables turn out to be more efficient than search trees or any other table
lookup structure. For this reason, they are widely used in many kinds of computer software,
particularly for associative arrays, database indexing, caches, and sets.

You might also like