Professional Documents
Culture Documents
( #( _ _
S #(S _ _
- #(- S 1
A #(-A S _
) # SA- 1
/ #/ SA- 1
( #/( SA- 1
D #/(D SA- _
+ #/(+ SA-D 2
Y #/(+Y SA-D 1
↑ #/(+ ↑ SA-DY _
) #/ SA-DY ↑ +
1
+ #+ SA-DY ↑ +/
1
R #+R SA-DY ↑ +/
_
⏎ # SA-DY ↑ +/RK*+
1
1
Q1)B: Evaluate the expressions below then write their original forms:
a) 4 5 8 * + 12 3 / −
b) 10 8 − 5 27 3 / * +
Answer:
a) 4 5 8 * + 12 3 / -
i) 4 40 + 12 3 / -
ii) 44 12 3 / -
iii) 44 4 -
iv) 40
Its original form is:
4 + 5 * 8 − 12 / 3
b) 10 8 - 5 27 3 / * +
i) 2 5 27 3 / * +
ii) 2 5 9 * +
iii) 2 45 +
Its original form is:
10 - 8 + 5 * 27 / 3
Q2)A: Brie y explain the main characteristics and properties of an array
Answer:
An array is a set of elements that are homogeneous, which means of the same type.
Ordered, which means there is a first, second, third …. Elements. Finite, which means there
must be a last element. Fixed size, which means that the size must be defined when the
program is written and cannot be changed while executing and the insertion and deletion
operations are not allowed, but changing values of the elements is permitted. The array
takes consecutive memory locations.
Q2)B: Assume that 8 bytes are required to hold each element of the array with 5 rows and
6 columns.
1. Compute the total area needed to store the array
2. Use the row major formula to nd the location of the element before the last one
Answer:
1. Size of the array = Rows * Columns
Size of the array = 5 * 6 = 30
Area needed = size * cells
Area needed = 30 * 8 = 240 bytes required
2
3
To delete to the linked list that is represented as a Queue, we delete from the Front:
1. [Delete the node at the front and store it at a variable (deletedNode)]
deletedNode ← Front
Front ← link(Front)
link(deletedNode) ← avail
avail ← deletedNode
2. [Return the deletedNode to the availability list]
link(deletedNode) ← avail
avail ← deletedNode
3. [finished] exit
Q4) A: State all the cases to count number of elements reside in Circular Queue
Answer:
Q4) B: De ne then compare between Static and Dynamic Variables
Answer:
Static Variables: They are the variables that are fixed in size, which means after defining
them their size cannot be changed and the compiler has to know their size initially, which
means insertion and deletion operations are not permitted. All the primitive data
types(Integer, Real, Characters and arrays) are static.
Dynamic Variables: They are variables that can be dynamically resized while executing the
program, which means insertion and deletion operations are permitted and this means
they can grow and shrink in size. List and files(batch) are dynamic.