DATA STRUCTURE. 1- What data structure can be used to check if a syntax has balanced paranthesis? A - queue B - tree C - list D - stack

Similar documents
INSTITUTE OF AERONAUTICAL ENGINEERING

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

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

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT)

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

1. Attempt any three of the following: 15

Data Structures Question Bank Multiple Choice

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))

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

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

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

CS8391-DATA STRUCTURES QUESTION BANK UNIT I

Data Structures. 1. Each entry in a linked list is a called a (a)link (b)node (c)data structure (d)none of the above

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

GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER ENGINEERING (07) / INFORMATION TECHNOLOGY (16) / INFORMATION & COMMUNICATION TECHNOLOGY (32) DATA STRUCTURES

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

Course Review for Finals. Cpt S 223 Fall 2008

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

GLA University, Mathura

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

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

Data Structure Advanced

DS ata Structures Aptitude

Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 154) Pass Marks: 24

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

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

Department of Computer Science and Technology

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

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

CS8391-DATA STRUCTURES

Course Review. Cpt S 223 Fall 2009

Computer Science E-22 Practice Final Exam

UCS-406 (Data Structure) Lab Assignment-1 (2 weeks)

DYNAMIC MEMORY ALLOCATION AND DEALLOCATION

CS 8391 DATA STRUCTURES

CS301 - Data Structures Glossary By

Course goals. exposure to another language. knowledge of specific data structures. impact of DS design & implementation on program performance

Recitation 9. Prelim Review

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?

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1

CPSC 331 Term Test #2 March 26, 2007

Summer Final Exam Review Session August 5, 2009

MLR Institute of Technology

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

ECE250: Algorithms and Data Structures Midterm Review

Discuss the following operations on One-Dimensional array with algorithms.

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

Binary Trees, Binary Search Trees

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

CSL 201 Data Structures Mid-Semester Exam minutes

Data Structures Brett Bernstein

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

n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο

DC104 DATA STRUCTURE JUNE Q.2 a. If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

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

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

Computer Science 302 Spring 2017 (Practice for) Final Examination, May 10, 2017

Syllabus for Bachelor of Technology. Computer Engineering. Subject Code: 01CE0301. Subject Name: Data Structure. B.Tech. Year - II

TREES. Trees - Introduction

Tribhuvan University Institute of Science and Technology Computer Science and Information Technology (CSC. 154) Section A Attempt any Two questions:

Your favorite blog : (popularly known as VIJAY JOTANI S BLOG..now in facebook.join ON FB VIJAY

Basic Data Structures (Version 7) Name:

n 2 ( ) ( ) + n is in Θ n logn

Midterm solutions. n f 3 (n) = 3

UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING E&CE 250 ALGORITHMS AND DATA STRUCTURES

COMP 251 Winter 2017 Online quizzes with answers

Data Structures. Trees. By Dr. Mohammad Ali H. Eljinini. M.A. Eljinini, PhD

( ). Which of ( ) ( ) " #& ( ) " # g( n) ( ) " # f ( n) Test 1

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο

Computer Science Spring 2005 Final Examination, May 12, 2005

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

Frequently asked Data Structures Interview Questions

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

Computer Science 302 Spring 2007 Practice Final Examination: Part I

( ) ( ) C. " 1 n. ( ) $ f n. ( ) B. " log( n! ) ( ) and that you already know ( ) ( ) " % g( n) ( ) " #&

VALLIAMMAI ENGINEERING COLLEGE

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

QUESTION BANK. Prepared by,mrs.d.maladhy AP/IT,RGCET. Page 1

Course Name: B.Tech. 3 th Sem. No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours. Planned.

Computational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs

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

CSE 373 APRIL 17 TH TREE BALANCE AND AVL

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Direct Addressing Hash table: Collision resolution how handle collisions Hash Functions:

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

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

CS61B Lecture #20: Trees. Last modified: Wed Oct 12 12:49: CS61B: Lecture #20 1

AP Computer Science 4325

Sample Question Paper

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

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8)

Total Score /1 /20 /41 /15 /23 Grader

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

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

CSCE 2014 Final Exam Spring Version A

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

CS24 Week 8 Lecture 1

Algorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs

) $ f ( n) " %( g( n)

Transcription:

DATA STRUCTURE 1- What data structure can be used to check if a syntax has balanced paranthesis? A - queue B - tree C - list D - stack Answer : D Explanation Stack uses LIFO method which is good for checking matching paranthesis. 2. What does the following function do for a given Linked List with first node as head? void fun1(struct node* head) { if(head == NULL) return; fun1(head->next); printf("%d ", head->data); }

A Prints all nodes of linked lists B Prints all nodes of linked list in reverse order C Prints alternate nodes of Linked List D Prints alternate nodes in reverse order B 3 - Which of the following asymptotic notation is the worst among all? A - Ο(n+9378) B - Ο(n 3 ) C - n Ο(1) D - 2 Ο(n) D 4 - Which of the following searching techniques do not require the data to be in sorted form A - Binary Search B Linear search

C-Both A and B D-None of the above Answer : A Explanation Both binary requires data set to be in sorted form. Linear search can work even if the data is not sorted. 5 - Which method can find if two vertices x & y have path between them? A - Depth First Search B - Breadth First Search C - Both A & B D - None A or B Answer : C Explanation By using both BFS and DFS, a path between two vertices of a connected graph can be determined. 6 - Tower of hanoi is a classic example of A - divide and conquer B - recursive approach C - B but not A

D - Both A & B Answer : D Explanation The recursive approach of tower of hanoi uses divide and conquer method. 7.Which of the following is true about linked list implementation of stack? a. In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation, nodes must be removed from end. b. In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be removed from the beginning. c. Both of the above d. None of the above D 8.The result evaluating the postfix expression 10 5 + 60 6 / * 8 is A 284 B 213 C 142 D 71

C 9.Which of the following can be solved by dynamic programming approach? A All pair shortest path problem B 0/1 Knapsack problem C- None of the above D - All of the above Answer : D Explanation All mentioned use dynamic programming approach. Before solving the in-hand sub-problem, dynamic algorithm will try to examine the results of previously solved sub-problems. The solutions of sub-problems are combined in order to achieve the best solution. 10 - Recursion uses more memory space than iteration because A - it uses stack instead of queue. B - every recursive call has to be stored. C - both A & B are true. D - None of the above are true.

Answer : B Explanation Recursion uses stack but the main reason is, every recursive call needs to be stored separately in the memory. Q 11 - What is the worst case run-time complexity of quicksort sort algorithm? A - Ο(n 2 ) B - Ο(n log n ) C - Ο(n 3 ) D - Ο(n) Answer : A Explanation 3 cases 1)All numbers are equal 2)Numbers are in decreasing order 3) Numbers are in increasing order 12. How many stacks are needed to implement a queue. How many queues are needed to implement a stack.

a)1, 1 b)2,1 c)1,2 d)2,2 D 13.Which algorithm is used to construct minimum spanning tree? A.Prims and krushkal algo B.Prims and dijkstras algo C.Krushkal and dijkstras D.Prims and krushkal and dijkstras algo A 14. How many distinct binary search trees can be created out of 4 distinct keys? A 4 B 14

C 24 D 42 14 Catalan no: (2n)!/(n!*(n+1)!) 15. Which of the following traversal outputs the data in sorted order in a BST? A Preorder B B Inorder C Postorder D Level order 16. What are the worst-case complexities of insertion and deletion of a key in a binary search tree? A Θ(logn) for both insertion and deletion B Θ(n) for both insertion and deletion

C Θ(n) for insertion and Θ(logn) for deletion D Θ(logn) for insertion and Θ(n) for deletion B 17.A max-heap is a heap where the value of each parent is greater than or equal to the values of its children. Which of the following is a max-heap? A A B B C C D D

B 18. Consider a binary max-heap implemented using an array. Which one of the following array represents a binary max-heap? A 25,12,16,13,10,8,14 B 25,12,16,13,10,8,14 C 25,14,16,13,10,8,12 D 25,14,12,13,10,8,16 C 19.What is the content of the array after two delete operations on the correct answer to the previous question(deleting root node)? A 14,13,12,10,8 B 14,12,13,8,10 C 14,13,8,12,10

D 14,13,12,8,10 D 20.The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty hash table of length 10 using open addressing (CLOSED HASHING)with hash function h(k) = k mod 10 and linear probing. What is the resultant hash table? A A B B C C D D

C open addressing =CLOSED HASHING closed addressing=open HASHING Open addressing, or closed hashing, is a method of collision resolution in hash tables. With this method a hash collision is resolved by probing, or searching through alternate locations in the array (the probe sequence) until either the target record is found, or an unused array slot is found, which indicates that there is no such key in the table. Well known probe sequences include: linear probing in which the interval between probes is fixed--often at 1. quadratic probing in which the interval between probes increases linearly (hence, the indices are described by a quadratic function). double hashing in which the interval between probes is fixed for each record but is computed by another hash function. 21.Which of the following statement(s) is TRUE? I. A hash function takes a message of arbitrary length and generates a fixed length code. II.A hash function takes a message of fixed length and generates a code of variable length.

III.A hash function may give the same hash value for distinct messages. A.I only B.II and III only C.I and III only D.II only C 22. The Breadth First Search algorithm has been implemented using the queue data structure. One possible order of visiting the nodes of the following graph is A MNOPQR B NQMPOR C QMNPRO

D QMNPOR C 23.Consider the DAG with Consider V = {1, 2, 3, 4, 5, 6}, shown below. Which of the following is NOT a topological ordering? A 1 2 3 4 5 6 B 1 3 2 4 5 6 C 1 3 2 4 6 5 D 3 2 4 1 6 5 D 24.Worst case complexity and average case complexity of Height of binary search tree is (complexity is in Big O) a)log n, n

b)n, log n c)n,n d)log n,log n C 25.The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes and minimum number of nodes in a binary tree of height h is: a)2^(h+1) 2^(h)-1 b) 2^(h+1)-1 2^(h-1)-1 c) 2^(h+1)-1 2^(h) d) 2^(h) 2^(h+1)-1 C 26. In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is a)log 2 n c)n d) log 2 n 1 d)n/2 B

27. You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list? a) Delete the first element b) Insert a new element as a first element c) Delete the last element of the list d) Add a new element at the end of the list C 28. Consi der the follo wing functi on to traver se a linked list.

void traver se(str uct Node *head ) { whi le (head- ->nex t!= NUL L) { p rintf(" %d ", head- >data ); h ead = head- >next ; } }

Whic h of the follo wing is FA LSE about above functi on? a.th e funct ion may crash

when the linke d list is empt y b.th e funct ion does n't print the

last node when the linke d list is not empt y c.th e funct ion is impl emen

ted incor rectl y beca use it chan ges head C 29. Predict the output of following program #include <stdio.h> int f(int n) { if(n <= 1) return 1;

} if(n%2 == 0) return f(n/2); return f(n/2) + f(n/2+1); int main() { printf("%d", f(11)); return 0; } A)3 B)4 C)5 D)STACK OVERFLOW C 30. Here is an infix notation ((A+B)*C-(D-E))^(F+G). Choose the correct postfix notation of the above from the given options. a. AB+CD*E--FG+^ b. AB+C*DE--FG+^ c. AB+C*DE-FG-+^ d. A+BC*DE-FG-+^ B

31. What is the best time complexity of bubble sort? a)n 2 b)logn c)n d)nlogn C int main() { int arr[] = {10, 20, 30, 400, 50}, i, j, isswapped; int n = sizeof(arr) / sizeof(*arr),t; isswapped = 1; for(i = 0; i < n - 1 && isswapped; ++i) { isswapped = 0; for(j = 0; j < n - i - 1; ++j) { if (arr[j] > arr[j + 1]) { t=arr[j];

arr[j]=arr[j+1]; arr[j+1]=t; } isswapped = 1; } } for(i = 0; i < n; ++i) printf("%d ", arr[i]); return 0; } 32. The auxiliary space of insertion sort is O(1), what does O(1) mean? a.the memory (space) required to process the data is not constant. b.it means the amount of extra memory Insertion Sort consumes doesn't depend on the input. The algorithm should use the same amount of memory for all inputs. c.it takes only 1 kb of memory.

c.it is the speed at which the elements are traversed B