Array is a container which can hold a fix number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms. Following are the important terms to understand the concept of array.
2. Array is a container which can hold a fix
number of items and these items should be of the
same type. Most of the data structures make use of
arrays to implement their algorithms. Following are
the important terms to understand the concept of
array.
Element – Each item stored in an array is
called an element.
Index – Each location of an element in
an array has a numerical index, which is
used
to identify the element.
3. The sequential representation uses an array to store
information corresponding to each node of a tree. Consider
the binary tree shown in Figure 1.1 . Its depth is 5 and it has
fourteen nodes. The nodes are numbered in a special way.
This numbering may obtained by preorder traversing the
tree and as each node is accessed , assigning it a node
number. The root is assigned 1, each left successor of a node
is assigned twice the number of its predecessor, and each
right successor is assigned one more than twice the
number of its predecessor. With nodes numbered in this
way, the predecessor of node i is numbered i/2 (integer
divide), its left successor is numbered 2*i, and its right
successor 2*i+1.
4.
5. A type of list is known as an ordered list. The
structure of an ordered list is a collection of items
where each item holds a relative position that is based
upon some underlying characteristics of the item. The
ordering is typically either ascending or descending
and we assume that list items have a meaningful
comparison operation that is already defined . Many of
the list operations are the same as those of the
unordered list.
6. Stack :
A stack is a linear data structure in which
elements can be inserted and deleted only from
one side of the list, called the top. A stack follows
the LIFO (Last In First Out) principle, i.e., the
element inserted at the last is the first element to
come out. The insertion of an element into stack is
called push operation, and deletion of an element
from the stack is called pop operation. In stack we
always keep track of the last element present in the
list with a pointer called top.
8. Queue:
A queue is linear data structure in which elements
can be inserted only from one side of the list called
rear, and the elements can be deleted only from the
other side called the front . The queue data structure
follows the FIFO (First In First Out) principle, i.e., the
element inserted at first in the list, is the first element
to be removed from the list. The insertion of an
element in a queue is called an enqueue operation
and deletion of an element is called a dequeue
operation.
10. Evaluate an expression represented by a string .
Expression can contain parentheses, you can assume only
binary operations allowed are +, -, *, and /. Arithmetic
expressions can be written in one of three forms :
Infix Notation: Operators are written between the
operands they operate on, e.g. 3+4 .
Prefix Notation: Operators are written before the
operands, e.g. +3 4
Postfix Notation: Operators are written after operands.
11. Up to now we have been concerned only with the
representation of a single stack or a single queue in the
memory of a computer. For these two cases we have
seen efficient sequential data representations.
B(i) = T(i) = [m/n] (i-1),1<i<n
12. A Linked list is a way to store a collection of
elements. Like an array these can be character or
integers. Each element in a linked list is stored in the
form of node.
13. A node is a collection of two sub-elements or parts.
A data part that stores the element and a next part
that stores the link to the node.
14. To represent stacks and queues sequentially. Such a
representation proved efficient if we had only one
stack or one queue. However, When several stacks and
queues co-exist, there was no efficient way to represent
them sequentially. In this section we present a good
solution to this problem using linked list.
15. T(i) = Top of ith stack 1<i<n
F(i) = Front of ith queue 1<i<m
R(i) = Rear of ith queue 1<i<m
Initial conditions:
T(i) = 0 1<i<n
F(i) = 0 1<i<m
Boundary conditions:
T(i) = 0 iff stack i empty
F(i) = 0 iff queue i empty
16. The manipulation of symbolic polynomials, has
become a classical example of the use of list
processing. To represent any number of different
polynomials as long as their combined size does not
exceed our block of memory. In general , we want
represent the polynomial.
A(x) = amxem+……+a1xe1