You are on page 1of 2

COMSATS Institute of Information Technology (Virtual Campus)

Subject: Data Structures CSC211


Sessional I (Spring 2016)
MARKS: 10

TIME: 01 Hour

INSTRUCTIONS:

Attempt all questions.

Write to the point answers, and all questions carry equal marks.

Its open book and if found copied, then straight ZERO will be given.

---------------------------------------------------------------------------------------------------------------------

1. Briefly explain in your own words that why data structures are required?

(2)

2. How we can measure the efficiency of a program?

(2)

3. Do we need fast machines or fast algorithms? Explain in your own words.

(2)

4. Write the output of the given program.

(2)

int foo [] = {1, 2, 2, 11, 21, 22, 32, 33, 43, 44, 45, 55};
int n, result=0;
int main ()
{
for ( n=0 ; n<10 ; ++n )
{
result += foo[n];
}
cout<<result;
return 0;
}

Page 1 of 2

5. Write the output of the given program.

(2)

void increment_all (int* start, int* stop)


{
int * current = start;
while (current != stop)
{
++(*current);
++current;
}
}
void print_all (const int* start, const int* stop)
{
const int * current = start;
while (current != stop)
{
cout<< *current << '\n';
++current;
}
}
int main ()
{
int numbers[] = {1,11,111};
increment_all (numbers,numbers+3);
print_all (numbers,numbers+3);
return 0;
}

--------------------------------------------------------------------------------------------------------------------Good Luck

Page 2 of 2

You might also like