Page 353 - C++
P. 353
CBSE AISSCE 2017-2018 Marking Scheme for Computer Science
(2018-2019 Sub Code: 083 Paper Code: 91)
address of the element Data[10][5], if the element Data[15][10] is stored at the
memory location 15000.
Ans LOC(Data[10][5]) = LOC(Data[15][10])+2(15*(10-15)+(5-10))
= 15000 + 2((-75) + (-5))
= 15000 + 2(-80)
= 15000 - 160
= 14840
OR
LOC(Data[I][J]) = Base(Data)+W*(NC*(I-LBR)+(J-LBC))
Taking LBR=0, LBC=0
LOC(Data[15][10]) = Base(Data)+2*(15*15+10)
15000 = Base(Data)+2*(15*15+10)
Base(Data) = 15000 - 2*(235)
Base(Data) = 15000 - 470
Base(Data) = 14530
LOC(Data[10][5])= 14530 + 2*(10*15+5)
= 14530 + 2*(155)
= 14530 + 310
= 14840
OR
LOC(Data[I][J]) = Base(Data)+W*(NC*(I-LBR)+(J-LBC))
Taking LBR=1, LBC=1
LOC(Data[15][10]) = Base(Data)+2*(15*14+9)
15000 = Base(Data)+2*(15*14+9)
Base(Data) = 15000 - 2*(219)
Base(Data) = 15000 - 438
Base(Data) = 14562
LOC(Data[10][5])= 14562 + 2*(15*9+4)
= 14562 + 2*(139)
= 14562 + 278
= 14840
(1 Mark for writing correct formula (for Row major)
OR substituting formula with correct values)
(1 Mark for correct step calculations)
(1 Mark for final correct address)
NOTE:
● Marks to be awarded for calculating the address taking LBR and LBC = 1
(d) Write the definition of a member function AddPacket() for a class QUEUE in C++, 4
to remove/delete a Packet from a dynamically allocated QUEUE of Packets
considering the following code is already written as a part of the program.
struct Packet
{
int PID;
Page #11/35