PESIT Bangalore South Campus

Similar documents
PES Institute of Technology-BSC QUESTION BANK

Binary Search Trees (BST)

Binary Search Trees. Data in each node. Larger than the data in its left child Smaller than the data in its right child

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

Ordered Lists and Binary Trees

TREE BASIC TERMINOLOGIES

Union-Find Problem. Using Arrays And Chains

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

Algorithms and Data Structures

Data Structure with C

Data Structures. Jaehyun Park. CS 97SI Stanford University. June 29, 2015

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

Binary Search Trees CMPSC 122

Converting a Number from Decimal to Binary

Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

Data Structures and Algorithms

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.

10CS35: Data Structures Using C

Data Structure [Question Bank]

Analysis of Algorithms I: Binary Search Trees

Cpt S 223. School of EECS, WSU

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

DATA STRUCTURES USING C

Motivation Suppose we have a database of people We want to gure out who is related to whom Initially, we only have a list of people, and information a

Full and Complete Binary Trees

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

Output: struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

Any two nodes which are connected by an edge in a graph are called adjacent node.

CS711008Z Algorithm Design and Analysis

Binary Heaps * * * * * * * / / \ / \ / \ / \ / \ * * * * * * * * * * * / / \ / \ / / \ / \ * * * * * * * * * *

A binary search tree is a binary tree with a special property called the BST-property, which is given as follows:

GRAPH THEORY LECTURE 4: TREES

Binary Trees (1) Outline and Required Reading: Binary Trees ( 6.3) Data Structures for Representing Trees ( 6.4)

Binary Heaps. CSE 373 Data Structures

Lecture Notes on Binary Search Trees

Chapter 8: Binary Trees

root node level: internal node edge leaf node Data Structures & Algorithms McQuain

Heaps & Priority Queues in the C++ STL 2-3 Trees

Binary Search Trees. Ric Glassey

Binary Heap Algorithms

Algorithms and Data Structures Written Exam Proposed SOLUTION

Sample Questions Csci 1112 A. Bellaachia

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:

Chapter 14 The Binary Search Tree

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

Algorithms Chapter 12 Binary Search Trees

Data Structures Fibonacci Heaps, Amortized Analysis

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

Why Use Binary Trees?

Exam study sheet for CS2711. List of topics

A binary heap is a complete binary tree, where each node has a higher priority than its children. This is called heap-order property

Big Data and Scripting. Part 4: Memory Hierarchies

Data Structures and Algorithms(5)

International Journal of Software and Web Sciences (IJSWS)

Binary Trees. Wellesley College CS230 Lecture 17 Thursday, April 5 Handout #28. PS4 due 1:30pm Tuesday, April

Binary Trees and Huffman Encoding Binary Search Trees

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

The ADT Binary Search Tree

Introduction to Data Structures and Algorithms

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

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

Data Structures Using C++

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

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY

Class Notes CS Creating and Using a Huffman Code. Ref: Weiss, page 433

How To Create A Tree From A Tree In Runtime (For A Tree)

Data Structures. Level 6 C Module Descriptor

Lecture 6: Binary Search Trees CSCI Algorithms I. Andrew Rosenberg

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

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

Previous Lectures. B-Trees. External storage. Two types of memory. B-trees. Main principles

Learning Outcomes. COMP202 Complexity of Algorithms. Binary Search Trees and Other Search Trees

B+ Tree Properties B+ Tree Searching B+ Tree Insertion B+ Tree Deletion Static Hashing Extendable Hashing Questions in pass papers

B-Trees. Algorithms and data structures for external memory as opposed to the main memory B-Trees. B -trees

6 March Array Implementation of Binary Trees

Algorithms and Data Structures

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

Parallelization: Binary Tree Traversal

From Last Time: Remove (Delete) Operation

A TOOL FOR DATA STRUCTURE VISUALIZATION AND USER-DEFINED ALGORITHM ANIMATION

Data Structures and Algorithm Analysis (CSC317) Intro/Review of Data Structures Focus on dynamic sets

CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 221] edge. parent

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

Data Structures, Practice Homework 3, with Solutions (not to be handed in)

Analysis of Algorithms I: Optimal Binary Search Trees

Lecture Notes on Binary Search Trees

Binary Search Tree Intro to Algorithms Recitation 03 February 9, 2011

Outline BST Operations Worst case Average case Balancing AVL Red-black B-trees. Binary Search Trees. Lecturer: Georgy Gimel farb

Keys and records. Binary Search Trees. Data structures for storing data. Example. Motivation. Binary Search Trees

Operations: search;; min;; max;; predecessor;; successor. Time O(h) with h height of the tree (more on later).

Data Structures UNIT III. Model Question Answer

Symbol Tables. Introduction

Binary Search Trees. Each child can be identied as either a left or right. parent. right. A binary tree can be implemented where each node

An Immediate Approach to Balancing Nodes of Binary Search Trees

API for java.util.iterator. ! hasnext() Are there more items in the list? ! next() Return the next item in the list.

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

CIS 631 Database Management Systems Sample Final Exam

Introduction to data structures

Physical Data Organization

OPTIMAL BINARY SEARCH TREES

Transcription:

PESIT Bangalore South Campus Hosur road, km before Electronic City, Bengaluru -00 Department of Information Science and Engineering Scheme For Internal Assessment Test 3 Subject & Code: Data Structures with C- 0CS35 Faculty: Mrs.R.Bharathi Note: Answer any FIVE full questions Q.No Questions a) Explain the following terms with examples: Complete Binary Tree Marks 0 A complete binary tree of depth d is the strictly binary all of whose leaves are at level d. A complete binary tree with depth d has 2d leaves and 2d- nonleaf nodes Strictly Binary Tree A full binary tree of depth k is a binary tree of depth k having 2 - nodes, k>=0. Expression tree Expression tree is a binary tree in which each internal node corresponds to operator and each leaf node corresponds to operand Binary search tree Every element has a unique key. The keys in a nonempty left subtree (right subtree) are smaller (larger) than the key in the root of subtree. The left and right subtrees are also binary search trees. Forest A forest is a set of n >= 0 disjoint trees 2 a) i) Define the following: i) Undirected Graph ii)directed Graph Undirected graph => no oriented edge. Directed graph => every edge has an orientation. [BE ISE III Semester]

b) Construct the binary tree from the given traversals: ) Preorder: A B D G C E H I F In order: D G B A H E I C F 3 a) Write a recursive C routine to implement Binary Search NODE search(node root,int key) /* return a pointer to the node that contains key. If there is no such node, return NULL */ if (root==null) return NULL; if (key == root->data) return root; if (key < root->data) return search(root->left_child, key); return search(root->right_child,key); b) Write and explain with a function, level order tree traversal void level_order(tree_pointer ptr) /* level order tree traversal */ int front = rear = 0; tree_pointer queue[max_queue_size]; if (!ptr) return; /* empty queue */ addq(front, &rear, ptr); for (;;) ptr = deleteq(&front, rear); if (ptr) printf( %d, ptr->data); if (ptr->left_child) addq(front, &rear, ptr->left_child); [Type text] [Type text] [Type text]be ISE IV Semester

PESIT Bangalore South Campus Hosur road, km before Electronic City, Bengaluru -00 Department of Information Science and Engineering if (ptr->right_child) addq(front, &rear, ptr->right_child); else break; a) Define a forest. Explain how to transform a forest into a binary tree with an example. If T, T 2,, T n is a forest of trees, then the binary tree corresponding to this forest, denoted by B(T, T 2,, T n ) () empty, if n = 0 (2) has root equal to root(t ) has left subtree equal to B(T,T 2,,T m ) has right subtree equal to B(T 2,T 3,,T n ) 5 Forest A forest is a set of n >= 0 disjoint trees A Forest A E G B E B C D F H I C F G D H I CHAPTER 5 72 [BE ISE III Semester]

b) How to represent a disjoint set? Explain Disjoint set union and find(i) operations with example. Set Representation S=0,, 7, 8, S2=,, 9, S3=2, 3, 5 0 7 8 9 S i S j = φ Two operations considered here Disjoint set union S S 2 =0,,7,8,,,9 Find(i): Find the set containing the element i. 3 S 3, 8 S 2 3 5 Array Representation for Set i [0] [] [2] [3] [] [5] [] [7] [8] [9] parent - - 2-2 0 0 0 int find(int i) for (; parent[i]>=0; i=parent[i]) return i; void union(int i, int j) parent[i]= j; CHAPTER 5 8 [Type text] [Type text] [Type text]be ISE IV Semester

PESIT Bangalore South Campus Hosur road, km before Electronic City, Bengaluru -00 Department of Information Science and Engineering 5 a) What is Winner tree? Explain with suitable example a winner tree for k=8. Complete binary tree with n external nodes and n - internal nodes. External nodes represent tournament players. Each internal node represents a match played between its two children; the winner of the match is stored at the internal node. Root has overall winner. Winner Tree for k = 8 5 5 9 8 7 7 8 0 9 9 20 8 9 90 7 2 5 20 38 2 3 8 0 20 30 5 25 28 5 50 3 95 99 8 20 run run2 run3 run run5 run run7 run8 5-5 b) Explain HBLT and WBLT with example HBLT: A binary tree is a (height biased) leftist tree iff for every internal node x, s(leftchild(x)) >= s(rightchild(x)) WBLT: Let the weight, w(x), of node x to be the number of internal nodes in the subtree with root x If x is an external node, w(x) = 0 If x is an internal node, its weight is one more than the sum of the weights of its children A binary tree is a weight-biased leftist tree (WBLT) iff at every internal node, the w value of the left child is greater than or equal to the w value of the right child a) What is priority queue? Explain various types of priority queues. [BE ISE III Semester]. Single ended priority queue It is a collection of elements in which each element has a priority Two types Max Min 2. A double-ended priority queue It is a data structure that supports the following operation:

i) Return an element with minimum priority. ii) Return an element with maximum priority. iii) Insert an element with arbitrary priority. iv) Delete an element with minimum priority. a. Delete an element with maximum priority b) What is binomial heap? Explain the steps involved in the deletion of min element from a binomial heap. A binomial heap is a data structure that supports the same functions as those supported by leftist trees. The binomial tree B k, of degree k is a tree such that if k = 0, then the tree has exactly one node, and if k > 0, then the tree consists of a root whose degree is k and whose subtrees are B 0, B,, B k-. ***************************************************** [Type text] [Type text] [Type text]be ISE IV Semester