Where does the insert method place the new entry in the array? Assume array indexing starts from 0(zero).

Similar documents
DEEPIKA KAMBOJ UNIT 2. What is Stack?

Tutorial 3: Infix, Prefix, Postfix & Tower of Hanoi

Stack. Data structure with Last-In First-Out (LIFO) behavior. Out

INSTITUTE OF AERONAUTICAL ENGINEERING

PA3 Design Specification


MIDTERM EXAMINATION Spring 2010 CS301- Data Structures

BBM 201 DATA STRUCTURES

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

EC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3

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

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1

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

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

Stacks. stacks of dishes or trays in a cafeteria. Last In First Out discipline (LIFO)

Data Structures. Chapter 06. 3/10/2016 Md. Golam Moazzam, Dept. of CSE, JU

STACKS AND QUEUES. Problem Solving with Computers-II

ADVANCED DATA STRUCTURES USING C++ ( MT-CSE-110 )

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

Types of Data Structures

CIS Fall Data Structures Midterm exam 10/16/2012

DATA STRUCTURE UNIT I

BBM 201 DATA STRUCTURES

! A data type for which: ! In fact, an ADT may be implemented by various. ! Examples:

17CS33:Data Structures Using C QUESTION BANK

CPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues

The Stack ADT. Stacks. The Stack ADT. The Stack ADT. Set of objects in which the location an item is inserted and deleted is prespecified.

final int a = 10; for(int i=0;i<a;i+=2) { for(int j=i;j<a;j++) { System.out.print("*"); } System.out.println(); }

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1

Stack and Queue. Stack:

CSE 326 Team. Today s Outline. Course Information. Instructor: Steve Seitz. Winter Lecture 1. Introductions. Web page:

Queues. Queue ADT Queue Implementation Priority Queues

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

Largest Online Community of VU Students

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

Some Applications of Stack. Spring Semester 2007 Programming and Data Structure 1

! A data type for which: ! An ADT may be implemented using various. ! Examples:

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

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

The Bucharest University of Economic Studies. Data Structures. ADTs-Abstract Data Types Stacks and Queues

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

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

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

Programming and Data Structure Solved. MCQs- Part 2

Linked Structures. See Section 3.2 of the text.

Data Structures Question Bank Multiple Choice

A linear-list Data Structure where - addition of elements to and - removal of elements from are restricted to the first element of the list.

Data Structures And Algorithms

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING B.E SECOND SEMESTER CS 6202 PROGRAMMING AND DATA STRUCTURES I TWO MARKS UNIT I- 2 MARKS

Linked List. April 2, 2007 Programming and Data Structure 1

Queues. ADT description Implementations. October 03, 2017 Cinda Heeren / Geoffrey Tien 1

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #04

CS 206 Introduction to Computer Science II

15. Stacks and Queues

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

STACKS. A stack is defined in terms of its behavior. The common operations associated with a stack are as follows:

Introduction to the Stack. Stacks and Queues. Stack Operations. Stack illustrated. Week 9. elements of the same type.

1 P age DS & OOPS / UNIT II

Lecture Data Structure Stack

.:: UNIT 4 ::. STACK AND QUEUE

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

Introduction to the Stack. Stacks and Queues. Stack Operations. Stack illustrated. elements of the same type. Week 9. Gaddis: Chapter 18

The Stack and Queue Types

LIFO : Last In First Out

Lecture 4 Stack and Queue

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

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

Problem One: Loops and ASCII Graphics

SCHOOL OF COMPUTER AND COMMUNICATION ENGINEERING. EKT224: ALGORITHM AND DATA STRUCTURES (Stack, Queue, Linked list)

COSC160: Data Structures: Lists and Queues. Jeremy Bolton, PhD Assistant Teaching Professor

Stacks, Queues and Hierarchical Collections

CS8391-DATA STRUCTURES QUESTION BANK UNIT I

DATA STRUCUTRES. A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0)

Discussion 2C Notes (Week 3, January 21) TA: Brian Choi Section Webpage:

Top of the Stack. Stack ADT

Queue ADT. January 31, 2018 Cinda Heeren / Geoffrey Tien 1

Abstract Data Type: Stack

Outline. Stacks. 1 Chapter 5: Stacks and Queues. favicon. CSI33 Data Structures

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

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

Linear Data Structure

Postfix (and prefix) notation

Stacks, Queues and Hierarchical Collections. 2501ICT Logan

CS 206 Introduction to Computer Science II

CPSC 221: Algorithms and Data Structures ADTs, Stacks, and Queues

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

Functions. CS10001: Programming & Data Structures. Sudeshna Sarkar Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur

Content: Learning Objectives

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

12 Abstract Data Types

Data Structures & Algorithm Analysis. Lecturer: Souad Alonazi

Top of the Stack. Stack ADT

Queues. Gaddis 18.4, Molly A. O'Neil CS 2308 :: Spring 2016

Cpt S 122 Data Structures. Course Review Midterm Exam # 1

Ch. 18: ADTs: Stacks and Queues. Abstract Data Type

Motivation for Queues

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

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

CMSC Introduction to Algorithms Spring 2012 Lecture 7

Transcription:

Suppose we have a circular array implementation of the queue,with ten items in the queue stored at data[2] through data[11]. The current capacity of an array is 12. Where does the insert method place the new entry in the array? Assume array indexing starts from 0(zero). A. data[1] B. data[0] C. data[11] D. data[12] B If the sequence of operations - push(1), push(2), pop, push(1), push(2), pop, pop, pop, push(2), pop are performed on a stack, the sequence of popped out values are? A. 2, 2, 1, 1, 2 B. 2, 2, 1, 2, 2 C. 2, 1, 2, 2, 1 D. 2, 1, 2, 2, 2 A The postfix equivalent of the prefix * + ab - cd is? A. ab + cd - * B. abcd + - * C. ab + cd * - D. ab + - cd * A Which of the following data structure may give overflow error, even though the current number of elements in it is less than its size? A. stack

B. circular queue C. simple queue D. array C Which of the following shows the number of disk moves for the 6 disk towers of Hanoi problem? A. 31 B. 64 C. 63 D. 32 C Suggest an appropriate data structure for the following cases-"when a key of keyboard is pressed, the character is printed on the monitor screen". A. Linked list B. Stack C. Queue D. Priority queue C An array A[2:10, 1:15] is stored in column major order having base address 5115 and each element of array occupies 3 bytes. Find the address of an element A[4,4]. A. 5150 B. 5146 C. 5208 D. 5220 D

If the address of A[1][2] and A[2][2] are 1012 and 1018 respectively and each element occupies 2 bytes then the array has been stored in order. A. row major B. matix major C. column major A Which data structure is best suited for performing undo and redo operation? A. Queue B. Stack C. Tree D. Array B Which queue does not follow strict fifo rules? A. Priority Queue B. Double Ended Queue C. Circular Queue D. Input Restricted Queue A What can we said about the array representation of a circular queue when it contain only one element?. A. Front=Rear=NULL B. Front=Rear-1 C. Front=Rear+1

D. Front=Rear D A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1 and top2 (topl< top 2) point to the location of the topmost element in each of the stacks. If the space is to be used efficiently, the condition for stack full is. A. (top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1) B. top1 + top2 = MAXSIZE C. (top1= MAXSIZE/2) or (top2 = MAXSIZE) D. top1= top2-1 D To evaluate an expression without any embedded function calls. A. One stack is enugh B. Two stacks are needed C. no stack required D. none of all A Following is an incorrect pseudocode for the algorithm which is supposed to determine whether a sequence of parentheses is balanced declare a character stack while ( more input is available) { read a character if ( the character is a '(' ) push it on the stack

else if ( the character is a ')' and the stack is not empty ) pop a character off the stack else print "unbalanced" and exit } print "balanced" Which of these unbalanced sequences does the above code think is balanced? A. ((()) B. ())(() C. (()())) D. (()))() A How many stacks are needed to implement a queue. Consider the situation where no other data structure like arrays, linked list is available to you. A. 1 B. 2 C. 3 D. 4 Answer: B Consider the following pseudo code void fun(int n) { IntQueue q = new IntQueue(); q.enqueue(0); q.enqueue(1); for (int i = 0; i < n; i++) {

int a = q.dequeue(); int b = q.dequeue(); q.enqueue(b); q.enqueue(a + b); ptint(a); } } Assume that IntQueue is an integer queue. What does the function fun do? A. Prints numbers from 0 to n-1 B. Prints numbers from n-1 to 0 C. Prints first n Fibonacci numbers D. Prints first n Fibonacci numbers in reverse order. C Suppose implementation supports an instruction REVERSE, which reverses the order of elements on the stack, in addition to the PUSH and POP instructions. Which one of the following statements is TRUE with respect to this modified stack? A. A queue cannot be implemented using this stack. B. A queue can be implemented where ENQUEUE takes a single instruction and DEQUEUE takes a sequence of two instructions. C. A queue can be implemented where ENQUEUE takes a sequence of three instructions and DEQUEUE takes a single instruction. D. A queue can be implemented where both ENQUEUE and DEQUEUE take a single instruction each. Answer: C Which one of the following is an application of Queue Data Structure? A. When a resource is shared among multiple consumers. B. When data is transferred asynchronously (data not necessarily received at same rate as sent) between two processes

C. Load Balancing D. All of the above Answer: D A program P reads in 500 integers in the range [0..100] representing the scores of 500 students. It then prints the frequency of each score above 50. What would be the best way for P to store the frequencies? A. An array of 50 numbers B. An array of 100 numbers C. An array of 500 numbers D. A dynamically allocated array of 550 numbers Answer: A Let A be a square matrix of size n x n C = 100 for i = 1 to n do for j = 1 to n do { Temp = A[i][j] + C A[i][j] = A[j][i] A[j][i] = Temp - C } for i = 1 to n do for j = 1 to n do Output(A[i][j]); Consider the following program. What is the expected output? A. The matrix A itself B. Transpose of matrix A

C. Adding 100 to the upper diagonal elements and subtracting 100 from diagonal elements of A D. None of the above Answer: A