May 2018 - CBSGS
Contents
The questions below are the paper as the University of Mumbai set it at the May 2018 - CBSGS examination, in the order it was set.
MarksPage
MarksPage
The Paper as Set
The questions in this volume are the questions asked at the May 2018 - CBSGS examination, reproduced as the University of Mumbai set them, in the order it set them. Nothing has been reworded, added or left out. Only the answers are ours. See the original question paper.
Duration 3 hours · Total marks 80 · 18 questions answered
How to use this volume
Solve the paper first, under exam conditions and against the clock. Then read the answers here and mark your own. Reading a solution before attempting the question feels productive and teaches very little, because recognising an answer is not the same as being able to write one.
Q. 1
Q1 20 Marks
a.Define algorithm. Write algorithm to calculate Fibonacci series.[4]
Answer
For full marks, cover: a definition of an algorithm with its properties, the Fibonacci series and its rule, the algorithm in numbered steps, and a program that follows the steps, with a sample run.
Algorithm
An algorithm is a finite sequence of clear, unambiguous steps that takes some input and produces the required output. A correct algorithm has a definite start and end, each step can be carried out exactly, and it finishes after a finite number of steps.
Fibonacci series
The series begins 0, 1, and each later term is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, 13, and so on.
Algorithm to print the first n terms
- Start.
- Read n, the number of terms.
- Set a = 0, b = 1 and i = 1.
- If i > n, go to step 9.
- Print a.
- Set c = a + b, then a = b and b = c.
- Set i = i + 1.
- Go to step 4.
- Stop.
Program following the steps
#include <stdio.h>
int main(void)
{
int n, i;
long long a = 0, b = 1, c;
printf("Enter the number of terms (1 to 91): ");
scanf("%d", &n);
if (n < 1 || n > 91) {
printf("The number of terms must be from 1 to 91\n");
return 0;
}
printf("Fibonacci series:");
for (i = 1; i <= n; i++) {
printf(" %lld", a);
c = a + b;
a = b;
b = c;
}
printf("\n");
return 0;
}
Sample run
Enter the number of terms (1 to 91): 10
Fibonacci series: 0 1 1 2 3 5 8 13 21 34
For n terms the loop also works out c, the term after the last one printed. Writing F(0) = 0 and F(1) = 1, F(92) = 7540113804746346429 is the largest Fibonacci number that fits in a long long, whose largest value is 9223372036854775807. For 91 terms the last c is F(92); for 92 terms it would be F(93), which does not fit, so the program accepts up to 91 terms.
Conclusion. An algorithm is a finite, exact list of steps from input to output. The Fibonacci algorithm keeps the last two terms in a and b, prints a, and moves on with c = a + b, a = b, b = c; for 10 terms it gives 0 1 1 2 3 5 8 13 21 34.
The rest of the answers
You have read the paper as it was set and its first answer in full.
Every other answer, in every solved paper of this semester, opens with the solved papers.
Already bought it? Sign in and it opens.
What do you need?
Tap one.
The answers are on this page
You can read the first answer here. The box further down shows how to read all of them.
Read it here, any time
We keep checking and updating our papers and notes, and adding more. A saved copy would be an old version. Reading on munotes.in always gives you the latest one.
I paid, but I can't open it
Please type an email, or a 10-digit phone number.
Done
If we find your payment, we send a link to the email you paid with. Open it to read.
Check your email in 2 minutes. Also check Spam.
No email after 10 minutes?
Something else
Please write a little more, so we can help.
Your email app opens with this. You can add more there. We reply by email.
Found an error in this volume? Report it and we will check it against the paper.
Tip: use the left and right arrow keys to turn papers.