You are on page 1of 4

3/25/2020 An Introduction To Programming Through C++ - - Unit 10 - Week 8

Assessment submitted.
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)
X

iamraihan00@gmail.com 

NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL) » An Introduction To Programming Through C++

(course)

Announcements (announcements)

About the Course (https://swayam.gov.in/nd1_noc20_cs53/preview) Ask a Question (forum)

Progress (student/home) Mentor (student/mentor)

Unit 10 - Week 8

Course Thank you for taking the Week 8


outline
Quiz.
How does an
NPTEL online

Week 8 Quiz
course work?

Week 0
Your last recorded submission was on 2020-03-25, 15:49 Due date: 2020-03-25, 23:59 IST.
IST
Week 1
1) Consider the following code.
Week 2 char buffer[80];
cin >> buffer;
Week 3 cout << buffer;
Assume the user types "Sachin Tendulkar" without the quotes as the input. What will be printed?
Week 4

Sachin
Week 5
1 point
Week 6 2) Consider the following code.
char buffer[80];
Week 7 cin.getline (buffer,80);
cout << buffer;
Week 8 Assume the user types "Sachin Tendulkar" without the quotes as the input. What will be printed?

Lecture 17 : Sachin Tendulkar


More on
1 point
Arrays : Part 1
: Textual data

https://onlinecourses.nptel.ac.in/noc20_cs53/unit?unit=93&assessment=211 1/4
3/25/2020 An Introduction To Programming Through C++ - - Unit 10 - Week 8

(unit?
Assessment submitted.
unit=93&lesson=111)
X
Lecture 17 :
More on
Arrays : Part 2 Consider the following program
: Functions on int main(int argc, char *argv[]){
character for (int i=0; i<argc; i++)
strings (unit? cout << argv[i] << endl;
unit=93&lesson=112)
}
Lecture 17 : Suppose it is invoked from the command line as:
More on ./a.out On Education
Arrays : Part 3
: Two 3) What will the value of 'argc' be?
dimensional
arrays (unit?
7
unit=93&lesson=113) 1 point

Lecture 17 : 4) What will the value of 'argv[1][1]' be? Write without placing quotes etc. Do not write additional
More on spaces in the answer.
Arrays : Part 4
: Command
Line
1 point
Arguments
(unit?
unit=93&lesson=114)

Lecture 18 :
Arrays and Given below is the code for binary search from the lecture, with small modifications; a couple of
recursion :
original lines are commented out & new lines have been added in their place".
Part 1 : Binary
//bool Bsearch(int A[], int S, int L, int x){
Search
Introduction int Bsearch(int A[], int S, int L, int x){
(unit? // if(L == 1) return A[S] == x;
unit=93&lesson=115) if(L == 1) return S;
int H = L/2;
Lecture 18 :
if(x < A[S+H])
Arrays and
recursion :
return Bsearch(A, S, H, x);
Part 2 : Binary else
search return Bsearch(A, S+H, L-H, x);
analysis (unit? }
unit=93&lesson=116)
5) Suppose we do binary search (as in the lecture) on an array of size 100000. The 1 point
Lecture 18 : number of array elements that x will be compared with will be about
Arrays and
recursion : 10
Part 3 :
17
Mergesort
overview (unit? 20
unit=93&lesson=117) 1000000
Lecture 18 :
6) Tn = 2Tn/2 + n and T1 = 0. W hat is the value of T64 ?
Arrays and
recursion :
Part 4 : Merge
384
function (unit?
unit=93&lesson=118) 1 point

https://onlinecourses.nptel.ac.in/noc20_cs53/unit?unit=93&assessment=211 2/4
3/25/2020 An Introduction To Programming Through C++ - - Unit 10 - Week 8

Lecture 18 : 7) The function merge discussed in the lecture does 2 kinds of comparison: inter key (i.e. 1 point
Assessment submitted.
Arrays and between U[uf] and V[vf]) and inter indices (i.e. between uf,vf,Lu,Lv). For which of the cases below
X recursion : will the number of inter key comparisons be largest?
Part 5 :
Mergesort U={1,2,3}, V={4,5,6}
conclusion
U={1,5,6}, V={2,3,4}
(unit?
unit=93&lesson=119) U={1,3,6}, V={2,4,5}
U={1,2,5}, V={3,4,6}
Download
Videos (unit?
unit=93&lesson=184)

Weekly
Feedback
(unit? A two dimensional array is useful for storing image. If we have a black and white image with m
unit=93&lesson=196) rows each having n pixels, this is easily represented using a bool array A[m][n], where true
indicates black colour and false indicates white. The following code counts the number of
Quiz : Week 8
Quiz vertical lines in a picture. A vertical line is a
(assessment? contiguous sequence of black pixels, one below the other, of any positive length, terminated on
name=211) either end by a white pixel or by the end of the picture. A vertical line can even be just one pixel
in length.
Week 8
int found=0;
Programming
Assignment 1
for(int i=0; i<m; i++)
for(int j=0; j<n; j++)
(/noc20_cs53/progassignment?
name=212) //beginning of inner iteration
if(A[i][j]){
Week 8
found++;
Programming
for(int k=i; k<m; k++){
Assignment 2
(/noc20_cs53/progassignment? if(A[k][j]) A[k][j] = false;
name=213) else break;
}
Week 8
}
Programming
cout << found << endl;
Assignment 3
(/noc20_cs53/progassignment?
8) Suppose that originally the image A contained 5 vertical lines. Consider the point in time 1 point
name=214)
when control reaches the beginning of the inner iteration, and i=25, j=16, and found = 2.
Which of the following is true?
Week 9

A[10][40] must be false.


A[10][40] must be true.
A[10][40] may be true or false, we do not know which based on what is given.

9) Which of the following is true? 1 point

A[25][40] must be false.


A[25][40] must be true.
A[25][40] may be true or false, we do not know which based on what is given.

10)How many vertical lines will be present in the image at this point?

2
1 point

https://onlinecourses.nptel.ac.in/noc20_cs53/unit?unit=93&assessment=211 3/4
3/25/2020 An Introduction To Programming Through C++ - - Unit 10 - Week 8

You may submit any number of times before the due date. The final submission will be
Assessment submitted. considered for grading.
X
Submit Answers

https://onlinecourses.nptel.ac.in/noc20_cs53/unit?unit=93&assessment=211 4/4

You might also like