gujarat technological university - …mytoolbag.in/media/gtupapers/1/2/computer/s3/ds.pdfgujarat...

30

Upload: duongdieu

Post on 23-Mar-2018

224 views

Category:

Documents


6 download

TRANSCRIPT

GUJARAT TECHNOLOGICAL UNIVERSITY

COMPUTER ENGINEERING (07) / INFORMATION TECHNOLOGY

(16) / INFORMATION & COMMUNICATION TECHNOLOGY (32) DATA STRUCTURES

SUBJECT CODE: 2130702

B.E. 3rd

Semester

Type of course: Compulsory

Prerequisite: Computer Programming & utilization

Rationale: Data structure is a subject of primary importance in Information and Communication

Technology. Organizing or structuring data is important for implementation of efficient algorithms

and program development. Efficient problem solving needs the application of appropriate data

structure during program development.

Understanding of data structures is essential and this facilitates the understanding of the

language. The practice and assimilation of data structure techniques is essential for programming. The

knowledge of „C‟ language and data structures will be reinforced by practical exercises during the

course of study. The course will help students to develop the capability of selecting a particular data

structure.

Teaching and Examination Scheme:

Teaching Scheme Credits Examination Marks Total

Marks L T P C Theory Marks Practical Marks

ESE

(E)

PA (M) PA (V) PA

(I) PA ALA ESE OEP

4 0 4 8 70 20 10 20 10 20 150

Contents:

Sr. No. Topics Teaching

Hrs.

Module

Weightage

1 INTRODUCTION TO DATA STRUCTURE:

Data Management concepts, Data types – primitive and

non-primitive, Performance Analysis and Measurement

(Time and space analysis of algorithms-Average, best and

worst case analysis), Types of Data Structures- Linear &

Non Linear Data Structures.

04 10

2 LINEAR DATA STRUCTURE

Array: Representation of arrays, Applications of arrays,

sparse matrix and its representation

Stack: Stack-Definitions & Concepts, Operations On

Stacks, Applications of Stacks, Polish Expression, Reverse

Polish Expression And Their Compilation, Recursion,

Tower of Hanoi

Queue: Representation Of Queue, Operations On Queue,

Circular Queue, Priority Queue, Array representation of

Priority Queue, Double Ended Queue, Applications of

Queue

Linked List: Singly Linked List, Doubly Linked list,

13 30

Circular linked list ,Linked implementation of Stack,

Linked implementation of Queue, Applications of linked

list.

3 NONLINEAR DATA STRUCTURE :

Tree-Definitions and Concepts, Representation of binary

tree, Binary tree traversal (Inorder, postorder, preorder),

Threaded binary tree, Binary search trees, Conversion of

General Trees To Binary Trees, Applications Of Trees-

Some balanced tree mechanism, eg. AVL trees, 2-3 trees,

Height Balanced, Weight Balance, Graph-Matrix

Representation Of Graphs, Elementary Graph

operations,(Breadth First Search, Depth First Search,

Spanning Trees, Shortest path, Minimal spanning tree )

13 30

4 HASHING AND FILE STRUCTURES :

Hashing: The symbol table, Hashing Functions, Collision-

Resolution Techniques,

File Structure: Concepts of fields, records and files,

Sequential, Indexed and Relative/Random File

Organization, Indexing structure for index files, hashing

for direct files, Multi-Key file organization and access

methods.

06 15

5 Sorting & Searching:

Sorting – Bubble Sort, Selection Sort, Quick Sort, Merge

Sort Searching – Sequential Search and Binary Search

06 15

Reference Books: 1. An Introduction to Data Structures with Applications. by Jean-Paul Tremblay & Paul G.

Sorenson Publisher-Tata McGraw Hill. 2. Data Structures using C & C++ -By Ten Baum Publisher – Prenctice-Hall International. 3. Fundamentals of Computer Algorithms by Horowitz, Sahni,Galgotia Pub. 2001 ed. 4. Fundamentals of Data Structures in C++-By Sartaj Sahani.

5. Data Structures: A Pseudo-code approach with C -By Gilberg & Forouzan Publisher-

Thomson Learning.

Course Outcome:

After learning the course the students should be able:

1. Differentiate primitive and non primitive structures

2. Design and apply appropriate data structures for solving computing problems.

3. Apply sorting and searching algorithms to the small and large data sets.

List of Practical:

At least 10 practical should be performed by students using programming language.

1. Introduction to pointers. Call by Value and Call by reference.

2. Introduction to Dynamic Memory Allocation. DMA functions malloc(), calloc(), free() etc.

3. Implement a program for stack that performs following operations using array.

(a) PUSH (b) POP (c) PEEP (d) CHANGE (e) DISPLAY

4. Implement a program to convert infix notation to postfix notation using stack.

5. Write a program to implement QUEUE using arrays that performs following operations (a)

INSERT (b) DELETE (c) DISPLAY

5. Write a program to implement Circular Queue using arrays that performs following

operations. (a) INSERT (b) DELETE (c) DISPLAY

6. Write a menu driven program to implement following operations on the singly linked list.

(a) Insert a node at the front of the linked list.

(b) Insert a node at the end of the linked list.

(c) Insert a node such that linked list is in ascending order.(according to info. Field)

(d) Delete a first node of the linked list.

(e) Delete a node before specified position.

(f) Delete a node after specified position.

7. Write a program to implement stack using linked list.

8. Write a program to implement queue using linked list.

9. Write a program to implement following operations on the doubly linked list.

(a) Insert a node at the front of the linked list.

(b) Insert a node at the end of the linked list.

(c) Delete a last node of the linked list.

(d) Delete a node before specified position.

10. Write a program to implement following operations on the circular linked list.

(a) Insert a node at the end of the linked list.

(b) Insert a node before specified position.

(c) Delete a first node of the linked list.

(d) Delete a node after specified position.

10. Write a program which create binary search tree.

11. Implement recursive and non-recursive tree traversing methods inorder, preorder and post-

order traversal.

12. Write a program to implement Queue Sort

13. Write a program to implement Merge Sort

14. Write a program to implement Bubble Sort

15. Write a program to implement Binary Search.

Open Ended Problem:

1) Simulate a simple dictionary. Assume each character contains at least 10 vocabularies. Create

an index page for all characters. Retrieve the word using index value. Assume that the index

characters from a to z.

2) Design a simple search engine to display the possible websites upon entering a search query.

Use suitable data structure for storage and retrieval.

3) Design and Develop the index for a text book of at least 100 pages using alphabets.

4) Design a Student Prerequisite Subjects Management System requires the use of linked list or

tree to store different courses and their prerequisites and based on this list it will allow any

student to take any course or not.

5) Write a program that uses the radix sort to sort 1000 random digits. Print the data before and

after the sort. Each sort bucket should be a linked list. At the end of the sort, the data should

be in the original array.

ACTIVE LEARNING ASSIGNMENTS: Preparation of power-point slides, which include videos,

animations, pictures, graphics for better understanding theory and practical work – The faculty will

allocate chapters/ parts of chapters to groups of students so that the entire syllabus to be covered. The

power-point slides should be put up on the web-site of the College/ Institute, along with the names of

the students of the group, the name of the faculty, Department and College on the first slide. The best

three works should submit to GTU.

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–III (NEW) - EXAMINATION – SUMMER 2017

Subject Code: 2130702 Date: 31/05/2017 Subject Name: Data Structure Time: 10:30 AM to 01:00 PM Total Marks: 70 Instructions:

1. Attempt all questions. 2. Make suitable assumptions wherever necessary. 3. Figures to the right indicate full marks.

MARKS

Q.1 Short Questions 14

1 Arithmetic expression evaluation is an explanation of which

data structure?

1

2 How many stacks are needed to implement a queue. Consider

the situation where no other data structure like arrays, linked

list is available.

1

3 A graph containing only isolated nodes is called a ___. 1

4 What is the 2’s complement representation for integer 5 in

modulo 16?

1

5 What is the result of 7+7 using 2’s complement representation

and modulo 16 arithmetic.

1

6 In which type of tree, each leaf node is kept at the same

distance from root?

1

7 What is the reverse polish notation for infix expression a / b

*c ?

1

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

}

1

9 Which of the traversal technique outputs the data in sorted

order in a Binary Search Tree?

1

10 What is common in inorder, preorder and postorder traversal? 1

11 For sorting 1 GB of data with only 100 MB of available main

memory. Which sorting technique will be most appropriate?

1

12 In 2-3 trees, what do leaves contain and what do nonleaf nodes

indicate?

1

13 Consider a situation where swap operation is very costly.

Which of the sorting algorithms should be preferred so that the

number of swap operations are minimized in general?

1

14 Draw tree whose postorder traversal is C B F E G D A 1

2

Q.2 (a) Write an algorithm for finding average of given numbers.

Calculate time complexity. 03

(b) Given Inorder and Preorder traversal, find Postorder traversal.

Inorder traversal = {4, 2, 5, 1, 3, 6}

Preorder traversal = {1, 2, 4, 5, 3, 6}

04

(c) Consider an example where the size of the queue is four

elements. Initially the queue is empty. It is required to insert

symbols ‘A’,’B’ and ‘C’. delete ‘A’ and ‘B’ and insert ‘D’ and

‘E’. Show the trace of the contents of the queue.

07

OR

(c) Insertion sequence of names is

Norma, Roger,John,Bill,Leo,Paul, Ken and Maurice

(i) Show the behavior of creating a lexically ordered

binary tree.

(ii) Insert Kirk. Show the binary tree.

(iii)Delete John. Show the binary tree.

07

Q.3 (a) Write an algorithm to return the value of ith element from top

of the stack. 03

(b) Write an algorithm for inserting an element in a stack,

removing an element from stack . 04

(c) Write algorithm for inserting and deleting an element in

circular queue. 07

OR

Q.3 (a) Consider the expression v1*v2-(v3+v4^v5). Show the tree

corresponding to the expression. 03

(b) What is an ordered tree? What is forest? 04

(c) Explain the structure of indexed sequential file. 07

Q.4 (a) Consider singly linked storage structures,Write an algorithm

which inserts a node into a linked linear list in a stack like

manner.

03

(b) How open addressing can be used for collision resolution? 04

(c) Explain structure of sequential file. Explain processing in

sequential file. 07

OR

Q.4 (a) Consider singly linked storage structures,Write an algorithm

which performs an insertion at the end of a linked linear list. 03

(b) Give definitions

(i) Graph

(ii) Adjacent nodes

04

(c) What is priority queue? Explain the array representation of

priority queue. 07

Q.5 (a) Explain outdegree and indegree. 03

(b) Explain Depth First Search operation. 04

(c) Explain the trace of selection sort on following data.

42,23,74,11,65,58,94,36,99,87 07

OR

Q.5 (a) Write and explain application of queue. 03

(b) Explain Breadth First Search operation. 04

(c) Explain the trace of bubble sort on following data.

42,23,74,11,65,58,94,36,99,87 07

*************

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–III(New) • EXAMINATION – WINTER 2016

Subject Code:2130702 Date:02/01/2017

Subject Name:Data Structure

Time: 10:30 AM to 01:00 PM Total Marks: 70 Instructions:

1. Attempt all questions.

2. Make suitable assumptions wherever necessary.

3. Figures to the right indicate full marks.

MARKS

Q.1 Explain the following terms in brief 14

1 Primitive data structure

2 Non-primitive data structure

3 Linear data structure

4 Non-linear data structure

5 Recursion

6 Time complexity of an algorithm

7 Double-ended queue

8 Priority queue

9 Circular linked list

10 Complete binary tree

11 2-3 tree

12 Minimum spanning tree

13 Degree of vertex

14 Hash collision

Q.2 (a) Write a pseudo-code for PUSH and POP operations of

stack. 03

(b) What is prefix notation? Convert the following infix

expression into prefix.

A + B – C * D * E $ F $ G

04

(c) Write an algorithm to perform various operations (insert,

delete and display) for simple queue. 07

OR

(c) Write differences between simple queue and circular

queue. Write an algorithm for insert and delete operations

for circular queue.

07

Q.3 (a) Convert the following infix expression into postfix.

A + B – C * D * E $ F $ G 03

(b) Write algorithm(s) to perform INSERT_FIRST (to insert

a node at the first position) and REVERSE_TRAVERSE

(to display the data in nodes in reverse order) operations

in doubly linked list.

04

(c) Write a ‘C’ program to implement stack using linked list. 07

OR

Q.3 (a) Enlist and briefly explain various applications of stack. 03

(b) Discuss various rehashing techniques. 04

(c) Write ‘C’ functions to implement INSERT_FIRST (to

insert a node at the first position), DELETE_FIRST (to

delete a node from the first position), DELETE_LAST

(delete a node from the last position) and TRAVERSE (to

display the data in nodes) operations in circular linked

list.

07

2

Q.4 (a) Write an algorithm for Binary search method. 03

(b) Write a ‘C’ program for Bubble sort. 04

(c) Sort the following numbers using (i) Selection sort (ii)

Quick sort:

10 50 0 20 30 10

07

OR

Q.4 (a) Write a ‘C’ function for Selection sort. 03

(b) Write an algorithm for Quick sort. 04

(c) Explain Depth First Search and Breadth First Search in

graphs with an example. 07

Q.5 (a) Draw a binary expression tree for the following and

perform preorder traversal for the same:

(A + B $ C) + (D + E * F)

03

(b) Construct a binary search tree for the following and

perform inorder and postorder traversals:

5 9 4 8 2 1 3 7 6

04

(c) Write ‘C’ functions for: inserting a node, postorder

traversal and counting total number of nodes for binary

search tree.

07

OR

Q.5 (a) Explain AVL trees. 03

(b) Construct a binary search tree from the following

traversals:

Inorder: 3 4 5 6 7 9 17 20 22

Preorder: 9 4 3 6 5 7 17 22 20

04

(c) Write Kruskal’s algorithm for minimum spanning tree with

an example. 07

*************

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY

BE - SEMESTER–III(New) EXAMINATION – SUMMER 2016

Subject Code:2130702 Date:09/06/2016

Subject Name:Data Structure Time:10:30 AM to 01:00 PM Total Marks: 70 Instructions:

1. Attempt all questions.

2. Make suitable assumptions wherever necessary. 3. Figures to the right indicate full marks.

MARKS

Q.1 Short Questions 14

1 Define primitive data structure.

2 Explain space and time complexity.

3 What is the time complexity of Quicksort algorithm in the worst

case?

4 List the applications of Stack.

5 Define graph.

6 Explain degree of a vertex in a graph.

7 List the applications of Graphs.

8 List the applications of Binary trees.

9 Define B-Tree.

10 Describe the time complexity of Binary search algorithm.

11 What is hash collision?

12 Write ‘C’ structure of Binary tree.

13 Write ‘C’ structure of Singly linked list.

14 Define priority queue.

Q.2 (a) Write an algorithm for simple queue with ENQUEUE operations. 03

(b) Write an algorithm to reverse a string using stack. 04

(c) Write a program to implement stack using linked list. 07

OR

(c) Write a program to implement circular queue using array. 07

Q.3 (a) Evaluate the following postfix expression using stack:

(a) 9 3 4 * 8 + 4 / - (b) 5 6 2 + * 1 2 4 / - + 03

(b) Explain the concept of circular queue. Compare circular queue with

simple queue. 04

(c) Explain insert and delete operations in AVL trees with suitable

examples. 07

OR

Q.3 (a) Explain double ended queue. 03

(b) Write ‘C’ functions to implement DELETE_FIRST_NODE and

TRAVERSE operations in doubly linked list.

04

(c) With a suitable example, explain steps for conversion of a general

tree into a binary tree.

07

Q.4 (a) Explain Sequential search method. 03

(b) Explain Threaded binary trees with suitable examples. 04

(c) Write an algorithm for Selection sort method. Explain each step

with an example.

07

OR

Q.4 (a) Explain Depth First Search in graphs with an example. 03

(b) Explain Binary search method. 04

2

(c) Write an algorithm for Insertion sort method. Explain each step with

an example. 07

Q.5 (a) Explain Breadth First Search in graphs with an example. 03

(b) Construct a binary tree from the traversals given below:

Inorder: 1 3 4 6 7 8 10 13 14

Preorder: 8 3 1 6 4 7 10 14 13

04

(c) Explain various Hash collision resolution techniques with examples. 07

OR

Q.5 (a) Explain Sequential file organizations and list its advantages and

disadvantages. 03

(b) Draw a Binary expression tree for the following and perform

preorder traversal: (A $ B $ C) + (D – E * F) 04

(c) Write Prim’s algorithm for minimum spanning tree with an

example. 07

*************

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–III (New) EXAMINATION – WINTER 2015

Subject Code:2130702 Date:02/01/2016

Subject Name: Data Structures

Time: 2:30pm to 5:00pm Total Marks: 70 Instructions:

1. Attempt all questions.

2. Make suitable assumptions wherever necessary.

3. Figures to the right indicate full marks.

MARKS

Q.1 Short Questions 14

1 Define data structure. 1

2 List operations performed on a stack. 1

3 Mention variations of the queue data structure. 1

4 What is the worst case time complexity of searching an

element in a list? How?

1

5 Mention one operation for which use of doubly linked

list is preferred over the singly linked list.

1

6 Write an algorithm/steps to traverse a singly linked list. 1

7 Define: Height of a tree. 1

8 What is the height of a complete binary with n nodes? 1

9 Write two simple hash functions. 1

10 What is a header node and what is its use? 1

11 Is Queue a priority queue? Justify. 1

12 What is the complexity of binary search algorithm? 1

13 Name two divide and conquer algorithms for sorting. 1

14 Give two applications of graphs. 1

Q.2 (a) Write an algorithm to check if an expression has

balanced parenthesis using stack. 03

(b) What is postfix notation? What are its advantages?

Convert the following infix expression to postfix.

A$B-C*D+E$F/G

04

(c) Write a C program to implement a stack with all

necessary overflow and underflow checks using array. 07

OR

(c) Write a C program to implement a circular queue using

array with all necessary overflow and underflow checks. 07

Q.3 (a) Evaluate the following postfix expression using a stack.

Show the stack contents.

AB*CD$-EF/G/+

A=5, B=2, C=3, D=2, E=8, F=2, G=2

03

(b) Perform following operations in a circular queue of

length 4 and give the Front, Rear and Size of the queue

after each operation.

1) Insert A, B

2) Insert C

3) Delete

4) Insert D

04

2

5) Insert E

6) Insert F

7) Delete

(c) Write a program to insert and delete an element after a

given node in a singly linked list. 07

OR

Q.3 (a) Explain various applications of queue. 03

(b) Differentiate between arrays and linked list. 04

(c) Create a doubly circularly linked list and write a

function to traverse it. 07

Q.4 (a) Define complete binary tree and almost complete binary

tree. 03

(b) Explain deletion in an AVL tree with a suitable

example. 04

(c) What is binary tree traversal? What are the various

traversal methods? Explain any two with suitable

example.

07

OR

Q.4 (a) Mention the properties of a B-Tree. 03

(b) Construct a binary tree from the traversals given below:

Inorder: 1, 10, 11, 12, 13, 14, 15, 17, 18, 21

Postorder: 1, 11, 12, 10, 14, 18, 21, 17, 15, 13

04

(c) What is a binary search tree? Create a binary search tree

for inserting the following data.

50, 45, 100, 25, 49, 120, 105, 46, 90, 95

Explain deletion in the above tree.

07

Q.5 (a) Insert the following elements in a B-Tree.

a, g, f, b, k, c, h, n, j 03

(b) Apply quicksort algorithm to sort the following data.

Justify the steps.

42, 29, 74, 11, 65, 58

04

(c) What is hashing? What are the qualities of a good hash

function? Explain any two hash functions in detail. 07

OR

Q.5 (a) List advantages and disadvantages of Breadth First

Search and Depth First Search. 03

(b) What is a minimum spanning tree? Explain Kruskal’s

algorithm for finding a minimum spanning tree. 04

(c) Discuss various methods to resolve hash collision with

suitable examples. 07

*************

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER– III (NEW) EXAMINATION – SUMMER 2015

Subject Code: 2130702 Date:09/06/2015

Subject Name: DATA STRUCTURE

Time: 02.30pm-05.00pm Total Marks: 70 Instructions:

1. Attempt all questions.

2. Make suitable assumptions wherever necessary.

3. Figures to the right indicate full marks.

Q.1 (a) Write a ‘C’ program for insertion sort and discuss its efficiency. 07

(b) Briefly explain various linear and non-linear data structures along with their

applications.

07

Q.2 (a) Write ‘C’ functions to: (1) insert a node at the end (2) delete a node from the

beginning of a doubly linked list.

07

(b) Write an algorithm to reverse a string of characters using stack. 07

OR

(b) Compare: (1) Linked-list and Array (2) Circular queue and Simple Queue. 07

Q.3 (a) Convert (A + B) * C – D ^ E ^ (F * G) infix expression into prefix format

showing stack status after every step in tabular form.

07

(b) Write an algorithm to implement insert and delete operations in a simple queue. 07

OR

Q.3 (a) Describe: (1) Recursion (2) Priority Queue (3) Tower of Hanoi 07

(b) Write a ‘C’ functions to: (1) insert a node at beginning in singly linked list (2)

insert an element in circular queue.

07

Q.4 (a) With figure, explain the following terms: (1) Depth of a tree (2) Sibling nodes (3)

Strictly binary tree (4) Ancestor nodes (5) Graph (6) Minimum spanning tree (7)

Degree of a vertex

07

(b) Generate a binary search tree for following numbers and perform in-order and

post-order traversals: 50, 40, 80, 20, 0, 30, 10, 90, 60, 70

07

OR

Q.4 (a) Explain Right-in-threaded, left-in-threaded and full-in-threaded binary trees. 07

(b) Write Kruskal’s algorithm for minimum spanning tree and explain with an

example.

07

Q.5 (a) Describe various collision resolution techniques in hashing. 07

(b) Write an algorithm for binary search method and discuss its efficiency. 07

OR

Q.5 (a) Explain Sequential, Indexed Sequential and Random file organizations. 07

(b) Write recursive ‘C’ functions for (1) in-order (2) pre-order and (3) post-order

traversals of binary search tree.

07

*************

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–III • EXAMINATION – WINTER • 2014

Subject Code: 2130702 Date: 01-01-2015

Subject Name: Data Structure

Time: 02.30 pm - 05.00 pm Total Marks: 70 Instructions:

1. Attempt all questions.

2. Make suitable assumptions wherever necessary.

3. Figures to the right indicate full marks.

Q.1 (a) Write short note on performance analysis and performance measurement of an

algorithm.

07

(b) Write a selection sort algorithm and also discuss its efficiency. 07

Q.2 (a) What is Stack? List out different operation of it and write algorithm for any two

operation.

07

(b) Write a 'C' program or an algorithm to convert infix expression without parenthesis to

postfix expression.

07

OR

(b) Write user defined C function for inserting an element into circular queue. 07

Q.3 (a) What is a Queue? Write down drawback of simple queue. Also write an algorithm for

deleting an element from circular queue

07

(b) Write down advantages of linked list over array and explain it in detail. 07

OR

Q.3 (a) Write an algorithm to delete a node from doubly linked list. 07

(b) Convert A+(B*C-(D/E^F)*G) infix expression into postfix format showing stack

status after every step in tabular form.

07

Q.4 (a) Define the following terms. 1) Graph 2) Tree 3) Multi graph 4) Weighted graph

5) Elementary path 6) Complete Binary tree 7) Descendent node

07

(b) List out different traversal way of tree and demonstrate any two with example. 07

OR

Q.4 (a) Write an algorithm to delete a node from tree. 07

(b) Explain BFS and DFS in detail. 07

Q.5 (a) Explain AVL tree with example. 07

(b) List out different hash methods and explain any three. 07

OR

Q.5 (a) Write down precondition and algorithm of binary search method. 07

(b) Explain file in terms of fields, records and database. 07

*************

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–III (OLD) - EXAMINATION – SUMMER 2017

Subject Code: 130702 Date: 02/06/2017 Subject Name: Data and File Structure Time: 10:30 AM to 01:00 PM Total Marks: 70 Instructions:

1. Attempt all questions. 2. Make suitable assumptions wherever necessary. 3. Figures to the right indicate full marks.

Q.1 (a) What does abstract data type means? Briefly explain linear and non linear data

structures.

07

(b) Explain PUSH and POP operation of the stack with algorithm. 07

Q.2 (a) Convert following infix expressions to the postfix expressions. Shows stack

trace.

A/B$C+D*E/F-G+H

(A+B)*D+E/(F+G*D)+C

07

(b) Write an algorithm to convert infix to postfix expression and explain it with

example.

07

OR

(b) Write a Program to perform insert and delete operations on a circular Queue. 07

Q.3 (a) Define recursion. What care should be taken in writing recursive function? Give

a recursive solution for the problem of “Towers of Hanoi”.

07

(b) Write an algorithm to insert and delete a node in Doubly Linked List. 07

OR

Q.3 (a) Differentiate between stack & queue. Also explain priority queue with example. 07

(b) Write a program to search an element in a linked list. 07

Q.4 (a) Create a Binary Search Tree for the following data and do in-order, Preorder and

Post-order traversal of the tree.

40, 60, 15, 4, 30, 70, 65, 10, 95, 25, 34

07

(b) Define the following with example :

Strictly binary tree

Complete binary tree

07

OR

Q.4 (a) How graph can be represented? Write an algorithm for Breadth First Search

Traversal of a Graph. 07

(b) What is an AVL tree? Explain the different types of rotations used to create an

AVL tree with suitable examples.

07

Q.5 (a) What is hashing? Explain hashing functions. 07

(b) Write a short note on inverted key file organization 07

OR

Q.5 (a) Define Hash Clash. Explain Primary Clustering, secondary clustering, rehashing

and double hashing.

07

(b) Write a short note on indexed file organization. 07

*************

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–III(OLD) • EXAMINATION – WINTER 2016

Subject Code:130702 Date:04/01/2017

Subject Name:Data and File Structure

Time: 10:30 AM to 01:00 PM Total Marks: 70 Instructions:

1. Attempt all questions.

2. Make suitable assumptions wherever necessary.

3. Figures to the right indicate full marks.

Q.1 (a) What is data structure? Explain different types of data structures with

applications.

07

(b) Derive the formula to calculate address A[i, j] of 2-D array, for a Row-major

order storage representation.

A 2-D array defined as A[r, c] where 1 ≤ r ≤ 4, 5≤ c ≤ 8, requires 2 bytes of

memory for each element. If the array is stored in Row-major order form,

calculate the address of A[3,7] given the Base address as 2000.

07

Q.2 (a) Discuss and compare array and linked list. 07

(b) Discuss importance of hashing. Also discuss one of the method of hashing with

an example.

07

OR

(b) Discuss the structure of sequential and indexed file organization. 07

Q.3 (a) Write algorithm OR code for PUSH, POP and DISPLAY function of the

STACK.

07

(b) Convert the following infix expression to postfix form using Stack.

(( A – (B + C)) × D) / (E + F)

07

OR

Q.3 (a) Write algorithm OR code for INSERT, DELETE and DISPLAY function of the

QUEUE.

07

(b) What is a priority queue? Discuss the array implementation of priority queue. 07

Q.4 (a) Write C code to insert a node at the end of a doubly link list. 07

(b) Write an algorithm to merge two simple link lists having initial address L1 and

L2 respectively. Also write algorithm to display the list.

07

OR

Q.4 (a) Write algorithm OR code for DELETE and DISPLAY functions of Circular

Link List.

07

(b) Write C code for the following operations for a simple link list.

i. Reverse : to reverse the link list

ii. Max : to find the largest element from the link list.

07

Q.5 (a) Write a non-recursive algorithm for Preorder traversal of a binary tree 07

(b) What is a sparse matrix? Explain memory representation of a sparse matrix. 07

OR

Q.5 (a) Discuss DFS and BFS. 07

(b) Discuss Inorder and Postorder traversal of a binary tree. 07

*************

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY

BE - SEMESTER–III EXAMINATION – SUMMER 2016

Subject Code:130702 Date:09/06/2016

Subject Name:Data and File Structure

Time:10:30 AM to 01:00 PM Total Marks: 70

Instructions: 1. Attempt all questions.

2. Make suitable assumptions wherever necessary.

3. Figures to the right indicate full marks.

Q.1 (a) Give various applications of stack and queue. 06

(b) What is a binary search tree? Explain with an example and state its applications. Also explain deletion in a binary search tree.

Discuss the advantages and disadvantages of linked list over array.

05

(c) 03

Q.2 (a) Write a ‘C’ program to implement a stack. Do check for overflow and

underflow. 07

(b) What is hashing? Explain the collision resolution techniques. 07

OR

(b) Define recursion. What care should be taken in writing recursive function?

Give a recursive solution for the problem of “Towers of Hanoi”. 07

Q.3 (a) Consider a circular queue of size 6.

Let Front =2, Rear =4, and Queue : __, L, M, N, __, __

Describe the queue as following operations are performed.

1) Add O

2) Add P

3) Delete

4) Delete

5) Add Q, R, S

6) Delete

07

(b) What is importance of postfix notation? Write the algorithm for converting

an infix expression to postfix notation.

07

OR

Q.3 (a) Convert the following expression to postfix notation. Show the contents of

the stack while conversion.

12 / (7 - 3) + 2 * (1 + 5)

07

(b) What is a priority queue? Discuss the array implementation of priority queue. 07

Q.4 (a) Write an algorithm to insert a node before a given node in a singly linked list.

Is it advantageous to use a doubly linked list for this operation? Explain.

07

(b) Create a B-tree of order 5 by inserting the following data values.

D, H, K, Z, B, P, Q, E, A, S, W, T, C, L, N, Y, M

07

OR

Q.4 (a) What is an AVL tree? Explain the different types of rotations used to create

an AVL tree with suitable examples.

07

(b) Construct an expression tree for the following expression.

A+(B+C*D+E)+F/G.

Make a preorder traversal of the resultant tree.

07

2

Q.5 (a) A binary tree T has 9 nodes. The inorder and preorder traversals of T give the

following sequence of nodes.

Inorder: E A C K F H D B G

Preorder: F A E K C D H G B

Draw the tree T.

07

(b) What is a graph? Discuss the Adjacency Matrix and Adjacency List

representation of graphs with an example.

07

OR

Q.5 (a) Define the following with respect to a graph:

1) Path 2) degree 3) Cycle 4) Spanning tree 5) Directed Graph

07

(b) Consider the following graph: Create a minimum spanning tree using the

Kruskal’s algorithm.

07

*************

A

B C D

E

F

G H

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–III EXAMINATION – WINTER 2015

Subject Code:130702 Date:02/01/2016

Subject Name: Data and File Structure

Time: 2:30pm to 5:00pm Total Marks: 70 Instructions:

1. Attempt all questions.

2. Make suitable assumptions wherever necessary.

3. Figures to the right indicate full marks.

Q.1 (a) What does abstract data type means? Briefly explain linear and non linear data

structures.

07

(b) Given a two dimensional array A1(1:8, 7:14) stored in row-major order with base

address 100 and size of each element is 4 bytes, find address of the element A1(4, 12).

07

Q.2 (a) Write an algorithm to implement PUSH and POP Operations on Stack.

07

(b) Write an algorithm for evaluation of postfix expression and evaluate the

following expression showing every status of stack in tabular form.

5 6 2 - * 4 9 3 / + *

07

OR

(b) Enlist difference between recursive and iterative algorithms. Write any one

recursive function showing the stack contents while function call and return.

07

Q.3 (a) Write a program to perform insert and delete routines on a queue. 07

(b) Write advantages and disadvantages of linked list, doubly linked list and

circular linked list with example.

07

OR

Q.3 (a) Explain priority queue and dequeue. Write an algorithm/program for insert

routine in input restricted dequeues.

07

(b) Write a program to search an element in a linked list.

07

Q.4 (a) Create a Binary Search Tree for the following data and do in-order, Preorder

and Post-order traversal of the tree.

40, 60, 15, 4, 30, 70, 65, 10, 95, 25, 34

07

(b) Define the following with example :

Strictly binary tree

Complete binary tree

07

OR

Q.4 (a) What is Binary Search Tree? Write recursive algorithm/program to implement

in-order traversal of the Binary Search Tree.

07

2

(b) Define height balanced tree. Construct a height balanced binary tree (AVL tree)

for the following data

32,16,44,52,78,40,12,22,02,23

07

Q.5 (a) What is hashing? Briefly explain various methods of hashing. 07

(b) Explain with example DFS and BFS traversal of graph. 07

OR

Q.5 (a) What is File Structure? Explain any one File Structure in detail. 07

(b) Show how graph can be represented using example? How path matrix can be

found out using adjacency matrix.

07

*************

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE – SEMESTER III– • EXAMINATION – SUMMER 2015

Subject Code:130702 Date:09/06/2015

Subject Name: Data and File structure

Time: 02.30pm-05.00pm Total Marks: 70 Instructions:

1. Attempt all questions.

2. Make suitable assumptions wherever necessary.

3. Figures to the right indicate full marks.

Q.1 (a)

(i) Write algorithm to sum values in vector V and find out the execution time

required.

(ii) Explain the equation that finds out the address of the element of the one

dimensional array. Assume necessary data.

07

04

03

(b)

(i) Convert the following Polish(prefix) expression to Reverse Polish(suffix)

notation

a. ++abc

b. +a+bc

c. +a*bc

d. *a+bc

(ii) Does a time sharing computer use a queue or stack? Explain.

07

04

03

Q.2 (a) Write an algorithm for inserting a node and deleting a node in doubly linked linear

list.

07

(b) Write steps of procedure to insert an element to the top of the stack and remove

top element from a stack.

07

OR

(b) What is the advantage of Polish expression over infix notation? Write an

algorithm to convert an infix expression into reverse Polish expression.

07

Q.3 (a)

(i) Write a recursive algorithm to find factorial.

(ii) Which type of allocation is called linked allocation? Define singly linked

linear list.

07

04

03

(b)

(i) Explain the threaded storage representation for binary trees.

(ii) Define the inorder, postorder and preorder traversal for the following tree.

07

04

03

OR

Q.3 (a)

(i) What are the advantages of circular lists over singly linked list?

(ii) Explain – Why doubly linked lists are much more efficient with respect to

deletions than singly linked lists?

07

04

03

A

B

C

D

E G

F

2

(b)

(i) Define adjacency matrix. When two digraphs are considered to be

equivalent?

(ii) Explain the breadth first search and depth first search tree traversal on the

following graph.

07

04

03

Q.4 (a) Write an algorithm for inserting and deleting an element from queue. 07

(b)

(i) Define 2-3 tree. Describe the characteristic of 2-3 tree.

(ii) Write the characteristics of AVL tree.

07

04

03

OR

Q.4 (a) What is a circular queue? Write an algorithm for inserting and deleting an element

from a circular queue.

07

(b)

(i) Explain the structure of sequential file.

(ii) Explain the structure of indexed sequential files.

07

04

03

Q.5 (a) What is collision? Explain two broad classes of collision resolution techniques. 07

(b) Explain the binary search method. Write an algorithm for performing a binary

search.

07

OR

Q.5 (a) What is hashing? Explain hashing functions. 07

(b) Explain the multi key file organization and access methods. 07

*************

A

B C D E

F

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–III • EXAMINATION – WINTER • 2014

Subject Code: 130702 Date: 01-01-2015

Subject Name: Data and File Structure

Time: 02.30 pm - 05.00 pm Total Marks: 70 Instructions:

1. Attempt all questions.

2. Make suitable assumptions wherever necessary.

3. Figures to the right indicate full marks.

Q.1 (a) What is data structure? Explain linear and non-linear data structure with

example.

03

(b) Discuss best case, average case and worst case time analysis with example. 04

(c) Explain PUSH and POP operation of the stack with algorithm. 07

Q.2 (a) Write an algorithm to perform insert and delete operation on single queue. 07

(b) (a) Convert the following infix expression to postfix prefix form.

(( A –( B +C))* D) $ ( E +F )

(b) Evaluate the following infix expression.

2 $ 3 + 5 * 2 $ 2 – 6 / 6

07

OR

(b) Define the following term : Path, Cycle, Degree of vertex, Sibling, Height

Balanced Tree, Strictly binary tree, in degree

07

Q.3 (a) Explain delete operation in doubly link list. 07

(b) What is the difference between queue & Dqueue . Explain insertion operation in

Dqueue.

07

OR

Q.3 (a) Write an algorithm to reverse a given single link list. 07

(b) Create a binary search tree by inserting following nodes in sequence.

68,85,23,38,44,80,30,108,26,5,92,60

Write inorder,preorder and post order traversal of the above generated Binary

search tree.

07

Q.4 (a) Write an algorithm to perform traversal of Binary search tree 07

(b) Explain AVL tree with the help of an example also show insertion and deletion

with the help of an example.

07

OR

(a) Write a short note on :spanning tree , threaded binary tree 07

(b) Explain the basic two techniques for Collision-resolution in Hashing with

example. Also explain primary clustering.

07

Q.5 (a) Compare and contrast Prim’s and Kruskal’s algorithm with the help of an

example

07

(b) Explain various multiple key access file organization in brief with

advantages and disadvantages of each method.

07

OR

Q.5 (a) What do you mean by Hashing? Explain any FOUR hashing techniques 07

(b) Explain and differentiate BFS and DFS graph traversal method with suitable

graph.

07

*************

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–III • EXAMINATION – SUMMER • 2014

Subject Code: 130702 Date: 04-06-2014

Subject Name: Data and File Structure

Time: 02.30 pm - 05.00 pm Total Marks: 70 Instructions:

1. Attempt all questions.

2. Make suitable assumptions wherever necessary.

3. Figures to the right indicate full marks.

Q.1 (a) Answer the following

i) Obtain the expression tree from the following post fix representation

ab+cde+**

ii) Define complete binary tree and a full binary tree

iii) List the features of a good hash function

iv) List the uses of stack, queue and linklists

v) What are priority queues? Explain it’s uses

10

(b) Evaluate the following postfix expression using stack

AB+CD/*GH*+ ((where A=2,B=4,C=6,D=3,G=8,H=7)

04

Q.2 (a) Write an algorithm to convert infix to postfix expression and explain it with

example

07

(b) Translate the following string into polish notation and trace the content of stack

A - ( B / C + (D % E * F) / G ) * H

07

OR

(b) i) Consider a dequeue given below which has LEFT=1, RIGHT=5

_ A B C D E _ _ _ _ .

Now perform the following operations on the dequeue

1. Add F on the left.

2. Add G on the right.

3. Add H on the right.

4. Delete two alphabets from left

5. Add I on the right

ii) Differentiate peep() and pop() functions

04

03

Q.3 (a) Write a program in any programming language to concatenate two doubly linked

lists.

07

(b) Write an algorithm to insert a node in an ordered linked list 07

OR

Q.3 (a) Give the preorder and Inorder traversal of the tree given in fig 1. 07

(b) Given the following traversals create a binary tree from that. Also give the

postorder traversal for the same.

preorder = {7,10,4,3,1,2,8,11}

inorder = {4,10,3,1,7,11,8,2}

07

Q.4 (a) Explain DFS and BFS with example 07

(b) Construct a binary search tree for the following sequence. Also do the inorder

and postorder traversal for the same

45,56,39,12,34,78,54,67,10,32,89,81

07

OR

Q.4 (a) What is a spanning tree? Find the minimum spanning tree for the graph shown in

fig 2.

07

2

(b) Write short notes on (i) Height Balanced Tree. (ii) Indexed-Sequential Files

07

Q.5 (a) What do you mean by Hashing? Explain any FOUR hashing techniques

07

(b) Define the following terms

i) Node

ii) Sibling

iii) Path

iv) Indegree & outdegree of a vertex

v) Connected graph

07

OR

Q.5 (a) Compare and contrast Prim’s and Kruskal’s algorithm with the help of an

example

07

(b) Explain AVL tree with the help of an example also show insertion and deletion

with the help of an example.

07

Fig: 1. Fig :2

*************

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–III • EXAMINATION – WINTER 2013

Subject Code: 130702 Date: 07-12-2013

Subject Name: Data and File Structure

Time: 02.30 pm - 05.00 pm Total Marks: 70 Instructions:

1. Attempt all questions.

2. Make suitable assumptions wherever necessary.

3. Figures to the right indicate full marks.

Q.1 Answer the following. 14

(a) What do you mean by Data Structure? Give the difference between

Primitive and Non-primitive data structures.

(b) Explain Multidimensional Array. How it is stored in memory?

(c) Write a short note on threaded binary tree

(d) Convert following Infix expression into Postfix expression. Show each

step.

A + B ^ C^ D - E * F / G

Q.2 (a) What is Stack? Write down algorithms for performing POP and PEEP

operations on a stack.

07

(b) Answer the following.

(i) Compare Simple Queue and Circular Queue.

(ii) Define the following terms:

Path, Cycle, Degree of vertex, Sibling.

07

OR

(b) Write an algorithm to implement insert and delete operation into a Circular

Queue using array representation of Queue.

07

Q.3 Answer the following.(Any TWO) 14

(a) Write an algorithm/program to Delete a node from Doubly Linked List.

(b) Write an algorithm/program to “Insert a node at End” operation of Singly

Linked List.

(c) Define tree. Write an algorithm to do in-order traversal and post-order

traversals of Binary Search Tree.

Q.4 Answer the following.(Any TWO) 14

(a) Create a Binary Search Tree for the following data and do Inorder, Preorder

and Postorder traversal of the tree.

40, 65,25, 55, 10,70,30,50,15,80,75

(b) Define Graph. Write an algorithm to do BFS traversal of a Graph.

(c) Write short notes on (i) Height Balanced Tree. (ii) Indexed-Sequential

Files.

Q.5

(a)

Answer the following.(Any TWO)

Explain matrix and linked list representation of a Graph. Also compare

BFS and DFS methods of Graph Traversal.

14

(b) What do you mean by Hashing? Explain any FOUR hashing techniques.

(c) Explain various multiple key access file organization in brief with

advantages and disadvantages of each method.

*************

2

1/2

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–III • EXAMINATION – SUMMER 2013

Subject Code: 130702 Date: 04-06-2013 Subject Name: Data and File Structure Time: 02.30 pm - 05.00 pm Total Marks: 70 Instructions:

1. Attempt all questions. 2. Make suitable assumptions wherever necessary. 3. Figures to the right indicate full marks.

Q.1 (a) Define sparse matrix. Briefly explain representation of sparse matrix with the

help of link list and array. 07

(b) Define data structure. Briefly explain linear and non linear data structures with their applications

07

Q.2 (a) Convert following infix expressions to the postfix expressions. Shows stack

trace. A/B$C+D*E/F-G+H (A+B)*D+E/(F+G*D)+C

07

(b) Write an algorithm for stack operations Push, Pop and Empty. Assume stack is implemented using array

07

OR (b) What is the advantage of postfix expression over infix expression? Write an

algorithm of postfix expression evaluation. 07

Q.3 (a) Write a C function search (l, x) that accepts a pointer l to a list of integers

and returns a pointer to a node containing x if it exists and the null pointer otherwise.

07

(b) Write insert and remove functions for queue if it is implemented using circular link list.

07

OR Q.3 (a) Briefly explain advantages of doubly link list over singly link list. Write

function delete (p, &x) which delete the node pointed by p in doubly link list. 07

(b) Briefly explain advantages of binary search tree. Construct binary search tree for the following elements 8,3,11,5,9,12,13,4,6,20

07

Q.4 (a) The inorder and preorder traversal of a binary tree are

d b e a f c g a b d e c f g respectively Construct binary tree and find its postorder traversal.

07

(b) Define Directed graph, spanning tree and minimum spanning tree. Find minimum spanning tree for the graph shown in Figure 1.

07

OR Q.4 (a) Answer the following

1. The height of a binary tree is the maximum number of edges in any root to leaf path. Define the maximum number of nodes in a binary tree of height h.

2. Consider a B-tree in which the maximum number of keys in a node is

01

2/2

5. What is the minimum number of keys in any non-root node? 3. Define threaded binary tree. What are the advantages of threaded

binary tree? Give example of threaded binary tree.

01 05

(b) The Breadth First Search algorithm has been implemented using the queue data structure. Find breadth first search for the graph shown in Figure 2 with starting node M

07

Q.5 (a) 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 with hash function h(k) = k mod 10 and linear probing. What is the resultant hash table?

07

(b) Define AVL tree. Construct AVL tree for following data 10,20,30,40,50,60,70,80

07

OR Q.5 (a) What are the advantages of Multi way search tree over binary search tree?

Construct 2-3 tree for the following data 12, 50, 85, 6, 10, 37, 100, 120, 25, 70

07

(b) Define following 1. Strictly binary tree 2. Index sequential search 3. Hashing

07

*************

Figure 1

Figure 2