7
78 A New Generalized Data Stacking Programming (GDSP) Model Hala Elhadidy, Rawya Rizk Electrical Engineering Department, Port Said University, Port Said, Egypt [email protected], [email protected] Hassan T. Dorrah Electrical Engineering Department, Cairo University, Giza, Egypt [email protected] AbstractSix classes of the stack were recently introduced for describing the system change pathway under varying environment or events “on and above” the normal situations. Not only can stack store items at the top, but also can store items at the bottom, side(s), as outer ring, inner ring or randomly. The purpose of this paper is to develop the mathematical foundations and their programming algorithms for the necessary handling of the insertion and deletion operations in each of six generalized stacks. A Generalized Data Stacking Programming(GDSP) model is proposed to simulate what happen in the real world. GDSP uses the growing/shrinking matrix based implementation which is a generalization of the known array representation to be another way of implementing the stack. Index TermsGeneralized Data Stacking Programming (GDSP) Model, growing (shrinking) matrices, matrix implementation, mathematical representation, stacking. I. INTRODUCTION Anything in our life can be memorized or accumulated in different types of forms (data, stones, fats, animal decays, layers…etc.) in different types of storage containers (our brains, our body, soil, sea...etc.). Papers, books and photos are stored in a pile form. The dental plaque [2] is another example of the pile form. Seismic activities are the activities which can add or remove items from the bottom of the earth. Also there are many types of marine algae [3] that are found naturally in the bottom of blue water. The soil is very important to our life and its deposits can be from above and bottom. Decayed animals and plant remains in the soil affect its fertility. Tree trunk diameter usually changes during the day and the night and along full year with both a rainy and a dry season [4]. Some people are suffering from different diseases. Atherosclerosis is a disease that causes more death and disability than any other disease and is known by several other names - cholesterol deposits in the arteries[5-8].A kidney stone is a hard, crystalline mineral material formed within the kidney or urinary tract. Formation of a stone in the body is formed by accumulating the sand randomly [9]. All the previous are examples of stacking forms that we classify them into 6 different classes and combined into Fig.1.Stacking is the arrangement of items where the item most recently arrived at the stack is the first to be retrieved. The infinite stacking property will permit accommodating apparently any number of elements in the stack due to its unlimited capacity [10].Stack has lots of applications in many areas e.g. Function Calls; When a subroutine calls another subroutine, it stores its register contents by pushing the contents into a stack. The new function uses the registers. When the program returns to the old function, pop the stack. Data may stay in the stack for a long time [11-15]. Bounded stacks, where we know the maximal size in advance, are readily implemented with bounded arrays. For unbounded stacks we can use unbounded arrays. Array implementation of the stack was traditionally used to represent the various operations done to the stack in its traditional form. The stack was redefined in [1] in more general way that can be connected to the real world. The stack is not only one class but as illustrated in Fig. 1, it has more than one class depending on the place where a new element is inserted. The insertion can be not only to the top as the traditional stack (class S1), but also could be to the bottom (class S2), one or both sides (class S3), the outer ring of the object (class S4), the inner ring of the object (class S5), or randomly anywhere (class S6). Generalized Data Stacking Programming (GDSP) model is defined in this paper. The proposed model is using matrix implementation which replaces array implementation to represent the stack in its new classes. 3D matrix represents the 3D object in which the stack represents. This method is based on growing (or shrinking) matrices which is equivalent to insert (or remove) items to (from) the stack. (a) (b) (c) (d) (e) (f) Fig. 1.Examples of the stack from our life. The paper is organized as follows. Section II presents the stack classes and how these classes represent physical

A new Generalized Data Stacking Programming (GDSP) model

  • Upload
    ps-eng

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

78

A New Generalized Data Stacking Programming

(GDSP) Model

Hala Elhadidy, Rawya Rizk

Electrical Engineering Department, Port Said University,

Port Said, Egypt

[email protected], [email protected]

Hassan T. Dorrah

Electrical Engineering Department, Cairo University,

Giza, Egypt

[email protected]

Abstract—Six classes of the stack were recently introduced for

describing the system change pathway under varying

environment or events “on and above” the normal situations. Not

only can stack store items at the top, but also can store items at

the bottom, side(s), as outer ring, inner ring or randomly. The

purpose of this paper is to develop the mathematical foundations

and their programming algorithms for the necessary handling of

the insertion and deletion operations in each of six generalized

stacks. A Generalized Data Stacking Programming(GDSP) model

is proposed to simulate what happen in the real world. GDSP

uses the growing/shrinking matrix based implementation which

is a generalization of the known array representation to be

another way of implementing the stack.

Index Terms—Generalized Data Stacking Programming

(GDSP) Model, growing (shrinking) matrices, matrix

implementation, mathematical representation, stacking.

I. INTRODUCTION

Anything in our life can be memorized or accumulated in

different types of forms (data, stones, fats, animal decays,

layers…etc.) in different types of storage containers (our

brains, our body, soil, sea...etc.). Papers, books and photos are

stored in a pile form. The dental plaque [2] is another example

of the pile form. Seismic activities are the activities which can

add or remove items from the bottom of the earth. Also there

are many types of marine algae [3] that are found naturally in

the bottom of blue water. The soil is very important to our life

and its deposits can be from above and bottom. Decayed

animals and plant remains in the soil affect its fertility. Tree

trunk diameter usually changes during the day and the night

and along full year with both a rainy and a dry season [4].

Some people are suffering from different diseases.

Atherosclerosis is a disease that causes more death and

disability than any other disease and is known by several other

names - cholesterol deposits in the arteries[5-8].A kidney

stone is a hard, crystalline mineral material formed within the

kidney or urinary tract. Formation of a stone in the body is

formed by accumulating the sand randomly [9].

All the previous are examples of stacking forms that we

classify them into 6 different classes and combined into

Fig.1.Stacking is the arrangement of items where the item

most recently arrived at the stack is the first to be retrieved.

The infinite stacking property will permit accommodating

apparently any number of elements in the stack due to its

unlimited capacity [10].Stack has lots of applications in many

areas e.g. Function Calls; When a subroutine calls another

subroutine, it stores its register contents by pushing the

contents into a stack. The new function uses the registers.

When the program returns to the old function, pop the stack.

Data may stay in the stack for a long time [11-15]. Bounded

stacks, where we know the maximal size in advance, are

readily implemented with bounded arrays. For unbounded

stacks we can use unbounded arrays. Array implementation of

the stack was traditionally used to represent the various

operations done to the stack in its traditional form.

The stack was redefined in [1] in more general way that

can be connected to the real world. The stack is not only one

class but as illustrated in Fig. 1, it has more than one class

depending on the place where a new element is inserted. The

insertion can be not only to the top as the traditional stack

(class S1), but also could be to the bottom (class S2), one or

both sides (class S3), the outer ring of the object (class S4),

the inner ring of the object (class S5), or randomly anywhere

(class S6). Generalized Data Stacking Programming (GDSP)

model is defined in this paper. The proposed model is using

matrix implementation which replaces array implementation

to represent the stack in its new classes. 3D matrix represents

the 3D object in which the stack represents. This method is

based on growing (or shrinking) matrices which is equivalent

to insert (or remove) items to (from) the stack.

(a)

(b)

(c)

(d)

(e)

(f)

Fig. 1.Examples of the stack from our life.

The paper is organized as follows. Section II presents the

stack classes and how these classes represent physical

79

systems. Section III presents the stack classes in more detail

having the mathematical presentation and flow chart to clarify

the idea of these classes based on the proposed matrix

implementation. Section IV presents conclusions and the

future work.

II. DEFINITION OF GENERALIZED STACK CLASSES

System changes in real life may be logically conceived to

be internally stacked in the form of a new sub-layer arranged

in some form in relations to the other preceding existing

layer(s). Such new sub-layers represent the incremental

physical changes or alternations imposed on the original

system basic layer(s) due to the induced effects. There are six

classes of stack as defined and mentioned in [1] and Fig.2.

III. GDSP MODEL

The proposed model depends on the idea of simulating

what happen in the physical world where any object can be a

stack. Also our model depends on the matrix implementation

which is in turn depends on the idea of growing or shrinking

matrices.

A. Growing Matrix Implementation Approach:

Traditionally, the object is represented by an array where

the insertion or deletion is done at one side of the array [10-

15]. As the definition of the stack is become wider and more

general than before, it is needed to find more general way for

implementation. The growing matrix implementation is an

extension to the array one. The insertion is done by adding an

element, (a) row(s), (a) column(s) or both depending on the

class of the stack making the matrix grow (growing matrix).

While the deletion is done by removing an element, (a) row(s),

(a) column(s) or both depending on the class of the stack

making the matrix shrink (shrinking matrix).The following

subsections describe in detail the matrix implementation of

each class but first the model assumptions for the proposed

model are presented.

Fig. 2.The different classes of the stack [1].

B. Model assumptions

1- M[m,n,k] is the stack matrix of the 3 dimensions m x n x k

where m, n and k are integer constants. M represents a file,

figure, picture…etc.

2- A[m,n,k] or B[m,1,k] is a storage matrix and sometimes is

the output matrix.

3- All the elements of the stack are non-negative real numbers.

4- The element we wish to insert is e.We want to insert it at

(a,b) where a ≤ m and b ≤ n.

5- 0 means empty space.

6- Adding or removing a column is done from the left then

right (if the two sides are considered).

7- Adding or removing a ring (inside or outside the object) is

done in the following sequence; left, top, right then

bottom.

C. Class S1(Above, top or upward)

Traditionally, the stack is found in a pile form which is the

first class S1. Obviously, this class can be found in many

applications (e.g. storing data in the computer memory, the

dental plaque as in Fig.1-a). Adding (S1+) or removing (S1

-)

an item from the stack is done from above only as seen in

Fig.3 A and B. Using the matrix representation, the matrix

represents the pile (M(mxn)) and adding an item at the top of

the pile means adding a row at the top of the matrix which

makes the matrix grow (M(m+1,n)). Removing an item from

the top of the pile means removing a row from the top of the

matrix which makes the matrix shrink; M(m-1,n).

Mathematically, for adding an element at the top of the

matrix, we have the following:

A(c+1,r,k)=M(c,r,k) r,c,k ϵ Ⱬ : k=:1→q & r =:1→ n

& c =:1→m (1)A(1,r,k)= e : k=:1→q & r =:1→ n

(2)

where A is the new matrix (m+1,n,q).

For deleting the first row of the matrix:B(c-1,r,k)=M(c,r,k)

r,c,k ϵ Ⱬ : k=:1→q& r =:1→ n

& c =:2→m(3)B is the new matrix (m-1,n,q)

Basic Stack

Adding 2 rows Adding 3 rows

(1)

(3) (4)

(2)Adding a row(2)

Fig. 3A.Inserting operation on stack according to S1.

80

Start

Inputs:

3D Matrix M(m,n,q)

represents the object

and e the new added

element

For each layer, row and column

Move the first row of M to the second

row of a new matrix A, the second

row of M to the third row of A ...etc

leaving the first row of A empty.

Fill the first row of

A with the value e

Output:

Matrix A(m+1,n,q)

which equal to the

matrix M after

adding a new row at

the beginning

End

Start

Inputs:

3D Matrix

M(m,n,q) represents

the object

For each layer, row and column

Move the second row of M to be

the first row of the new matrix B,

the third row of M to be the

second row of B ...etc

Output:

Matrix B(m-1,n,q)

which equal to the

original matrix M

after deleting the

first row

End

Insert Delete

Fig.3B . S1: Flow chart for inserting an item or deleting it.

D. Class S2 (Beneath, bottom and downward)

There are some applications that can store items under

objects (e.g. seismic activities and growing the marine algae

under water). This kind of applications where the insertion or

deletion is done at the bottom is class S2 as seen in Fig.4 A

and B. Applying the matrix method, adding an item means

adding a row at the bottom of the matrix and increment the

size by one (growing M(m+1,n)). While removing an item

means removing a row from the bottom and decrement the

size by one (shrinking M(m-1,n)).

Mathematically;

A(c,r,k)=M(c,r,k) k=:1→q & r =:1→ n& c =:1→m

r,c,k ϵ Ⱬ : (4)

A(m+1,r,k)= e k=:1→q & r =:1→ n (5)

where A is the new matrix (m+1,n,q)

For deleting the last row:

B(c,r,k)=M(c,r,k) r,c,k ϵ Ⱬ : k=:1→q & r =:1→ n

& c =:1→m-1 (6)

Basic Stack(1)

Adding a row(2)

Adding 2 rows(3)

Adding 3 rows(4)

Fig. 4A.Inserting operation on stack according to S2

Start

Inputs:

3D Matrix M(m,n,q)

represents the object

and e the new added

element

For each layer and column, add a

new element e to the new row at the

bottom of M

Output:

Matrix M(m+1,n,q)

which equal to the

original matrix after

adding a new row at

the bottom

End

Start

Inputs:

3D Matrix

M(m,n,q) represents

the object

For each layer, delete the

last row of M

Output:

Matrix M(m-1,n,q)

which equal to the

original matrix M

after deleting last

row

End

Shrinking matrix (Delete S2-)Growing matrix (Insert S2+) Fig.4B. S2: Flow chart for inserting an item or deleting it.

E. Class S3 (Single, double or all sided –external)

The example of the soil (Fig.1-c) which the deposits can

be done in both sides is an example of the third class of the

stack (S3) in which the insertion (S3+) or deletion (S3

-) is done

to a side or the two as described in Fig.5A, B and C. Applying

the matrix method; adding an item using the third class means

adding a column to the left of the matrix then adding another

column to the right and increase the size by two (growing

matrix M(m,n+2)) if the insertion is done in both sides. If the

insertion is done in only one side (the left), the increment will

be by one (M(m,n+1)). While removing an item means

removing a column from the left then right and decrement the

size by two (shrinking M(m,n-2)) in the case of two sides.

However the left column is removed only and decrement by

one if the deletion is done to one side (M(m,n-1)).

Mathematically, if the insertion is done in one side:

A(c,r+1,k)=M(c,r,k) r,c,k ϵ Ⱬ : k=:1→q & r =:1→ n & c

=:1→m (7)

A(c,1,k)= e : k=:1→q & c =:1→ m (8) where

A is the new matrix (m,n+1,q).

If the insertion is done in both sides:

A(c,r+1,k)=M(c,r,k) r,c,k ϵ Ⱬ : k=:1→q & r =:1→ n & c

=:1→m (7')

A(c,1,k)= A(c,n+2,k)= e : k=:1→q & c =:1→ m (8')

where A is the new matrix (m,n+2,q).

If the deletion is done in one side:

B(c,r,k)=M(c,r+1,k) r,c,k ϵ Ⱬ : k=:1→q & r =:1→ n-1 &

c =:1→m (9)

If it is done on both sides:

B(c,r,k)=M(c,r+1,k) r,c,k ϵ Ⱬ : k=:1→q & r =:1→ n-2 &

c =:1→m (9')

81

Ba

sic

Sta

ck

Ad

din

g 2

sid

es

Ad

din

g 4

sid

es

Ad

din

g 6

sid

es

(1) (4)(3)(2)

Fig. 5A. Inserting operation on stack according to S3

Start

Inputs:

3D Matrix M(m,n,q)

represents the object

and e the new added

element

For each layer, row and column

Move the first column of M to the

second column of a new matrix A,

the second column of M to the third

column of A ...etc leaving the first

column of A empty.

Fill the first column of

A with the value e

Output:

Matrix A(m,n+1,q)

which equal to the

matrix M after

adding a new

column at the left

End

Start

Inputs:

3D Matrix

M(m,n,q) represents

the object

For each layer, row and column

Move the second column of M to

be the first column of the new

matrix B, the third column of M to

be the second column of B ...etc

Output:

Matrix B(m,n-1,q)

which equal to the

original matrix M

after deleting the

first column

End

One side (Insert S3+) One side (Delete S3-)

Fig. 5 B. S3: Flow chart for inserting an item or deleting it in one side.

Two sides (Delete S3-)

Start

Inputs:

3D Matrix M(m,n,q)

represents the object

and e the new added

element

For each layer, row and column

Move the first column of M to the

second column of a new matrix A,

the second column of M to the third

column of A ...etc leaving the first

column of A empty.

Fill the first column of A with

the value e and make a new

column at the end with the

value e for each layer

Output:

Matrix A(m,n+2,q) which

equal to the matrix M

after adding two new

columns at the left and

right

End

Two sides (Insert S3+)

Start

Inputs:

3D Matrix

M(m,n,q) represents

the object

For each layer, row and column

Move the second column of M to

be the first column of the new

matrix B, the third column of M to

be the second column of B ...till

the column n-1

Output:

Matrix B(m,n-2,q)

which equal to the

original matrix M

after deleting the

first and the last

column

End

Fig. 5C.S3:Flow chart for inserting an item or deleting it in two sides.

F. Class S4 (Outward, outer or coating)

Furthermore the example of the growing of tree trunk(Fig.

1-d) is an example of the fourth class of the stack (S4) in

which the insertion (S4+) or deletion (S4

-) is done to the four

sides like adding a ring around the object or removing the

outer layer as seen in Fig.6A and B. Applying the growing

matrix method, adding an item using the fourth class means

adding a column to the left then a row up then column to the

right and a row to the bottom of the matrix and increment the

size as follow (growing M(m+2,n+2)). While removing an

item means removing a column from the left then a row from

up then column from the right and a row from the bottom of

the matrix and decrement the size as follow (shrinking M(m-

2,n-2)).

Mathematically;

A(c+1, r+1,k)=M(c,r,k): k=:1→q & r =:1→ n

& c =:1→m (10)

Basic Stack

(4)

(3)(2)(1)

Fig. 6A.Inserting operation on stack according to S4.

Start

Inputs:

3D Matrix M(m,n,q)

represents the

object and e the

new added element

For each layer, row and column

Move each (i,j) element of M to

(i+1,j+1) element of a new matrix A

leaving the first row and the first

column of A empty.

Fill the first column of A with

the value e and make a new

column at the end with the

value e for each layer

Fill the first row of A with the

value e and make a new

row at the end with the

value e for each layer

Output:

Matrix A(m+2,n+2,q)

which equal to the

matrix M after adding an

outer ring around it.

End

Growing matrix (Insert S4+)

Start

Inputs:

3D Matrix M(m,n,q)

represents the

object

For each layer, row and column

beginning from the second row and

second column, Move each (i,j)

element of M to (i-1,j-1) element of

a new matrix B .

Output:

Matrix B(m-2,n-2,q)

which equal to the

matrix M after deleting

the outer ring around it.

End

Shrinking matrix (Insert S4-)

Fig.6 B. S4: Flow chart for inserting an outer ring or deleting it.

82

A(c,1,k)= e where e is the new element : k=:1→q

& c =: 1→m+1 (add a left column) (11)

A(1,r,k) = e : k=:1→q& r =:2→ n+2 (up row)

(12)A(c,6,k) = e : k=:1→q& c =:2→m+2 (right column)

(13)

A(5,r,k) = e : k=:1→q& r =:1→ n+1( bottom row)(14)

A (m+2, n+2,q) is the new produced matrix.

The deletion is done by removing the outer ring of the

matrix M resulting the new matrix B (m-2,n-2, q)

B(c-1,r-1,k)=M(c,r,k) : k=:1→q& r =:2→ n-1

& c =:2→m-1 (15)

G. Class S5 (Inward, inner or lining)

The example of the cholesterol deposits in the arteries

(Fig. 1-e) is an example of the fifth class of the stack (S5) in

which the insertion (S5+) or deletion (S5

-) is done inside the

object beginning from the middle going toward the wall

leaving the middle always empty as seen inFig.7A. It is like

adding or removing an inner ring as describe in the flow chart

in Fig.7B. Applying the matrix method, adding an item using

the fifth class means adding a column to the left then a row up

then column to the right and a row to the bottom of the matrix

and increment the size in the case of the infinite storage as

follow (growing M(m+2,m+2)) or keep the size as it is like the

case of the cholesterol deposits till it blocks the hole inside. To

do so, it is necessary for M to be a square matrix (m,m) with

an empty center. While removing an item means removing a

column from the left then a row from up then column from the

right and a row from the bottom of the empty space that

assumed inside the matrix and decrement the size (shrinking

M(m-2,n-2)).

Basic Stack with a hole inside it

(1) (2)

(4)(3)

Fig. 7A.Inserting operation on stack according to S5.

Start

Inputs:

3D Matrix

M(m,m,q) represents

the object and e the

new added element

Fill the inner ring with the element e

beginning with the left column, top row,

right column then bottom row

Output:

Matrix M(m,m,q) which

equal to the original

matrix after adding an

inner ring around the

empty space.

End

Check for the first empty space

Insert (S5+)

Start

Inputs:

3D Matrix

M(m,m,q) represents

the object.

Clear the content of the inner ring

starting with the value before the first

empty space beginning with the left

column, top row, right column then

bottom row

Output:

Matrix M(m,m,q) which

equal to the original

matrix after deleting the

inner ring around the

empty space.

End

Check for the first empty space

Delete (S5-)

Fig.7 B. S5: Flow chart for inserting an inner ring or deleting it.

Mathematically; assume that M is a square matrix mxm

where m is odd number and the vital condition to resume

working with this stack model is M(m+1

2,m+1

2)=0 which means

that the center of this square has to be empty. If M(m−i

2, m−i

2)=0

i odd number=:-1→m-2; beginning from inside going

outside. Stop this searching for at last M(m−i

2, m−i

2)=0. Take i

calculated and resume.

M(c,m−i

2) = e c =

m−i

2→ m-

m−i

2 +1 (16)

(add left column)

M(m−i

2,r) = e r =

m−i

2+1 → m-

m−i

2 +1 (17)

(upper row)

M(c,m-m−i

2+1) = e c =

m−i

2+1→ m-

m−i

2 +1 (18)

(right column)

M(m-m−i

2+1,r) = e r =

m−i

2+1→ m-

m−i

2(19)

(lower row)

Deleting from a matrix according to S5 is done as follow:

i odd number=:-1→m-2 check if M(m−i

2,m−i

2) ≠ 0 when

stop searching return r=c= m−i

2.

M(c,m−i

2) = 0 c =

m−i

2→ m-

m−i

2 +1 (20)

(remove left column)

M(m−i

2,r) = 0 r =

m−i

2+1 → m-

m−i

2 +1 (21)

(remove upper row)

M(c,m-m−i

2+1) = 0 c =

m−i

2+1→ m-

m−i

2 +1 (22)

(remove right column)

83

M(m-m−i

2+1,r) = 0 r =

m−i

2+1→ m-

m−i

2 (23)

(remove lower row)

H. Class S6 (Within, in-between, or scattered)

The example of the kidney stone (Fig. 1-f) is sixth class of

the stack (S6) in which the insertion (S6+) or deletion (S6

-) is

done by adding it to a specific place or removing it from a

specific place. Applying the matrix method, adding an item

using the sixth class means adding an element at position (a,b)

then rearranging the matrix either horizontally or vertically

according to the application. Arranging either ways is done to

the nearest wall to the new element; arranging horizontally if

the position of the new element is near the right is done by

adding a new column to the right then pushing right the

elements found in row a and column b+1 till the new column

but if the position is near the left, add the new column to the

left to be the first column then push the elements from the new

position till the second column in the row a are pushed one

position to the left as in Fig.8A and B. While removing an

item means deleting it then rearranging the matrix horizontally

without removing any columns but leaving a space at the end

of the column.

Mathematically; Adding e at (a,b) in matrix M horizontally

is done as follow: A(c,r,k) =M(c,r,k) k=: 1 → q&r=: 1→ n &

c=: 1 → m where A is a storage matrix (24)

If b ≥m 2⁄ then

M(a,r,k) = A(a,r-1,k) k=: 1 → q&r=: b → n+1

a,b,r,kϵ Ⱬ (25)

Else

{ M(c,r,k) = A(c,r-1,k) k=: 1 → q&r=: b → n+1 &c =: 1→

m (25')

And M(a,r,k) = A(a,r+1,k) k=: 1 → q&r=: 1 → b-1

a,b,c,kϵ Ⱬ} (26)

In both cases M(a,b,k) = e k=: 1 → q (27)

For deleting an element at (a,b) then rearrange the stack

horizontally; A(c,r,k) =M(c,r,k) k=: 1 → q&r=: 1→ n & c=:

1 → m(28)where A is a storage matrix

If b ≥ n 2⁄ then

{M(a,r,k) = A(a,r+1,k) k=: 1 → q&r=: b → n-1

a,b,c,kϵ Ⱬ (29)

And M(a,n,k) =0} (30)

Else

{M(a,r+1,k) = A(a,r,k) k=: 1 → q&r=: 1 → b-1

r,a,kϵ Ⱬ (29')

And M(a,1,k) =0 }

If the arrangement is vertically, add a new row at the

bottom if the position of the new element is near the bottom

then push down the elements found in column b and row a+1

till the last row. But if the new position is near the top of the

object (matrix), add a new row at the top and push the

elements beginning from the new element to the second row in

the same column (b) one position up as seen in Fig.9A and

Fig.9B shows the flow chart. While removing an item means

removing an element then rearranging the matrix horizontally

or vertically without removing column or row but leaving a

space at the end of the column or the row as follow:

Original Stack

Fig. 8A: Inserting operation on stack according to S6 with horizontally

rearrangement.

Start

Inputs:

3D Matrix M(m,n,q)

represents the object

and e the new added

element to (a,b) position

Output:

Matrix M(m,n+1,q)

which equal to the

original matrix after

adding the new

element e at (a,b)

End

Start

Inputs:

3D Matrix

M(m,n,q) represents

the object

End

Insert (S6+) Horizontally

Add e to the (a,b) position

From the Beginning of the a

row till b column, move the

elements right. Mark the

first element in that row as

empty.

The position (a,b) is

near the left??

Add an empty column at

the left and move the

elements in a row from first

column till the a position

one position left

Add an empty column at

the right and move the

elements in a row from the

b position till the end one

position right

YesNo The position (a,b) is

near the left??

From the b column in the a

row till the end of the row,

move the elements to the

left. Mark the last element in

that column empty.

Output:

Matrix M(m,n,q)

which equal to the

original matrix after

deleting (a,b)

element

YesNo

Delete (S6-) Horizontally

Fig. 8B. S6 with horizontally rearrangement in both inserting and deleting.

If we need to add the element e at position (a,b);

A(c,r,k) =M(c,r,k) k=: 1 → q&r=: 1→ n & c=: 1 →

m(30)where A is a storage matrix

If a ≥ m 2⁄ then M(c,b,k) = A(c-1,b,k) k=: 1 → q&c=: a →

m+1 a,b,c,kϵ Ⱬ (31)

Else{ M(c,r,k) = A(c-1,r,k) k=: 1 → q& c=: a → m+1 &r=:

1→ n c,r,kϵ Ⱬ (31')

And M(c,b,k) = A(c+1,b,k) k=: 1 → q&c=: 1 → a-1

a,b,c,kϵ Ⱬ } (32)In both cases M(a,b,k)

= e k=: 1 → q(33)

For deleting an element at (a,b) then rearrange the stack

vertically;

Original Stack

84

Fig. 9A.Inserting operation on stack according to S6 with vertically

rearrangement.

Start

Inputs:

3D Matrix M(m,n,q)

represents the object

and e the new added

element to (a,b) position

Output:

Matrix M(m+1,n,q)

which equal to the

original matrix after

adding the new

element e at (a,b)

End

Start

Inputs:

3D Matrix

M(m,n,q) represents

the object

End

Insert (S6+) vertically

Add e to the (a,b) position

From the Beginning of the b

column till a row, move the

elements row down. Mark

the first element in the

column as empty.

The position (a,b) is

near the top??

Add an empty row at the

top and move the elements

in b column from first row

till the a position one

position up

Add an empty row at the

bottom and move the

elements in b column from

the a position till the end

one position down

YesNo The position (a,b) is

near the top??

From the a row in the b

column till the end of the

column, move the elements

row up. Mark the last

element in the column

empty.

Output:

Matrix M(m,n,q)

which equal to the

original matrix after

deleting (a,b)

element

YesNo

Delete (S6-) vertically

Fig. 9B.S6 with vertically rearrangement in both inserting and deleting.

A(c,r,k) =M(c,r,k) k=: 1 → q&r=: 1→ n & c=: 1 →

m(34)where A is a storage matrix

If a ≥ m 2⁄ then { M(c,b,k) = A(c+1,b,k) k=: 1 → q&c=: a

→ m-1 a,b,c,kϵ Ⱬ (35)

And M(m,b,k) =0} (37)

Else

{ M(c+1,b,k) = A(c,b,k) k=: 1 → q&c=: 1 → a-1 c,b,kϵ

Ⱬ (35')

And M(1,b,k) =0 }

IV. CONCLUSIONS

Since there are different applications of the stack in our

physical world, it is important to give more attention to the

stack. In this paper, a new Generalized Data Stacking

Programming (GDSP) Model is proposed where the idea of

the stack is discussed. This idea is extended in this model to

be more than a pile kind. It is shown that the GDSP Model can

effectively handle the stack in its six classes which represents

what occur in the real life to any object. The growing matrix

implementation is proposed to model the six classes of the

stack. The mathematical models and algorithms for all the six

classes are then successfully tested using Matlab examples.

More efforts should be done in this work; for example,

focusing on real life applications and apply the proposed

model numerically using real observation data. These

applications could cover many fields such as life sciences,

medicine, biology, engineering..etc.

REFERENCES

[1] Hassen T. Dorrah. Supplement to “Consolidity: Moving

opposite to built-as-usual practices.” Elsevier Ain Shams

Engineering Journal (2013), doi:10.1016/j.asej.2013.2.009.

URL address:

http://www.sciencedirect.com/science/article/pii/S2090447913

000348.

[2] J.S. Nield-Gehrig," Dental Plaque Biofilms," Journal of

Practical Hygiene, 2005

[3]

http://www.aquaticcommunity.com/algae-ontrol/marine.php,

2004.

[4] Y. Aimene, C. Stah, D. Bonal and B. Thibaut," Modelisation

of the trunk daily diameter variation during wet season in a

neotropical rain forest of French Guiana," 6th Plant

Biomechanics Conference – Cayenne, November 16 – 21,

2009.

[5] Dr. Mercola,"The Cholesterol Myth that is Harming Your

Health," article in Mercola.com,

http://articles.mercola.com/sites/articles/archive/2010/08/10/m

aking-sense-of-your-cholesterol-numbers.aspx,

August 10, 2010.

[6] Dr. Mohamed Abo Dawla, “Treatment: Medical Magazine in

Arabic" http://www.al-3laj.com./3 , page 3, May 1st,2012.

[7] Mayo clinic staff, "Cholesterol levels: What numbers should

you aim for?,"http://www.mayoclinic.com/health/cholesterol-

levels/CL00001 , sep. 12, 2012.

[8] "Cholesterol management guide,

"http://www.webmd.boots.com/cholesterol-

management/guide/understanding-cholesterol-problems-basics,

May 11, 2013.

[9] Article in medicine, "Kidney Stone,"

http://www.medicinenet.com/kidney_stone/page3.htm, 14 May

2013.

[10] Steve Skiena, Lecture Notes -- Data Structures

http://www.cs.sunysb.edu/~skiena/214/lectures, 11 September

15:55:14 EDT 1997.

[11] K. Mehlhorn and P. Sanders," Algorithms and Data

Structures," The Basic Toolbox, p.p 295, 2007.

[12] B. R. Preiss," Data Structures and Algorithms with Object-

Oriented Design Patterns in C++," Published by John Wiley &

Sons ISBN 0471-24134-2, 1997.

http://www.brpreiss.com/books/opus4/html 22/4/2013

[13] "Algorithms and Data Structure; Table of Contents",

http://www.cs.auckland.ac.nz/~jmor159/PLDS210/ds_ToC.ht

ml 26/4/2013.

[14] C. A. Shaffer," A Practical Introduction to Data Structures and

Algorithm Analysis Third Edition (C++ Version),"

http://people.cs.vt.edu/~shaffer/Book, January 19, 2010.

[15] Student Support Forum, Wolfram,

http://forums.wolfram.com/student-support/topics/17332,

5/5/2013 at 11:45 pm.