02/07/2020 An Introduction To Programming Through C++ - - Unit 10 - Week 8
https://onlinecourses.nptel.ac.in/noc20_cs53/unit?unit=93&assessment=211 1/4
X
NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL)
» An Introduction To Programming Through C++(course)
Unit 10 - Week 8
(https://swayam.gov.in)
(https://swayam.gov.in/nc_details/NPTEL)Announcements (announcements) About the Course (https://swayam.gov.in/nd1_noc20_cs53/preview) Ask a Question (forum) Progress (student/home) Mentor (student/mentor)
Course outline
How does an NPTEL online course work?
Week 0 Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Week 8 Lecture 17 : More on Arrays : Part 1 : Textual data (unit?
unit=93&lesson=111)
Due on 2020-03-25, 23:59 IST.
1)
1 point 2)
Week 8 Quiz
The due date for submitting this assignment has passed.
As per our records you have not submitted this assignment.
Consider the following code.
char buffer[80];
cin >> buffer;
cout << buffer;
Assume the user types "Sachin Tendulkar" without the quotes as the input. What will be printed?
No, the answer is incorrect.
Score: 0
Accepted Answers:
(Type: String) Sachin
Consider the following code.
char buffer[80];
cin.getline (buffer,80);
cout << buffer;
Assume the user types "Sachin Tendulkar" without the quotes as the input. What will be printed?
No, the answer is incorrect.
Score: 0
Accepted Answers:
(Type: String) Sachin Tendulkar
02/07/2020 An Introduction To Programming Through C++ - - Unit 10 - Week 8
https://onlinecourses.nptel.ac.in/noc20_cs53/unit?unit=93&assessment=211 2/4
Lecture 17 : More on Arrays : Part 2 :
Functions on character strings (unit?
unit=93&lesson=112) Lecture 17 :
More on Arrays : Part 3 : Two dimensional arrays (unit?
unit=93&lesson=113) Lecture 17 :
More on Arrays : Part 4 :
Command Line Arguments (unit?
unit=93&lesson=114) Lecture 18 :
Arrays and recursion : Part 1 : Binary Search Introduction (unit?
unit=93&lesson=115) Lecture 18 :
Arrays and recursion : Part 2 : Binary search analysis (unit?
unit=93&lesson=116) Lecture 18 :
Arrays and recursion : Part 3 : Mergesort overview (unit?
unit=93&lesson=117) Lecture 18 :
Arrays and recursion : Part 4 : Merge function (unit?
unit=93&lesson=118) Lecture 18 :
Arrays and recursion : Part 5 : Mergesort conclusion (unit?
unit=93&lesson=119) Download
Videos (unit?
unit=93&lesson=184)
1 point
3)
1 point 4)
1 point
1 point 5)
Consider the following program int main(int argc, char *argv[]){
for (int i=0; i<argc; i++) cout << argv[i] << endl;
}
Suppose it is invoked from the command line as:
./a.out On Education
What will the value of 'argc' be?
No, the answer is incorrect.
Score: 0
Accepted Answers:
(Type: Numeric) 3
What will the value of 'argv[1][1]' be? Write without placing quotes etc. Do not write additional spaces in the answer.
No, the answer is incorrect.
Score: 0
Accepted Answers:
(Type: String) n
Given below is the code for binary search from the lecture, with small modifications; a couple of original lines are commented out & new lines have been added in their place".
//bool Bsearch(int A[], int S, int L, int x){
int Bsearch(int A[], int S, int L, int x){
// if(L == 1) return A[S] == x;
if(L == 1) return S;
int H = L/2;
if(x < A[S+H])
return Bsearch(A, S, H, x);
else
return Bsearch(A, S+H, L-H, x);
}
Suppose we do binary search (as in the lecture) on an array of size 100000. The number of array elements that x will be compared with will be about
10 17 20 1000000
N h i i
02/07/2020 An Introduction To Programming Through C++ - - Unit 10 - Week 8
https://onlinecourses.nptel.ac.in/noc20_cs53/unit?unit=93&assessment=211 3/4
Week 9 Week 10 Week 11 Week 12 Text Transcripts
Weekly Feedback (unit?
unit=93&lesson=196) Quiz : Week 8 Quiz
(assessment?
name=211) Week 8 Programming Assignment 1
(/noc20_cs53/progassignment?
name=212) Week 8 Programming Assignment 2
(/noc20_cs53/progassignment?
name=213) Week 8 Programming Assignment 3
(/noc20_cs53/progassignment?
name=214)
6)
1 point 1 point 7)
1 point 8)
No, the answer is incorrect.
Score: 0
Accepted Answers:
17
No, the answer is incorrect.
Score: 0
Accepted Answers:
(Type: Numeric) 384
The function merge discussed in the lecture does 2 kinds of comparison: inter key (i.e.
between U[uf] and V[vf]) and inter indices (i.e. between uf,vf,Lu,Lv). For which of the cases below will the number of inter key comparisons be largest?
U={1,2,3}, V={4,5,6}
U={1,5,6}, V={2,3,4}
U={1,3,6}, V={2,4,5}
U={1,2,5}, V={3,4,6}
No, the answer is incorrect.
Score: 0
Accepted Answers:
U={1,3,6}, V={2,4,5}
U={1,2,5}, V={3,4,6}
A two dimensional array is useful for storing image. If we have a black and white image with m 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 vertical lines in a picture. A vertical line is a
contiguous sequence of black pixels, one below the other, of any positive length, terminated on either end by a white pixel or by the end of the picture. A vertical line can even be just one pixel in length.
int found=0;
for(int i=0; i<m; i++) for(int j=0; j<n; j++)
//beginning of inner iteration if(A[i][j]){
found++;
for(int k=i; k<m; k++){
if(A[k][j]) A[k][j] = false;
else break;
} }
cout << found << endl;
Suppose that originally the image A contained 5 vertical lines. Consider the point in time when control reaches the beginning of the inner iteration, and i=25, j=16, and found = 2.
Which of the following is true?
A[10][40] must be false.
= 2 + 𝑛 𝑎𝑛𝑑 = 0. 𝑊 ℎ𝑎𝑡 𝑖𝑠 𝑡ℎ𝑒 𝑣𝑎𝑙𝑢𝑒 𝑜𝑓 ?
𝑇
𝑛𝑇
𝑛/2𝑇
1𝑇
6402/07/2020 An Introduction To Programming Through C++ - - Unit 10 - Week 8
https://onlinecourses.nptel.ac.in/noc20_cs53/unit?unit=93&assessment=211 4/4
1 point 9)
10)
1 point A[10][40] must be true.
A[10][40] may be true or false, we do not know which based on what is given.
No, the answer is incorrect.
Score: 0
Accepted Answers:
A[10][40] must be false.
Which of the following is true?
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.
No, the answer is incorrect.
Score: 0
Accepted Answers:
A[25][40] may be true or false, we do not know which based on what is given.
How many vertical lines will be present in the image at this point?
No, the answer is incorrect.
Score: 0
Accepted Answers:
(Type: Numeric) 3