0% found this document useful (0 votes)
5 views3 pages

DP1 paper

The document is a summative assessment for a computer science course at the Aga Khan Academy Hyderabad, dated September 27, 2022, for Grade DP2. It includes questions on data types, stack operations, and the implementation of stacks and queues using arrays and linked lists. Additionally, it covers direct access to array elements and the requirement for uniform data types in arrays.

Uploaded by

Mehabunnisa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

DP1 paper

The document is a summative assessment for a computer science course at the Aga Khan Academy Hyderabad, dated September 27, 2022, for Grade DP2. It includes questions on data types, stack operations, and the implementation of stacks and queues using arrays and linked lists. Additionally, it covers direct access to array elements and the requirement for uniform data types in arrays.

Uploaded by

Mehabunnisa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

The Aga Khan Academy Hyderabad

Unit – ADS
Summative Assessment
Sub: CS Date: 27/09/22
Grade: DP2 Marks: 20

Q1. Identify the data type of SAME, and predict the output logic and create the trace table. [4M]

HALF <-- LENGTH div 2

MIDDLE <-- HALF + 1

for POSITION <-- 1 upto HALF do

SAME <-- DATA[MIDDLE+POSITION] = DATA[MIDDLE-POSITION]

if SAME then

COUNT <-- COUNT + 1

End if

end for

DATA is an integer array containing [9 3 1 0 1 4 9]

LENGTH is an integer variable containing 7, and

COUNT is an integer variable initially containing 0.

Q2. Outline 2 uses of stacks in computer system and explain what are the stack operations? [4M]

Q3. 18. Arrays or linked lists can be used to implement stacks and queues. [5M]
(a) State when you would use an array to implement a stack or a queue. [1 mark]

(b) Describe the advantage of using an array to implement a stack or a queue. [1 mark]

(c) Describe the advantage of a linked list to implement a stack or a queue. [1 mark]

(4) Using diagrams, show how you would add and delete items from a stack

implemented using a linked list. [2 marks]


Q

Consider the following Java data structure.

A[ ] = {34,56,67,78,1,2,3,99};

(a) State the name of the data structure. [1 mark]

(b) Outline how the data value 78 can be directly accessed. [1 mark]

(c) Explain why all elements of an array must be of the same data type. [2 marks]

You might also like