Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

Similar documents
Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

TREES. Trees - Introduction

Trees. (Trees) Data Structures and Programming Spring / 28

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

Code No: R Set No. 1

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

Binary Trees, Binary Search Trees

An Introduction to Trees

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE

First Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...

Data Structures Question Bank Multiple Choice

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

Prepared By: Ms. Nidhi Solanki (Assist. Prof.) Page 1

Leftist Heaps and Skew Heaps. (Leftist Heaps and Skew Heaps) Data Structures and Programming Spring / 41

Data Structure and Algorithm, Spring 2013 Midterm Examination 120 points Time: 2:20pm-5:20pm (180 minutes), Tuesday, April 16, 2013

1 P a g e A r y a n C o l l e g e \ B S c _ I T \ C \

Tree traversals and binary trees

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

Operations on Heap Tree The major operations required to be performed on a heap tree are Insertion, Deletion, and Merging.

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

DATA STRUCTURES AND ALGORITHMS

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

Sample Question Paper

INSTITUTE OF AERONAUTICAL ENGINEERING

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

Computer Science Foundation Exam. Dec. 19, 2003 COMPUTER SCIENCE I. Section I A. No Calculators! KEY

Data Structures and Algorithms for Engineers

CS-301 Data Structure. Tariq Hanif

DYNAMIC MEMORY ALLOCATION AND DEALLOCATION

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

12 Abstract Data Types

CS301 - Data Structures Glossary By

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

CS24 Week 8 Lecture 1

Formal Languages and Automata Theory, SS Project (due Week 14)

March 20/2003 Jayakanth Srinivasan,

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

Answers. 1. (A) Attempt any five : 20 Marks

Lec 17 April 8. Topics: binary Trees expression trees. (Chapter 5 of text)

S.E. Sem. III [CMPN] Data Structures. Primitive Linear Non Linear

Stack. 4. In Stack all Operations such as Insertion and Deletion are permitted at only one end. Size of the Stack 6. Maximum Value of Stack Top 5

a) State the need of data structure. Write the operations performed using data structures.

Bharati Vidyapeeth s College Of Engineering for Women Pune-43 Department E & TC. SE- Unit Test I Subject-DS

Revision Statement while return growth rate asymptotic notation complexity Compare algorithms Linear search Binary search Preconditions: sorted,

Bioinformatics Programming. EE, NCKU Tien-Hao Chang (Darby Chang)

CP2 Revision. theme: dynamic datatypes & data structures

Table of Contents. Chapter 1: Introduction to Data Structures... 1

Linear Data Structure

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

8. Write an example for expression tree. [A/M 10] (A+B)*((C-D)/(E^F))

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours

CS DATA STRUCTURES AND ALGORITHMS

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures

Algorithms. AVL Tree

Data Structure Advanced

NET/JRF-COMPUTER SCIENCE & APPLICATIONS. Time: 01 : 00 Hour Date : M.M. : 50

DS ata Structures Aptitude

Objective Questions for Online Practical Exams under CBCS Scheme Subject: Data Structure-I (CS-113)

A. Year / Module Semester Subject Topic 2016 / V 2 PCD Pointers, Preprocessors, DS

CMSC351 - Fall 2014, Homework #2

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

4. Trees. 4.1 Preliminaries. 4.2 Binary trees. 4.3 Binary search trees. 4.4 AVL trees. 4.5 Splay trees. 4.6 B-trees. 4. Trees

Department of Computer Science and Technology

Tree: non-recursive definition. Trees, Binary Search Trees, and Heaps. Tree: recursive definition. Tree: example.

Data Structure & Algorithms Laboratory Manual (CS 392)

S.E. Sem. III [INFT] Data Structures & Analysis. Primitive Linear Non Linear

CS 171: Introduction to Computer Science II. Binary Search Trees

CSCE 2014 Final Exam Spring Version A

ASSIGNMENTS. Progra m Outcom e. Chapter Q. No. Outcom e (CO) I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n))

Algorithm Class. C C++ DS JAVA DATA STRUCTURES TRAINING INSTITUTE KPHB HYDERABAD. Mobile:

Analysis of Algorithms

CSL 201 Data Structures Mid-Semester Exam minutes

Visit ::: Original Website For Placement Papers. ::: Data Structure

DATA STRUCTURES AND ALGORITHMS

Cpt S 122 Data Structures. Data Structures Trees

Data Structures Brett Bernstein

Algorithms & Data Structures

Recursive Data Structures and Grammars

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

Operators & Expressions

WYSE Academic Challenge State Finals Computer Science 2007 Solution Set

Summer Final Exam Review Session August 5, 2009

We have the pointers reference the next node in an inorder traversal; called threads

Basic Data Structures (Version 7) Name:

Question Bank Subject: Advanced Data Structures Class: SE Computer

Q1 Q2 Q3 Q4 Q5 Q6 Total

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

There are many other applications like constructing the expression tree from the postorder expression. I leave you with an idea as how to do it.

Introduction to Linked List: Review. Source:

Chapter 9 binary tree

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

9/29/2016. Chapter 4 Trees. Introduction. Terminology. Terminology. Terminology. Terminology

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

MLR Institute of Technology

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

Stacks, Queues and Hierarchical Collections

Transcription:

Serial : 1PT_CS_A+C_Programming & Data Structure_230918 Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: E-mail: info@madeeasy.in Ph: 011-45124612 CLASS TEST 2018-19 COMPUTER SCIENCE & IT Subject : Programming & Data Structure Date of test : 23/09/2018 Answer Key 1. (b) 7. (c) 13. (b) 19. (a) 25. (b) 2. (a) 8. (a) 14. (c) 20. (a) 26. (b) 3. (d) 9. (c) 15. (a) 21. (b) 27. (d) 4. (c) 10. (b) 16. (b) 22. (a) 28. (c) 5. (c) 11. (b) 17. (c) 23. (a) 29. (c) 6. (c) 12. (c) 18. (a) 24. (c) 30. (c)

8 Computer Science & IT Detailed Explanations 1. (b) In this ordering of {2, 6} and ordering of {1, 3, 5, 7} do not matter. We can see that resulting binary tree is perfectly balance that is a AVL tree. 2. (a) In this code while (current) is used to run the loop until null is encountered i.e. linked list is finished. 1 st for loop to reach the M th position node in linked list. If M th position present then run further otherwise not. 2 nd for loop delete N nodes from M th position from linked list and connect further nodes to M th position node to (N+1) th position node. So code will return linked list after deleting N nodes from M th position in the linked list. 3. (d) We have pre-oder traversal and the tree is binary search tree. So in-oder traversal of binary search tree is ascending oder. Using the in-oder and pre-oder two we can construct binary search tree with Θ(n log n) [we can apply binary search]. 4. (c) str 0 1 2 3 4 5 6 7 8 9 10 11 m a d e e a s y 2 0 1 6 \0 Inside run( ). Pointer str2 is initialized as str1 and str1 is moved till \0 is reached. So str1 will increment by 12 then 12 0 = 12 will return. 5. (c) S1: Inserting n elements in empty binary heap take O(n) time because build heap method take O(n). S2: BFS algorithm take O(m + n) time to find number of connected components in undirected graphs of n vertices and m edges. 6. (c) Static allocation is used for global variable because they are created at compile time. Stack allocation is used for local variables. Heap allocation is used for dynamic data structure. 7. (c) Binary search on array take O(log (n)) time because random access is possible on array but binary search on linked list take O(n) time because random access is not possible. Merge sort on array has more space complexity because it is outplace (i.e. take extra space) but merge sort on linked list take less space because it is inplace (i.e. not take extra space). 8. (a) Insertion of record in double linked list A maximum 4 pointer when record insert at between two node. a b c e 2 1 3 4 6 5 7 A 1 d = prev = e prev; 2 d next = c = c next; 3 d prev next = d next prev; 4 d next prev = d prev next; 1 2 d 3 4 Deletion of record in double linked list A maximum 2 pointer when record deleted from middle of linked list. a b c d e A

CT-2018 CS Programming & Data Structure 9 1. C prev next = C next prev; 2. C next prev = C prev next; 9. (c) Postfix expression evaluation take O(n) time because only one pass required for evaluation push element and pop 2 elements from stack, operate it and again push it onto stack whenever operator occurs. Prefix and infix evaluation take O(n 2 ) because two pass are require to evaluate. 10. (b) S1: AVL tree is a balance search the that has time complexity of searching O(log n) but in binary search tree, we can have a completely left / right skewed tree, in which search is O(n). S2: Insertion in AVL take O(log n) time because max height is log n, but for binary search tree take O(n) time because maximum height is n. 11. (b) Maximum number of node in AVL tree of height h is 2 h+1 1 i.e. 2 5+1 1 = 2 6 1 = 64 1 = 63 Minimum number of node in AVL tree Height 0 = 1 Node Height 1 = 2 Height 2 = MNH (H 1) + MNH (H 2) + 1 = 1 + 2 + 1 = 4 Height 3 = MNH (H 1) + MNH (H 2) + 1 = MNH (2) + MNH (1) + 1 = 4 + 2 + 1 = 7 Height 4 = MNH (H 1) + MNH (H 2) + 1 = MNH (3) + MNH (2) + 1 = 7 + 4 + 1 = 12 Height 5 = MNH (H 1) + MNH (H 2) + 1 = MNH (4) + MNH (3) + 1 = 12 + 7 + 1 = 20 Difference = 63 20 = 43 12. (c) Inserting an element in AVL tree with n nodes take O(log n) time. So inserting n more nodes it takes n O(log n) = O(n log n) time. So, O(n a log b n) = O(n log n) a = 1, b = 1 Value of a + 50b = 1 + (50 1) = 51 13. (b) 1 rec(5) 2 5 rec(3) pf(5) rec(2) 3 4 6 7 rec(1) pf(3) rec(0) rec(0) pf(2) rec( 1) return return return return 14. (c) Address of an element A[10][15] = Base address + [(j 1) r + (i 1)] 1 r = number of element in column = 1000 + [(15 1) 20 + (10 1)] = 1000 + [14 20 + 9] = 1000 + 289 = 1289 15. (a) Here a is free variable, since it is not declare value assignment to global variable.

10 Computer Science & IT 16. (b) b 1213 Global Function call N b = 12 + 1 = 13 Function call M(b) a = b (assigning address of b) a = a a = 13 13 = 169 a = 169 and b = 13 q m a d e e a s y 2 0 1 6 \0 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 Strcpy (p, best ); copy the string at location 1004. So printf function will print string upto null character i.e. madebest. q m a d e b e s t \0 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 p 17. (c) It merges the two sorted lists. In every recursion, z gets a node which is smallest node from x and y Finally z gets entire sorted list of given two sorted lists of x and y. So option (c) is correct. 18. (a) Building max heap 92 50 62 After adding 97 45 41 92 92 97 50 62 50 97 50 92 45 41 97 45 41 62 Deleting inorder predecessor (i.e. 92). Final max heap will be 45 41 62 97 50 63 45 41

CT-2018 CS Programming & Data Structure 11 19. (a) If S 2 stack is empty and S 1 stack is not empty then we have to pop the element from stack S 1 and push that element into stack S 2 and return the stack S 2 which contain newly inserted element. 20. (a) 1st we have to change the head pointer which contain front node address initially to initial second node (new front node) have to free the initial first node to completely delete the node. 21. (b) In program condition If(root left child == NULL && root right child == NULL) will true when node is leaf node and return 0. Lvalue and Rvalue find number of non-leaf node on left side of root tree and number of non-leaf node on right side of root respectively, and atlast 1 is added to include the root node. So it will return total number of internal node node. 22. (a) float ( p[n]) (int a); Return type float, ( p[n]) p is n elements array of pointers to function where each function having argument (int a) pointer to an integer a. So p is a n elements array of pointers to functions, each function takes an argument as pointer to an integer and return a pointer to a float. 23. (a) Given post-fix expression is 16 2 4 / 4 3 + 6 2 Expression OP1 OP2 Value Top op of stack 16 16 2 16, 2 4 16, 2, 4 (max height = 3) 2 4 16 16, 16 / 16 16 1 1 4 1, 4 3 1, 4, 3 4 3 12 1, 12 + 1 12 13 13 6 13, 6 2 13, 6, 2 6 2 12 13, 12 13 12 1 1 (output) 24. (c) a 54 b x y z 400 10 200 10 200 54 400 15 100 200 300 400 1. x = x (y + z); x = x (5 + 15) = 10 (20) = 200 2. y = 200 << 1 = (11001000 ) 2 << 1 = (110010000) 2 = 400 3. z = x + y = 200 + 400 = 600 25. (b) Trace of matricx take a matrix m = n = 3 a 0 0 0 b 0 0 0 c 500 600

12 Computer Science & IT then sum = 0 + a, sum = a + b, sum = a + b + c sum = a + b + c which is trace of matrix. 26. (b) To evaluate the infix and prefix expression 1 operator stack is used. To evaluate the postfix expression 1 operand stack is used. 27. (d) a 20 100 28. (c) 58 a = 20 + Rec(3) Rec(4) a = 20 + a + a a a + 1 + a + 1 a + 1 a = 20 + 3 + 3 3 3 + 1 + 3 + 1 3 + 1 = 20 + 3 + 27 + 1 + 3 + 3 + 1 = 58 a p 90 98 96 84 70 a+0 a+1 a+2 a+3 a+4 a+5 a+2 a+1 a a+3 a+4 a+5 p+0 p+1 p+2 p+3 p+4 p+5 S p+4 p+5 p+1 p p+2 p+3 S+0 S+1 S+2 S+3 S+4 S+5 Ptr S+3 (ptr + 2) (p + 2) = ( ( ( (S + 3 + 2)))) ( ( (p + 2))) = ( ( (p + 3))) ( (a)) = 96 90 = 6 29. (c) If x be the number of vertices with p connected components, then maximum number of edges in X is given by size of each component in graph = x / p. xx ( p ) Maximum number of edges in each component =. 2 Total number of edges = Number of components Number of edges in one component x x 1 p p xx ( p) = p = 2 2p 10(10 5) So maximum number of edges = = 5 2 5 30. (c) 1. x y return (func (75, 25)) 2. x y return (func (25, 0)) y == 0. So x = 25 x 100 1000 y 75 25 75 25 2000 0