Class Test Solution. Which of the following shows the number of disk moves for the six disk towers of Hanoi problem?

Similar documents
DATA STRUCTURES USING C

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

10CS35: Data Structures Using C

PES Institute of Technology-BSC QUESTION BANK

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

Data Structures and Algorithms V Otávio Braga

Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010

Chapter 3: Restricted Structures Page 1

Questions 1 through 25 are worth 2 points each. Choose one best answer for each.

MAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push)

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s

Data Structures Using C++ 2E. Chapter 5 Linked Lists

CHAPTER 4 ESSENTIAL DATA STRUCTRURES

Module 2 Stacks and Queues: Abstract Data Types

St S a t ck a ck nd Qu Q eue 1

COMPUTER SCIENCE. Paper 1 (THEORY)

QUEUES. Primitive Queue operations. enqueue (q, x): inserts item x at the rear of the queue q

Algorithms and Data Structures

Unit Write iterative and recursive C functions to find the greatest common divisor of two integers. [6]

Analysis of a Search Algorithm

Data Structure [Question Bank]

Stack & Queue. Darshan Institute of Engineering & Technology. Explain Array in detail. Row major matrix No of Columns = m = u2 b2 + 1

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

Atmiya Infotech Pvt. Ltd. Data Structure. By Ajay Raiyani. Yogidham, Kalawad Road, Rajkot. Ph : ,

7.1 Our Current Model

Data Structures. Level 6 C Module Descriptor

BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering

Sample Questions Csci 1112 A. Bellaachia

Common Data Structures

Course: Programming II - Abstract Data Types. The ADT Stack. A stack. The ADT Stack and Recursion Slide Number 1

Queues Outline and Required Reading: Queues ( 4.2 except 4.2.4) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic

Abstract Data Type. EECS 281: Data Structures and Algorithms. The Foundation: Data Structures and Abstract Data Types

Stacks. Linear data structures

Algorithms and Data Structures Written Exam Proposed SOLUTION

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. Course Curriculum. DATA STRUCTURES (Code: )

PROBLEMS (Cap. 4 - Istruzioni macchina)

EE2204 DATA STRUCTURES AND ALGORITHM (Common to EEE, EIE & ICE)

Sequential Data Structures

Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit

Data Structure with C

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

Unordered Linked Lists

CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team

Lecture 12 Doubly Linked Lists (with Recursion)

STACKS,QUEUES, AND LINKED LISTS

This lecture. Abstract data types Stacks Queues. ADTs, Stacks, Queues Goodrich, Tamassia

Class Overview. CSE 326: Data Structures. Goals. Goals. Data Structures. Goals. Introduction

Recursion. Definition: o A procedure or function that calls itself, directly or indirectly, is said to be recursive.

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY

Lecture Notes on Binary Search Trees

Data Structures Using C++ 2E. Chapter 5 Linked Lists

Data Structures UNIT III. Model Question Answer

Stacks. Stacks (and Queues) Stacks. q Stack: what is it? q ADT. q Applications. q Implementation(s) CSCU9A3 1

CmpSci 187: Programming with Data Structures Spring 2015

Linked Lists, Stacks, Queues, Deques. It s time for a chainge!

CompSci-61B, Data Structures Final Exam

CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues. Linda Shapiro Spring 2016

Application of Stacks: Postfix Expressions Calculator (cont d.)

ADTs,, Arrays, Linked Lists

ECE 250 Data Structures and Algorithms MIDTERM EXAMINATION /5:15-6:45 REC-200, EVI-350, RCH-106, HH-139

The Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n-1)!

AP Computer Science Java Mr. Clausen Program 9A, 9B

Stacks. Data Structures and Data Types. Collections

Data Structures and Algorithms Stacks and Queues

Universidad Carlos III de Madrid

LINKED DATA STRUCTURES

Algorithms and Data S tructures Structures Stack, Queues, and Applications Applications Ulf Leser

Introduction to Data Structures

Binary Search Trees (BST)

Introduction to Data Structures and Algorithms

Sorting revisited. Build the binary search tree: O(n^2) Traverse the binary tree: O(n) Total: O(n^2) + O(n) = O(n^2)

Binary Heap Algorithms

Cpt S 223. School of EECS, WSU

The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).

Data Structures and Data Manipulation

Queues and Stacks. Atul Prakash Downey: Chapter 15 and 16

Ordered Lists and Binary Trees

Lab Manual. Data Structures (Pr): COT-213 Data Structures (P): IT-215

Course: Programming II - Abstract Data Types. The ADT Queue. (Bobby, Joe, Sue, Ellen) Add(Ellen) Delete( ) The ADT Queues Slide Number 1

Data Structures Using C++

Lecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists

DATA STRUCTURE - STACK

Java Software Structures

2) What is the structure of an organization? Explain how IT support at different organizational levels.

CS 2412 Data Structures. Chapter 2 Stacks and recursion

AP Computer Science AB Syllabus 1

Data Structures and Algorithms

PROGRAMMING CONCEPTS AND EMBEDDED PROGRAMMING IN C, C++ and JAVA: Lesson-4: Data Structures: Stacks

DATA STRUCTURE - QUEUE

What is a Stack? Stacks and Queues. Stack Abstract Data Type. Java Interface for Stack ADT. Array-based Implementation

Stack Allocation. Run-Time Data Structures. Static Structures

Exercises Software Development I. 11 Recursion, Binary (Search) Trees. Towers of Hanoi // Tree Traversal. January 16, 2013

Lecture 1: Data Storage & Index

Algorithms and Abstract Data Types

Chapter 5 Instructor's Manual

Last not not Last Last Next! Next! Line Line Forms Forms Here Here Last In, First Out Last In, First Out not Last Next! Call stack: Worst line ever!

Functions Recursion. C++ functions. Declare/prototype. Define. Call. int myfunction (int ); int myfunction (int x){ int y = x*x; return y; }

Syllabus for Computer Science. Proposed scheme for B.Sc Programme under Choice Based Credit System

Transcription:

Class Test Solution What is the postfix form of the infix expression ((+)*C (-E))^(F+G)?. ^-*+C EF+G. ^-*+C E+FG C. -^*+C E+FG. -^*+C EFG+ Which of the following shows the number of disk moves for the six disk towers of Hanoi problem?. 32. 64 C. 63. 31 C Which of the following operation can be easily performed on array as compare to linked list?. Insert. elete C. Traverse. Fetch an element from a given position Recursion is memory-intensive because:. Recursive functions tend to declare many local variables.. Previous function calls are still open when the function calls itself and the activation records of these previous calls still occupy space on the call stack. C. Many copies of the function code are created.. It requires large data values.

Which of the following data structure is linear data structure?. Tree. Graph C. linked list C n array [2:10, -1:15] is stored in column major order having base address 5115 and each element of array occupies 4 bytes. Find the address of an element [4,4].. 5256. 5303 C. 5208. 5202 If the address of [1][1] and [2][1] are 1000 and 1010 respectively and each element occupies 2 bytes then the array has been stored in order.. row major. matrix major C. column major What is the postfix form of the prefix expression *+ab cd?. abcd+*. ab+cd * C. ab+*cd. ab*+cd

The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is. 600. 650 C. 350. 588 C How many values can be held by an array (-1:n, 1:n)?. (n-1)*(n+1). n*(n+2) C. n*n. n*(n+1) What would be returned by the following recursive function after we call test(0, 3)? int test (int a, int b) if (a==b) return (1); else if (a>b) return(0); else return (a+test(a+1, b));. 1. 2 C. 3. 4

Recursive solution takes more or equal execution time compared to iterative solution for a given problem.. True. False 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?. 2, 2, 1, 1, 2. 2, 2, 1, 2, 2 C. 2, 1, 2, 2, 1. 2, 1, 2, 2, 2 Suggest an appropriate data structure for the following cases-"when a key of keyboard is pressed, the character is printed on the monitor screen".. Linked list. Stack C. Queue. Priority queue C Suppose you have opened a notepad, a music player, an excel sheet,and also you are doing your data structure programming simultaneously. Your OS implements which data structure for it?. Stack. Graph C. Tree. Queue

In a linked list with n nodes, the time taken to insert an element after an element pointed by some pointer is. O(1). O(logn) C. O(n). O(nlogn) Which of the following lines of code will delete two successive nodes of a singly linked list? (assume that the list contains more than 2 nodes). current->link = current->link->link;. current = current->link->link; C. current->link->link = current;. current->link = current->link->link->link; Suppose a circular queue of capacity (n 1) elements is implemented with an array of n elements. ssume that the insertion and deletion operation are carried out using RER and FRONT as array index variables, respectively. Initially, RER = FRONT = 0. The conditions to detect queue full and queue empty are. Full: (RER+1) mod n == FRONT, empty: RER == FRONT. Full: (RER+1) mod n == FRONT, empty: (FRONT+1) mod n == RER C. Full: RER == FRONT, empty: (RER+1) mod n == FRONT. Full: (FRONT+1) mod n == RER, empty: RER == FRONT Which one of the following permutations can be obtained as an output using stack assuming that the input is the sequence 1,2,3,4,5 in that order?. 3,4,5,1,2. 3,4,5,2,1 C. 1,5,2,3,4

. 5,4,3,1,2 What does the following function do for a given Linked List with first node as head? void fun(struct Node* head) if(head == NULL) return; fun(head->next); printf("%d", head->data);. Prints all nodes of linked lists. Prints all nodes of linked list in reverse order C. Prints alternate nodes of Linked List. Prints alternate nodes in reverse order Which of the following is true about linked list implementation of stack?. In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation, nodes must be removed from end.. In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be removed from the beginning. C. oth are correct. None is correct The following postfix expression with single digit operands is evaluated using a stack:

8 2 3 ^ / 2 3 * + 5 1 * - Which are the two top elements of the stack after evaluation of first *?. 6, 1. 5, 7 C. 3, 2. 7, 5 single array [1..MXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1 and top2 (topl< top2) 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.. (top1 = MXSIZE/2) and (top2 = MXSIZE/2+1). top1 + top2 = MXSIZE C. (top1= MXSIZE/2) or (top2 = MXSIZE). top1= top2-1 Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are: i. isempty (Q) returns true if the queue is empty, false otherwise. ii. delete (Q) deletes the element at the front of the queue and returns its value. iii. insert (Q, i) inserts the integer i at the rear of the queue. Consider the following function: void f(queue Q) int i ; if (!isempty(q)) i = delete(q);

f(q); insert(q, i);. Leaves the queue Q unchanged. Reverses the order of the elements in the queue Q C. eletes the element at the front of the queue Q and inserts it at the rear keeping the other elements in the same order Consider the following function to traverse a linked list. Head is a pointer pointing to the first node of the list. void traverse(struct Node *head) while (head->next!= NULL) printf("%d", head->data); head = head->next; Which of the following is FLSE about above function?. The function may return segmentation fault when the linked list is empty.. The function doesn't print data of the last node when the linked list is not empty C. The function prints data of all the nodes of the link list when the list is not empty. C