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

Size: px
Start display at page:

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

Transcription

1 Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The infix expression A+((B-C)*D) is correctly represented in prefix notation as + A * - B C D 4) A list of data items usually words or bytes, with the accessing restriction that elements can be added or removed at one end of the list only, is known as Stack 5) In what order the elements of a push down stack are accessed Last In First Out (LIFO) 6) The following sequence of operations performed on a stack push (1), push (2), pop, push (1), push (2), pop, pop, pop, push (2), pop. The sequence of popped out values are 2, 2, 1, 1, 2 7) The postfix form of A$B * C-D + E/F/(G+H) is AB $ C*D EF/GH+/+ 8) The postfix form of A-B/(C*D$E) is ABCDE$*/- 9) The prefix form of A-B/(C*D$E) is A/B*C$DE 10) The prefix of (A+B)*(C-D) is *+AB-CD 11) What is a Base case? It is a nonrecursive exit from the recursive routine 12) What is a Recursive case? It is a path that includes a recursive call to the routine, to solve a smaller version of the original problem 13) What will be the value returned by the following function when it is called with recur (int num) { if((num/2)!=0) return(recur(num/2)*10+num%2); else return 1; } 14) A linear list in which elements can be added or removed at either end but not in the middle is known as : dqueue 15) The initial configuration of queue is a, b, c, d ( a is at the front). To get the configuration d, c, b, a one needs a minimum of : 3 deletions and 3 additions 16) Queues serve a major role in : simulation of limited resource allocation 17) Queue : can be created by setting up an ordinary contiguous array to hold the items. 18) Let P be the queue of integers defined as follows- Mr. Shylesh B C Page 1 of 8

2 #define MAXQ 500 struct queue { int items [MAXQ]; int front, rear; }q; To insert an elements in the queue we can use : q.items[++q.rear]=x 19) Implementation of list in a dynamic fashion is : to call upon the system to allocate and free storage or a set of nodes is not reserved in advance for use 20) Because of linear structure of linked list having natural linear ordering, there is similarity between linked list and array in : traversal of elements of list 21) Header of a linked list is a special node at the : Beginning of the list 22)struct address { char name [40]; struct address *next }info; func(struct address *j ) { static struct address *i =0; if (i==0) i= j; else i ->next = j; j -> next =0; i =j; } builds the linked list by placing each element : On the end 23) struct address { char name [40]; struct address *next }info; func (struct address *head) { while (head) { printf (head ->name); head = head -> next;} } prints the : Name in all elements of linked list starting from the elements 24) In linked list the logical order of elements : Is not necessarily equivalent to their physical arrangement. 25) The nth node in singly linked list is accessed via ( where n > 1 ) : ( n 1 ) node 26) In linked list the successive elements : need not occupy contiguous space in memory but should be linked to one another. 27) Linear order in linked list is provided through : Pointer. 28) NULL pointer is used to tell : End of linked list., Empty pointer field of a structure. Linked list is empty. 29) List pointer variable in linked list contains address of the : First node in the list. 30) Underflow condition in linked list may occur when attempting to : Delete a node in an empty list. Mr. Shylesh B C Page 2 of 8

3 31) Deletion of a node in linked list involves keeping track of the address of the node : Which immediately follows the node that has to be deleted 32) Having address of the node to be deleted in double linked list, the node can be deleted : Without traversing the list 33) Appropriate data structure in C to represent linked list is : Array and Struct 34) Link of linked list in C is of type : Pointer to struct 35) malloc function returns NULL value when : If enough memory is not there or argument size is 0 36) Previously allocated memory can be returned to the system by using : free() 37) Function /s associated with dynamic memory allocation is : malloc(), calloc(), free() 38) How many ancestors does a node in the N th level (root level =0) of a binary search tree have? N 39) A binary search tree is generated by inserting in order the following integers : 50, 15, 62, 5, 20, 58, 91, 3, 8, 37, 60, 24. The number of nodes in the left subtree and right subtree of the root respectively is (7,4) 40) Which process is faster for threaded trees compared with their unthreaded counterparts : Traversal 41) If a binary tree is threaded for an in order traversal order, NULL left link of any node is replaced by the address of its : Predecessor 42) The inorder traversal of some binary tree produced the sequence DBEAFC, and the postorder traversal of the same tree produced the sequence DEBFCA. What is the preorder traversal sequence? ABDECF 43) A balanced binary tree is a binary tree in which the heights of the two subtrees of every node never differ by more than : 1 44) The postorder traversal of some binary tree produced the sequence CDBFEA, and the inorder traversal of the same tree produced the sequence CBDAFE. What will be the total number of nodes in its right sub tree : 2 45) The postorder traversal of some binary tree produced the sequence CDBFEA, and the inorder traversal of the same tree produced the sequence CBDAFE. What will be the total number of nodes in its left sub tree : 3 46) The inorder traversal of some binary tree produced the sequence CBDA, and the postorder traversal of the same tree produced the sequence CDBA. Then Right subtree is empty, and the left subtree contains 3 nodes. 47) In view of a complete binary tree what is the value of the outdegree - The outdegree of every node is exactly equal to 2 or 0. 48) Balance of the node : Height of its left subtree minus height of its right subtree. Mr. Shylesh B C Page 3 of 8

4 49) Level of any node of a tree is : Its distance from the root. 50) The element at the root of the heap is depending on type of heap it may be smallest or largest 51) Bubble sort does not use divide and conquer methodology 52) Name the sort in which array to be sorted is partitioned again and again in such a way that all elements less than or equal to partition element appear before it and those which are greater appear after it. quick sort 52) This sort inserts each elements A(k) into its proper position in the previously sorted subarray A(1),. A(k-1). insertion sort 53) In this sort file is divided into subfiles which are to be independently sorted and then merged : shell Sort 54) Average case time complexity of the quick sort algorithm is more than : O(N log2 N ) 55) For sorting contiguous list of records quicksort may be preferred over merge sort because : it does not require extra space for an auxilliary storage 56) In quicksort a desirable choice for the partitioning element will be : median of the list 57) The techniques used in creating hash keys are - Divided 58) In this search keys must be ordered : binary search 59) The searching method requires that all keys must reside in internal memory : binary search 60) The element being searched for is not in an array of 100 elements. What is the average number of comparisons needed in a sequential search to determine that the element is not there if the elements are completely unordered ) The element being searched for is not in an array of 100 elements. What is the average number of comparisons needed in a sequential search to determine that the element is not there if the elements are ordered from smallest to largest ) The element being searched for is not in an array of 100 elements. What is the average number of comparisons needed in a sequential search to determine that the element is not there if the elements are ordered from largest to smallest ) The element being searched for is not in an array of 100 elements. What is the average number of comparisons needed in a sequential search to determine the position of the if the elements are completely unordered. 75 State whether the following statements are TRUE or FALSE : 1) A stack may be represented by a linear linked list - True 2) Push operation in stack is performed at the rear end - False Mr. Shylesh B C Page 4 of 8

5 3) Only the most recently inserted element can be accessed through POP operation in stack - True 4) POP operation in stack may result in overflow - False 5) PUSH operation in stack may result in underflow - False 6) Stack is an example of linear list - True 7) Recursive function must be called directly - True 8) In many cases we observe that, a recursive solution is the most natural and logical way of solving problem. - True 9) The problem of Tower of Hanoi is very difficult to solve using non recursive process. - True 10) Recursive functions and iterative functions using stacks can accomplish exactly the same tasks. - True 11) The number of total elements in a queue is fixed. - False 12) The number of elements in a queue, at any time is : q.rear q.front False 13) The operation of removing an element from a queue logically, involves manipulation of only one element. - True 14) The term head of the queue is same as the term front of the queue. - True 15) Queue can be created by setting up am ordinary contiguous array to hold the items. - True 16) The concept of circular array is very difficult to implement. - False 17) For stack or queue,a arbitrary amount of memory can be allocated. - False 18) FRONT = REAR pointer means queue is empty. - True 19) A Queue can be implemented using a circular array with front and rear indices and one position left vacant. - True 20) Queue is an useful data structure for any simulation applications. - True 21) A Priority queue is implemented using an array of stacks. - False 22) List NULL can be used to initialize list as empty list - True 23) In linked list the logical order of elements is same as their physical arrangement - False 24) Random access of elements in linked list is possible - False Mr. Shylesh B C Page 5 of 8

6 25) In linked list each node must have atleast two fields - True 26) In linked list successive elements need not occupy adjacent space in memory. - True 27) Searching the linked list requires the list must be in sorted order - False 28) Every tree can be uniquely represented by a binary tree. True 29) Tree traversal is a procedure by which, each node in the tree is processed exactly twice in a systematic manner False 30) In preorder traversal of a binary tree the left subtree is traversed after processing the root node. True 31) In preorder traversal of a binary tree the root node is processed first. True 32) For inorder traversal of a binary tree the inorder traversal of its left subtree should be performed first. True 33) A binary tree is threaded according to a particular traversal order. False 34) For inorder threading of a binary tree if the left link of some node is NULL it is replaced by the address of its successor. True 35) The height of a binary tree is the maximum level of its leaves. False 36) In a tree a node with no sub trees is called a leaf node. True 37) The level of any node of a tree is the length of its path from the root. True 38) The level of the root node of any tree is 1. False 39) In internal sorting methods it is necessary for all data to reside in internal memory True 40) Insertion sort is also called bubble sort False 41) In merge sort, files to be merged must be sorted True 42) Quick sort and merge sort are example of divide and conquer algorithms True 43) Insertion sort is O(N) False 44) Average case time for quick sort is O(log n ) False 45) Bubble sort algorithm requires O(N) comparisons for sorting a sorted list True 46) Quick sort algorithm requires O(N log N) comparisons for sorting a sorted list False 47) A Heap need not be a binary tree False 48) Merge sort is a stable sorting algorithm True Mr. Shylesh B C Page 6 of 8

7 49) For sorting elements of an array, where each element is a large record, it is always desirable to use an index array for reducing overhead of comparison. False 50) Radix search algorithms work with bits or components of the keys instead of the complete keys. True 51) A binary search of an ordered set of elements in an array is always faster than a sequential search of the elements :False 52) A binary search is an O ( N log 2 N ) algorithm : False 53) A binary search of elements in an array requires that the elements be sorted from smallest to largest True 54) When a hash function is used to determine the placement of elements in an array, the order in which the elements are added will not affect the resulting array : False 55) When hashing is used, increasing the size of the array will always reduce the number of collisions. False 56) No. of elements in the linear Queue with pointers REAR & FRONT at any given instant can be given by formula - REAR FRONT +1 57) If n is the size of array, maximum no. of elements that can be stored in the circular queue is n ) The property of which data structure matches with that of Priority queue? Heap 59) If a doubly linked list is I/P restricted as well as O/P restricted, the queue become circular queue 60) The use of free() function in C requires the header file declaration malloc.h, alloc.h 61) malloc(sizeof(int[10])) The pointer that can point to the above defined m/y area is void 62)Minimum no of pointer adjustment for deletion of any node from the circular doubly linked list is 4 63) sizeof () is an identifier 64) The overflow condition in the array implementation of linked list may occur while calling to getnode 65) Struct book { int acc_no; char title[20]; float price; }; struct book *s; sizeof (*s) will give 2 Mr. Shylesh B C Page 7 of 8

8 66) What is the purpose of using header nodes in the linked? i) To contain global information ii) To avoid null condition in the case when list is empty iii) To indicate the beginning of linked list 67) Which function will require the concept of previous node pointer (for linear linked list): Ordered insertion, Deletion of all occurrences of x, Insertion in the end 68) Using C language to implement the heterogeneous linked list, what may be the different pointer types? The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type. 69) Minimum number of queues needed to implement the priority queue is 2 70) The queue data structure follows the order FIFO Mr. Shylesh B C Page 8 of 8

DATA STRUCTURES USING C

DATA STRUCTURES USING C DATA STRUCTURES USING C QUESTION BANK UNIT I 1. Define data. 2. Define Entity. 3. Define information. 4. Define Array. 5. Define data structure. 6. Give any two applications of data structures. 7. Give

More information

10CS35: Data Structures Using C

10CS35: Data Structures Using C CS35: Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C OBJECTIVE: Learn : Usage of structures, unions - a conventional tool for handling a

More information

UNIVERSITI MALAYSIA SARAWAK KOTA SAMARAHAN SARAWAK PSD2023 ALGORITHM & DATA STRUCTURE

UNIVERSITI MALAYSIA SARAWAK KOTA SAMARAHAN SARAWAK PSD2023 ALGORITHM & DATA STRUCTURE STUDENT IDENTIFICATION NO UNIVERSITI MALAYSIA SARAWAK 94300 KOTA SAMARAHAN SARAWAK FAKULTI SAINS KOMPUTER & TEKNOLOGI MAKLUMAT (Faculty of Computer Science & Information Technology) Diploma in Multimedia

More information

PES Institute of Technology-BSC QUESTION BANK

PES Institute of Technology-BSC QUESTION BANK PES Institute of Technology-BSC Faculty: Mrs. R.Bharathi CS35: Data Structures Using C QUESTION BANK UNIT I -BASIC CONCEPTS 1. What is an ADT? Briefly explain the categories that classify the functions

More information

Data Structure with C

Data Structure with C Subject: Data Structure with C Topic : Tree Tree A tree is a set of nodes that either:is empty or has a designated node, called the root, from which hierarchically descend zero or more subtrees, which

More information

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

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C Tutorial#1 Q 1:- Explain the terms data, elementary item, entity, primary key, domain, attribute and information? Also give examples in support of your answer? Q 2:- What is a Data Type? Differentiate

More information

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

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D. 1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D. base address 2. The memory address of fifth element of an array can be calculated

More information

Data Structure [Question Bank]

Data Structure [Question Bank] Unit I (Analysis of Algorithms) 1. What are algorithms and how they are useful? 2. Describe the factor on best algorithms depends on? 3. Differentiate: Correct & Incorrect Algorithms? 4. Write short note:

More information

12 Abstract Data Types

12 Abstract Data Types 12 Abstract Data Types 12.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT).

More information

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

Questions 1 through 25 are worth 2 points each. Choose one best answer for each. Questions 1 through 25 are worth 2 points each. Choose one best answer for each. 1. For the singly linked list implementation of the queue, where are the enqueues and dequeues performed? c a. Enqueue in

More information

Converting a Number from Decimal to Binary

Converting a Number from Decimal to Binary Converting a Number from Decimal to Binary Convert nonnegative integer in decimal format (base 10) into equivalent binary number (base 2) Rightmost bit of x Remainder of x after division by two Recursive

More information

Data Structures. Level 6 C30151. www.fetac.ie. Module Descriptor

Data Structures. Level 6 C30151. www.fetac.ie. Module Descriptor The Further Education and Training Awards Council (FETAC) was set up as a statutory body on 11 June 2001 by the Minister for Education and Science. Under the Qualifications (Education & Training) Act,

More information

Searching & Sorting. Searching & Sorting 1

Searching & Sorting. Searching & Sorting 1 Searching & Sorting Searching & Sorting 1 The Plan Searching Sorting Java Context Searching & Sorting 2 Search (Retrieval) Looking it up One of most fundamental operations Without computer Indexes Tables

More information

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

Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit Data Structures Page 1 of 24 A.1. Arrays (Vectors) n-element vector start address + ielementsize 0 +1 +2 +3 +4... +n-1 start address continuous memory block static, if size is known at compile time dynamic,

More information

Ordered Lists and Binary Trees

Ordered Lists and Binary Trees Data Structures and Algorithms Ordered Lists and Binary Trees Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science University of San Francisco p.1/62 6-0:

More information

TREE BASIC TERMINOLOGIES

TREE BASIC TERMINOLOGIES TREE Trees are very flexible, versatile and powerful non-liner data structure that can be used to represent data items possessing hierarchical relationship between the grand father and his children and

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms CS245-2016S-06 Binary Search Trees David Galles Department of Computer Science University of San Francisco 06-0: Ordered List ADT Operations: Insert an element in the list

More information

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.

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. 1. The advantage of.. is that they solve the problem if sequential storage representation. But disadvantage in that is they are sequential lists. [A] Lists [B] Linked Lists [A] Trees [A] Queues 2. The

More information

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

Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010 Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010 Problem 1. In each of the following question, please specify if the statement

More information

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

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 Binary Search Trees A Generic Tree Nodes in a binary search tree ( B-S-T) are of the form P parent Key A Satellite data L R B C D E F G H I J The B-S-T has a root node which is the only node whose parent

More information

Algorithms and Data Structures

Algorithms and Data Structures Algorithms and Data Structures Part 2: Data Structures PD Dr. rer. nat. habil. Ralf-Peter Mundani Computation in Engineering (CiE) Summer Term 2016 Overview general linked lists stacks queues trees 2 2

More information

Merge Sort. 2004 Goodrich, Tamassia. Merge Sort 1

Merge Sort. 2004 Goodrich, Tamassia. Merge Sort 1 Merge Sort 7 2 9 4 2 4 7 9 7 2 2 7 9 4 4 9 7 7 2 2 9 9 4 4 Merge Sort 1 Divide-and-Conquer Divide-and conquer is a general algorithm design paradigm: Divide: divide the input data S in two disjoint subsets

More information

Module 2 Stacks and Queues: Abstract Data Types

Module 2 Stacks and Queues: Abstract Data Types Module 2 Stacks and Queues: Abstract Data Types A stack is one of the most important and useful non-primitive linear data structure in computer science. It is an ordered collection of items into which

More information

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

MAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push) ----------------------------------------- =============================================================================================================================== DATA STRUCTURE PSEUDO-CODE EXAMPLES (c) Mubashir N. Mir - www.mubashirnabi.com

More information

Symbol Tables. IE 496 Lecture 13

Symbol Tables. IE 496 Lecture 13 Symbol Tables IE 496 Lecture 13 Reading for This Lecture Horowitz and Sahni, Chapter 2 Symbol Tables and Dictionaries A symbol table is a data structure for storing a list of items, each with a key and

More information

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

Atmiya Infotech Pvt. Ltd. Data Structure. By Ajay Raiyani. Yogidham, Kalawad Road, Rajkot. Ph : 572365, 576681 1 Data Structure By Ajay Raiyani Yogidham, Kalawad Road, Rajkot. Ph : 572365, 576681 1 Linked List 4 Singly Linked List...4 Doubly Linked List...7 Explain Doubly Linked list: -...7 Circular Singly Linked

More information

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

EE2204 DATA STRUCTURES AND ALGORITHM (Common to EEE, EIE & ICE) EE2204 DATA STRUCTURES AND ALGORITHM (Common to EEE, EIE & ICE) UNIT I LINEAR STRUCTURES Abstract Data Types (ADT) List ADT array-based implementation linked list implementation cursor-based linked lists

More information

Overview of Data Structures

Overview of Data Structures UNIT 3 Concrete Data Types Classification of Data Structures Concrete vs. Abstract Data Structures Most Important Concrete Data Structures Arrays Records Linked Lists Binary Trees Overview of Data Structures

More information

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

Linked Lists, Stacks, Queues, Deques. It s time for a chainge! Linked Lists, Stacks, Queues, Deques It s time for a chainge! Learning Goals After this unit, you should be able to... Differentiate an abstraction from an implementation. Define and give examples of problems

More information

CS 6202 PROGRAMMING & DATA STRUCTURES-I PART-B UNIT-I ANNA UNIVERSITY QUESTIONS

CS 6202 PROGRAMMING & DATA STRUCTURES-I PART-B UNIT-I ANNA UNIVERSITY QUESTIONS PART-B UNIT-I 1. Write a function that returns a pointer to the maximum value of an array of double s.if the array is empty,return null? (8) Double*maximum(double*a,int size); 2. Write a c program to find

More information

AS-2261 M.Sc.(First Semester) Examination-2013 Paper -fourth Subject-Data structure with algorithm

AS-2261 M.Sc.(First Semester) Examination-2013 Paper -fourth Subject-Data structure with algorithm AS-2261 M.Sc.(First Semester) Examination-2013 Paper -fourth Subject-Data structure with algorithm Time: Three Hours] [Maximum Marks: 60 Note Attempts all the questions. All carry equal marks Section A

More information

CSCI Trees. Mark Redekopp David Kempe

CSCI Trees. Mark Redekopp David Kempe 1 CSCI 104 2-3 Trees Mark Redekopp David Kempe 2 Properties, Insertion and Removal BINARY SEARCH TREES 3 Binary Search Tree Binary search tree = binary tree where all nodes meet the property that: All

More information

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

The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2). CHAPTER 5 The Tree Data Model There are many situations in which information has a hierarchical or nested structure like that found in family trees or organization charts. The abstraction that models hierarchical

More information

Binary Search Trees (BST)

Binary Search Trees (BST) Binary Search Trees (BST) 1. Hierarchical data structure with a single reference to node 2. Each node has at most two child nodes (a left and a right child) 3. Nodes are organized by the Binary Search

More information

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

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. Course Curriculum. DATA STRUCTURES (Code: 3330704) GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT Course Curriculum DATA STRUCTURES (Code: 3330704) Diploma Programme in which this course is offered Semester in which offered Computer Engineering,

More information

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

The Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n-1)! The Tower of Hanoi Recursion Solution recursion recursion recursion Recursive Thinking: ignore everything but the bottom disk. 1 2 Recursive Function Time Complexity Hanoi (n, src, dest, temp): If (n >

More information

Binary Heap Algorithms

Binary Heap Algorithms CS Data Structures and Algorithms Lecture Slides Wednesday, April 5, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005 2009 Glenn G. Chappell

More information

root node level: internal node edge leaf node CS@VT Data Structures & Algorithms 2000-2009 McQuain

root node level: internal node edge leaf node CS@VT Data Structures & Algorithms 2000-2009 McQuain inary Trees 1 A binary tree is either empty, or it consists of a node called the root together with two binary trees called the left subtree and the right subtree of the root, which are disjoint from each

More information

Stacks. Linear data structures

Stacks. Linear data structures Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations

More information

Exam study sheet for CS2711. List of topics

Exam study sheet for CS2711. List of topics Exam study sheet for CS2711 Here is the list of topics you need to know for the final exam. For each data structure listed below, make sure you can do the following: 1. Give an example of this data structure

More information

Analysis of a Search Algorithm

Analysis of a Search Algorithm CSE 326 Lecture 4: Lists and Stacks 1. Agfgd 2. Dgsdsfd 3. Hdffdsf 4. Sdfgsfdg 5. Tefsdgass We will review: Analysis: Searching a sorted array (from last time) List ADT: Insert, Delete, Find, First, Kth,

More information

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

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 Quiz 4 Solutions Q1: What value does function mystery return when called with a value of 4? int mystery ( int number ) { if ( number

More information

Data Structures, Sample Test Questions for the Material after Test 2, with Answers

Data Structures, Sample Test Questions for the Material after Test 2, with Answers Data Structures, Sample Test Questions for the Material after Test 2, with Answers 1. Recall the public interfaces of classes List and ListIterator: typedef int ListItemType; class ListIterator{ public:

More information

AP Computer Science AB Syllabus 1

AP Computer Science AB Syllabus 1 AP Computer Science AB Syllabus 1 Course Resources Java Software Solutions for AP Computer Science, J. Lewis, W. Loftus, and C. Cocking, First Edition, 2004, Prentice Hall. Video: Sorting Out Sorting,

More information

Trees & Binary Search Trees

Trees & Binary Search Trees CMSC 132: Object-Oriented Programming II Trees & Binary Search Trees Department of Computer Science University of Maryland, College Park Trees Trees are hierarchical data structures One-to-many relationship

More information

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

Previous Lectures. B-Trees. External storage. Two types of memory. B-trees. Main principles B-Trees Algorithms and data structures for external memory as opposed to the main memory B-Trees Previous Lectures Height balanced binary search trees: AVL trees, red-black trees. Multiway search trees:

More information

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92.

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92. Name: Email ID: CSE 326, Data Structures Section: Sample Final Exam Instructions: The exam is closed book, closed notes. Unless otherwise stated, N denotes the number of elements in the data structure

More information

Common Data Structures

Common Data Structures Data Structures 1 Common Data Structures Arrays (single and multiple dimensional) Linked Lists Stacks Queues Trees Graphs You should already be familiar with arrays, so they will not be discussed. Trees

More information

Binary Trees and Huffman Encoding Binary Search Trees

Binary Trees and Huffman Encoding Binary Search Trees Binary Trees and Huffman Encoding Binary Search Trees Computer Science E119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. Motivation: Maintaining a Sorted Collection of Data A data dictionary

More information

Definition. E.g. : Attempting to represent a transport link data with a tree structure:

Definition. E.g. : Attempting to represent a transport link data with a tree structure: The ADT Graph Recall the ADT binary tree: a tree structure used mainly to represent 1 to 2 relations, i.e. each item has at most two immediate successors. Limitations of tree structures: an item in a tree

More information

International Journal Of Engineering Research & Management Technology

International Journal Of Engineering Research & Management Technology International Journal Of Engineering Research & Management Technology ISSN: 2348-4039 September- 2014 Volume 1, Issue-5 Dynamic Implementation Using Linked List Karuna Department of Information and Technology

More information

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

Unit 1. 5. Write iterative and recursive C functions to find the greatest common divisor of two integers. [6] Unit 1 1. Write the following statements in C : [4] Print the address of a float variable P. Declare and initialize an array to four characters a,b,c,d. 2. Declare a pointer to a function f which accepts

More information

Bhakta Kavi Narsinh Mehta University, Junagadh

Bhakta Kavi Narsinh Mehta University, Junagadh Bhakta Kavi Narsinh Mehta University, Junagadh Draft Syllabus for B.Sc. (Computer Science) Bachelor of Science (Computer Science) (Semester - 1) Effective From June - 2016 B.Sc. (C.S.) (Semester - 1) CS-101:

More information

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

Data Structures Using C++ 2E. Chapter 5 Linked Lists Data Structures Using C++ 2E Chapter 5 Linked Lists Doubly Linked Lists Traversed in either direction Typical operations Initialize the list Destroy the list Determine if list empty Search list for a given

More information

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)

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) Sorting revisited How did we use a binary search tree to sort an array of elements? Tree Sort Algorithm Given: An array of elements to sort 1. Build a binary search tree out of the elements 2. Traverse

More information

Java Software Structures

Java Software Structures INTERNATIONAL EDITION Java Software Structures Designing and Using Data Structures FOURTH EDITION John Lewis Joseph Chase This page is intentionally left blank. Java Software Structures,International Edition

More information

Problem. Indexing with B-trees. Indexing. Primary Key Indexing. B-trees. B-trees: Example. primary key indexing

Problem. Indexing with B-trees. Indexing. Primary Key Indexing. B-trees. B-trees: Example. primary key indexing Problem Given a large collection of records, Indexing with B-trees find similar/interesting things, i.e., allow fast, approximate queries Anastassia Ailamaki http://www.cs.cmu.edu/~natassa 2 Indexing Primary

More information

1 2-3 Trees: The Basics

1 2-3 Trees: The Basics CS10: Data Structures and Object-Oriented Design (Fall 2013) November 1, 2013: 2-3 Trees: Inserting and Deleting Scribes: CS 10 Teaching Team Lecture Summary In this class, we investigated 2-3 Trees in

More information

Chapter 7. Indexes. Objectives. Table of Contents

Chapter 7. Indexes. Objectives. Table of Contents Chapter 7. Indexes Table of Contents Objectives... 1 Introduction... 2 Context... 2 Review Questions... 3 Single-level Ordered Indexes... 4 Primary Indexes... 4 Clustering Indexes... 8 Secondary Indexes...

More information

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY A PATH FOR HORIZING YOUR INNOVATIVE WORK A REVIEW ON THE USAGE OF OLD AND NEW DATA STRUCTURE ARRAYS, LINKED LIST, STACK,

More information

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

B-Trees. Algorithms and data structures for external memory as opposed to the main memory B-Trees. B -trees B-Trees Algorithms and data structures for external memory as opposed to the main memory B-Trees Previous Lectures Height balanced binary search trees: AVL trees, red-black trees. Multiway search trees:

More information

Data Structures Using Java

Data Structures Using Java Data Structures Using Java D. S. Malik P. S. Nair THOMSON COURSE TECHNOLOGY Australia Canada Mexico Singapore Spain United Kingdom United States TABLE OF Contents PREFACE XXV 1.Software Engineering Principles

More information

Data Structures Fibonacci Heaps, Amortized Analysis

Data Structures Fibonacci Heaps, Amortized Analysis Chapter 4 Data Structures Fibonacci Heaps, Amortized Analysis Algorithm Theory WS 2012/13 Fabian Kuhn Fibonacci Heaps Lacy merge variant of binomial heaps: Do not merge trees as long as possible Structure:

More information

Trees Carlos Delgado Kloos Mª Carmen Fernández Panadero Raquel M. Crespo García Dep. Ingeniería Telemática Univ. Carlos III de Madrid

Trees Carlos Delgado Kloos Mª Carmen Fernández Panadero Raquel M. Crespo García Dep. Ingeniería Telemática Univ. Carlos III de Madrid Trees Carlos Delgado Kloos Mª Carmen Fernández Panadero Raquel M. Crespo García Dep. Ingeniería Telemática Univ. Carlos III de Madrid cdk@it.uc3m.es Java: Trees / 1 Contents Concept Non recursive definition

More information

Data Structures UNIT III. Model Question Answer

Data Structures UNIT III. Model Question Answer Data Structures UNIT III Model Question Answer Q.1. Define Stack? What are the different primitive operations on Stack? Ans: Stack: A stack is a linear structure in which items may be added or removed

More information

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:

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: Binary Search Trees 1 The general binary tree shown in the previous chapter is not terribly useful in practice. The chief use of binary trees is for providing rapid access to data (indexing, if you will)

More information

Symbol Tables. Introduction

Symbol Tables. Introduction Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The

More information

Summary. Pre requisition. Content Details: 1. Basics in C++

Summary. Pre requisition. Content Details: 1. Basics in C++ Summary C++ Language is one of the approaches to provide object-oriented functionality with C like syntax. C++ adds greater typing strength, scoping and other tools useful in object-oriented programming

More information

Introduction to Data Structures

Introduction to Data Structures Introduction to Data Structures Albert Gural October 28, 2011 1 Introduction When trying to convert from an algorithm to the actual code, one important aspect to consider is how to store and manipulate

More information

Data Structures and Data Manipulation

Data Structures and Data Manipulation Data Structures and Data Manipulation What the Specification Says: Explain how static data structures may be used to implement dynamic data structures; Describe algorithms for the insertion, retrieval

More information

Chapter 3: Restricted Structures Page 1

Chapter 3: Restricted Structures Page 1 Chapter 3: Restricted Structures Page 1 1 2 3 4 5 6 7 8 9 10 Restricted Structures Chapter 3 Overview Of Restricted Structures The two most commonly used restricted structures are Stack and Queue Both

More information

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: IMPORTANT INSTRUCTIONS: 1. Question Paper in English and Hindi and Candidate can choose any one language. 2. In case of discrepancies in

More information

Sample Questions Csci 1112 A. Bellaachia

Sample Questions Csci 1112 A. Bellaachia Sample Questions Csci 1112 A. Bellaachia Important Series : o S( N) 1 2 N N i N(1 N) / 2 i 1 o Sum of squares: N 2 N( N 1)(2N 1) N i for large N i 1 6 o Sum of exponents: N k 1 k N i for large N and k

More information

Trees. Tree Definitions: Let T = (V, E, r) be a tree. The size of a tree denotes the number of nodes of the tree.

Trees. Tree Definitions: Let T = (V, E, r) be a tree. The size of a tree denotes the number of nodes of the tree. Trees After lists (including stacks and queues) and hash tables, trees represent one of the most widely used data structures. On one hand trees can be used to represent objects that are recursive in nature

More information

Introduction to Data Structures and Algorithms

Introduction to Data Structures and Algorithms Introduction to Data Structures and Algorithms Chapter: Elementary Data Structures(1) Lehrstuhl Informatik 7 (Prof. Dr.-Ing. Reinhard German) Martensstraße 3, 91058 Erlangen Overview on simple data structures

More information

The ADT Binary Search Tree. Recursive Tree Traversals. The ADT Binary Search Tree. The ADT Binary Search Tree. In-order

The ADT Binary Search Tree. Recursive Tree Traversals. The ADT Binary Search Tree. The ADT Binary Search Tree. In-order Recursive Tree Traversals The ADT Binary Search Tree In-order private void printinorder(treenode node) { if (node!= null) { printinorder(node.getleft()); System.out.print(node.getItem() + " "); printinorder(node.getright());

More information

2 Exercises and Solutions

2 Exercises and Solutions 2 Exercises and Solutions Most of the exercises below have solutions but you should try first to solve them. Each subsection with solutions is after the corresponding subsection with exercises. 2.1 Sorting

More information

1. Relational database accesses data in a sequential form. (Figures 7.1, 7.2)

1. Relational database accesses data in a sequential form. (Figures 7.1, 7.2) Chapter 7 Data Structures for Computer Graphics (This chapter was written for programmers - option in lecture course) Any computer model of an Object must comprise three different types of entities: 1.

More information

Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Module No. # 02 Lecture No. # 05 Run-time Environments-Part 3 and Local Optimizations

More information

CSE 5311 Homework 2 Solution

CSE 5311 Homework 2 Solution CSE 5311 Homework 2 Solution Problem 6.2-6 Show that the worst-case running time of MAX-HEAPIFY on a heap of size n is Ω(lg n). (Hint: For a heap with n nodes, give node values that cause MAX- HEAPIFY

More information

Data Structure. Lecture 3

Data Structure. Lecture 3 Data Structure Lecture 3 Data Structure Formally define Data structure as: DS describes not only set of objects but the ways they are related, the set of operations which may be applied to the elements

More information

Output: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

Output: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr; 50 20 70 10 30 69 90 14 35 68 85 98 16 22 60 34 (c) Execute the algorithm shown below using the tree shown above. Show the exact output produced by the algorithm. Assume that the initial call is: prob3(root)

More information

Data Structures Using C++

Data Structures Using C++ Data Structures Using C++ 1.1 Introduction Data structure is an implementation of an abstract data type having its own set of data elements along with functions to perform operations on that data. Arrays

More information

Analysis of Algorithms I: Binary Search Trees

Analysis of Algorithms I: Binary Search Trees Analysis of Algorithms I: Binary Search Trees Xi Chen Columbia University Hash table: A data structure that maintains a subset of keys from a universe set U = {0, 1,..., p 1} and supports all three dictionary

More information

Writing programs to solve problem consists of a large. how to represent aspects of the problem for solution

Writing programs to solve problem consists of a large. how to represent aspects of the problem for solution Algorithm Efficiency & Sorting Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms 1 Overview 2 If a given ADT (i.e. stack or queue) is attractive as part of a solution How will

More information

Parallelization: Binary Tree Traversal

Parallelization: Binary Tree Traversal By Aaron Weeden and Patrick Royal Shodor Education Foundation, Inc. August 2012 Introduction: According to Moore s law, the number of transistors on a computer chip doubles roughly every two years. First

More information

Algorithms Chapter 12 Binary Search Trees

Algorithms Chapter 12 Binary Search Trees Algorithms Chapter 1 Binary Search Trees Outline Assistant Professor: Ching Chi Lin 林 清 池 助 理 教 授 chingchi.lin@gmail.com Department of Computer Science and Engineering National Taiwan Ocean University

More information

To My Parents -Laxmi and Modaiah. To My Family Members. To My Friends. To IIT Bombay. To All Hard Workers

To My Parents -Laxmi and Modaiah. To My Family Members. To My Friends. To IIT Bombay. To All Hard Workers To My Parents -Laxmi and Modaiah To My Family Members To My Friends To IIT Bombay To All Hard Workers Copyright 2010 by CareerMonk.com All rights reserved. Designed by Narasimha Karumanchi Printed in

More information

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

St S a t ck a ck nd Qu Q eue 1 Stack and Queue 1 Stack Data structure with Last-In First-Out (LIFO) behavior In Out C B A B C 2 Typical Operations Pop on Stack Push isempty: determines if the stack has no elements isfull: determines

More information

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

Any two nodes which are connected by an edge in a graph are called adjacent node. . iscuss following. Graph graph G consist of a non empty set V called the set of nodes (points, vertices) of the graph, a set which is the set of edges and a mapping from the set of edges to a set of pairs

More information

Chapter 13. Disk Storage, Basic File Structures, and Hashing

Chapter 13. Disk Storage, Basic File Structures, and Hashing Chapter 13 Disk Storage, Basic File Structures, and Hashing Chapter Outline Disk Storage Devices Files of Records Operations on Files Unordered Files Ordered Files Hashed Files Dynamic and Extendible Hashing

More information

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

Lecture 6: Binary Search Trees CSCI 700 - Algorithms I. Andrew Rosenberg Lecture 6: Binary Search Trees CSCI 700 - Algorithms I Andrew Rosenberg Last Time Linear Time Sorting Counting Sort Radix Sort Bucket Sort Today Binary Search Trees Data Structures Data structure is a

More information

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

Learning Outcomes. COMP202 Complexity of Algorithms. Binary Search Trees and Other Search Trees Learning Outcomes COMP202 Complexity of Algorithms Binary Search Trees and Other Search Trees [See relevant sections in chapters 2 and 3 in Goodrich and Tamassia.] At the conclusion of this set of lecture

More information

BM267 - Introduction to Data Structures

BM267 - Introduction to Data Structures BM267 - Introduction to Data Structures 3. Elementary Data Structures Ankara University Computer Engineering Department BLM267 1 Objectives Learn about elementary data structures - Data structures that

More information

Trees 1. General Binary

Trees 1. General Binary Trees 1 General Binary General & Binary Trees General tree Binary Tree Root Root Parent Node Parent Node Child Leaf Child Leaf DFR/JS TREES 1 2 Ordered & Unordered Trees A tree is ORDERED if the child

More information

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

ECE 250 Data Structures and Algorithms MIDTERM EXAMINATION 2008-10-23/5:15-6:45 REC-200, EVI-350, RCH-106, HH-139 ECE 250 Data Structures and Algorithms MIDTERM EXAMINATION 2008-10-23/5:15-6:45 REC-200, EVI-350, RCH-106, HH-139 Instructions: No aides. Turn off all electronic media and store them under your desk. If

More information

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

Lecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists Lecture 11 Doubly Linked Lists & Array of Linked Lists In this lecture Doubly linked lists Array of Linked Lists Creating an Array of Linked Lists Representing a Sparse Matrix Defining a Node for a Sparse

More information

CS 210 Algorithms and Data Structures College of Information Technology and Engineering Weisberg Division of Engineering and Computer Science

CS 210 Algorithms and Data Structures College of Information Technology and Engineering Weisberg Division of Engineering and Computer Science CS 210 Algorithms and Data Structures College of Information Technology and Engineering Weisberg Division of Engineering and Computer Science Semester and Year: Spring 2009 Classroom Section, Meeting Times,

More information

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 13-1

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 13-1 Slide 13-1 Chapter 13 Disk Storage, Basic File Structures, and Hashing Chapter Outline Disk Storage Devices Files of Records Operations on Files Unordered Files Ordered Files Hashed Files Dynamic and Extendible

More information

Multi-Way Search Trees (B Trees)

Multi-Way Search Trees (B Trees) Multi-Way Search Trees (B Trees) Multiway Search Trees An m-way search tree is a tree in which, for some integer m called the order of the tree, each node has at most m children. If n

More information