[PDF] [PDF] Computer Programming - IIT Bombay

Dr Supratik Chakraborty Department of Computer Science and Engineering IIT Bombay Session: Quiz and Practice Questions on Structures 1 Dr Deepak B



Previous PDF Next PDF





[PDF] Question-Paper & Solutions - CSE IIT Kgp

25 nov 2013 · Department of Computer Science and Engineering End-Semester Examination, Autumn 2013-14 Programming and Data Structures (CS 



[PDF] Question-Paper & Solutions - CSE IIT Kgp

30 sept 2013 · Questions have been shuffled across different question papers (c) What will be the output of the program if nMax is initialized to 2K for some 



[PDF] Computer Programming - IIT Bombay

Dr Supratik Chakraborty Department of Computer Science and Engineering IIT Bombay Session: Quiz and Practice Questions on Structures 1 Dr Deepak B



[PDF] C programming I & II

Multiple choice one line questions 1) The C 26) What will be the output of the following program code ? 52) C programming language was developed by



[PDF] Data Structures and Algorithms End-semester exam - CSE - IIT Kanpur

17 juil 2017 · paper material or use any elctronic gadget during the exam (Please do not write C or any other programming language code but pseudo 



[PDF] CS : COMPUTER SCIENCE & INFORMATION TECHNOLOGY CS

Rough work can be done on the question paper itself question paper for rough work 12 What will be the output of the following C program segment?



[PDF] Computer Applications

Test Paper Code: CA Time: 3 This Question Booklet is your Question Paper This Question What is the output of the following C program? void fun (int *p)

[PDF] ikea cigna

[PDF] il 1040 form 2018 pdf

[PDF] il area code map

[PDF] il est en cours de cheminement

[PDF] il faut être de son temps translation

[PDF] il y a combien de continents

[PDF] il y a combien de mois dans une annee

[PDF] il y a combien de personnes dans ta famille

[PDF] ile de france nombre de deces covid

[PDF] ile kcal ma cheeseburger z mc

[PDF] iliad pronunciation guide

[PDF] illegal activities in hotel rooms

[PDF] illegal apartment eviction

[PDF] illegal apartment nyc tenant rights

[PDF] illegal apartment?

IIT Bombay

Computer Programming

Dr. Deepak B Phatak Dr. Supratik Chakraborty Department of Computer Science and Engineering IIT Bombay

Session: Quiz and Practice Questions on Structures

1 Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay

IIT Bombay

Q1. Consider the following structure definition

struct X { int Y; char Z;} varstruct X, the member Y of var is accessed as: (A) X.var.Y (B) var.Y (C) Y.var (D) var.X.Y

2 Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay

Recap Quiz

IIT Bombay

Q2. Which of the following is/are true of

structures defined in C++?

A.All members must have same data type

B.Cannot have arrays as members

C.Cannot have two different members with

same name

D.Cannot have more than 1000 members

3 Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay

Recap Quiz

IIT Bombay

Q3. Consider the structure definition

struct X {int Y, Z;} myVar

X myVar = {0, 1};

the initialized values of members of myVar are: (A)Y: 0, Z: 0 (B) Y: 0, Z: 1 (C) Y: 1, Z: 0 (D) Y: 1, Z: 1

4 Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay

Recap Quiz

IIT Bombay

Q4. Suppose x and y are two variables of

struct myStruct. The assignment statement x = y; (A)Is an illegal statement in C++ (B)Makes the addresses of x and y the same (C) Copies values of all members of y to corresponding members of x (D) None of the above

5 Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay

Recap Quiz

IIT Bombay

Q5. Suppose struct X is a structure with an

int member named Y. The declaration

X abc[10];

declares an array of objects of type struct X.

Which of the following accesses the

member Y of the 5th element of the array? (A) (abc.Y)[5] (B) (abc[5]).Y (C) abc.(Y[5]) (D) abc[Y.5]

6 Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay

Recap Quiz

IIT Bombay

A binary tree is a data structure

(representation of information) in which data items are related by a parent-child relationship as follows:

1.There is a designated data item called

2.Every other data item has a unique parent data item

7 Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay

Practice Question 1

IIT Bombay

3. Every data item has at most 2 children

data items

4. There are designated data items called

items.

8 Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay

Practice Question 1

IIT Bombay

9 Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay

Practice Question 1

root A leaf B leaf leaf

Left child of root Right child of root

Descendant of A

Descendant of A

Descendant of A

Descendant of A

IIT Bombay Practice Question 1

Now consider the following structure definition:

struct TreeNode { int value; int leftChild, rightChild; Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay 10 Value left

Child right

Child

IIT Bombay Practice Question 1

We want to use an array A of objects of type struct

TreeNode to represent a binary tree as follows:

Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay 11 24

3 7 A[0]

334

2 -1 A[3]

227
-1 9 A[7]

IIT Bombay Practice Question 1

You are given an array A of size 100 of objects of struct TreeNode such that AND

The values of A[i].leftChild and A[i].rightChild

are -1 for all i Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay 12

IIT Bombay Practice Question 1A

You are required to write a function

void heapify(TreeNode *A) { // Your code comes here

that fills in the values of leftChild and rightChild members of all elements of A such that it represents a binary tree in which

Value of every node is <= Value of all its descendants

Assume that the root is A[0], and absence of children is indicated by having leftChild (or rightChild) being -1

Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay 13

IIT Bombay Practice Question 1

Solve the same question as before but now with the additional requirement that we must maximize the number of tree nodes with two children. Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, IIT Bombay 14quotesdbs_dbs11.pdfusesText_17