Dsa Assignment

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

DAVIET CSE

DEPT
DSA ASSIGNMENT

ASSIGNMENT-1

INTRODUCTION TO DATA STRUCTURE


1. Define data structure. List the various linear and non-linear data structures
and explain them in brief.
2. What does abstract data type means? Briefly explain linear and non linear
data structures.
3. Discuss the basic operations performed with linear structure.
4. Explain the dynamic memory allocation functions in C.
5. Differentiate the following terms:(a). Liner and Non-Linear Data Structures
6. Define following terms: Time and space complexity of an algorithm.
7. Discuss best case, average case and worst case time analysis with example.

8. Write short note on performance analysis and performance measurement of


an algorithm.
9. Write algorithm to sum values in vector V and find out the execution time
required.

ASSIGNMENT-2

LINEAR DATA STRUCTURE

1. Define sparse matrix. Briefly explain representation of sparse matrix with


the help of link list and array.
2. 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).
3. Given a two dimensional array Z1(2:9, 9:18) stored in column-major
order with base address 100
and size of each element is 4 bytes, find address of the element Z1(4, 12).
Stack:
DAVIET CSE
1. What is stack? Explain basic primitive operation of stack with examp DEPT
2. Write a C program to implement a stack with all necessary overflow and
underflow checks using array.
3. Write an algorithm to reverse a string of characters using stack.
4. What is the advantage of Polish expression over infix notation? Write an
algorithm to convert an infix expression into reverse Polish expression
5. Convert the given infix expression to postfix expression.
1) A + ( (B – C) * (D – E) + F) / G ) $ (H – J)
2) (A + B) * (C – D) $ E * F
3) (A + B) * (C ^ (D – E) + F) – G
4) A + B * C
5) A + B * C ^ D – E
6) A + [(B +C) + (D + E) * F] / G
7) (A + B) * C / D + E ^ F /G
8) (A + B) * C / D
9) ((A + B – C / D) / E)
10) A / (B – C / D ^ E) + F
11) A – B / (C * D ^ E)
2. Evaluate the following expressions.
1) 5 + 4 * 2
2) 4 + 2 * 5 ^ 2 + 9 / 3 – 1 * 8
3) 40 25 + 20 5 * 3 + *
4) 9 + 5 * 7 – 6 ^ 2 + 9 / 3
5) 8 * 2 -1 + 7 * 5
6. Evaluate the following Postfix expression assume A=1, B=2, C=3
1) A B + C – B A + C - +
2) A B C + * C B A - + *
DAVIET CSE
DEPT

ASSIGNEMT-3

Sorting
1. Name two divide and conquer algorithms for sorting.
2. Apply quick sort algorithm to sort the following data. Justify the steps. 42,
29, 74, 11, 65, 58
3. Write a ‘C’ program for insertion sort and discuss its efficiency.
4. Write an algorithm/C Function to implement Selection Sort Method.
5. Write an algorithm/C Function to implement Bubble Sort Method.
6. Write an algorithm/C Function to implement Quick Sort Method.
7. Write an algorithm/C Function to implement Merge Sort Method.
8. Using Quick sort give tracing for following set of numbers 42,
11,23,58,65,72,36,99.

Searching

1. Write down precondition and algorithm of binary search meth

ASSIGNMENT-4 Linked List:


Singly Linked List

1. Differentiate between arrays and linked list.


2. Write an algorithm to implement ascending priority queue using singular linear linked list
which has insert() function such that queue remains ordered list. Also implement remove()
function
3. Write an algorithm to reverse a given single link list.
4. Write a program to insert and delete an element after a given node in a singly linked list. Write
a function in any programming language to insert an element in an ordered list.

Doubly Linked List


1. Write a c/c++ program to add two polynomials represented using doubly linear linked list.
Also write necessary functions to represent polynomial using doubly linear link list.
2. Write a program in any programming language to concatenate two doubly linked lists.
3. 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.
Circular Linked List
1. State the advantages of circular and doubly linked lists over a singly linked list. \
2. Write an algorithm to perform each of the following operations on Circular singly linked list
using header node
1. add node at the end
2. add node at beginning
ASSIGNEMENT- 5 NONLINEAR DATA STRUCTURE
Tree:
1. Discuss following with reference to trees. Tree
DAVIET CSE
. Node Parent node Child node DEPT

Link . Root Leaf Level


Height Degree Binary tree Complete binary tree
Strictly binary tree Threaded binary tree Forest Sibling
Binary search tree Height balanced tree Almost complete binary Full binary tree
tree
.

2. What are the applications of trees?


3. Construct a tree for the given inorder and postorder traversals Inorder DGBAHEICF
Postorder GDBHIEFCA
4. Give the preorder and Inorder traversal of the tree given in below fig.

5. Construct binary search tree for the following data


1. 10,3,15,22,6,45,65,23,78,34,5.
2. 50, 60, 25, 40, 30, 70, 35, 10, 55, 65, 5
3. 40, 65,25, 55, 10,70,30,50,15,80,75
4. 45,56,39,12,34,78,54,67,10,32,89,81 0
5. 60, 15, 4, 30, 70, 65, 10, 95, 25, 34
Find its inorder, preorder and postorder travesal
6. Define height of the binary tree. Define height balanced tree with its advantages. Construct a
height balanced binary tree (AVL tree) for the following data 42,06,54,62,88,50,22,32,12,33
7. 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

8. Why is Threaded binary tree required? Draw a right in threaded binary tree for the given tree in Fig.1

9. Write an algorithm to perform traversal of Binary search tree


10. Define an AVL tree. Obtain an AVL tree by inserting one integer at a time in the following
sequence. 150, 155, 160, 115, 110, 140, 120, 145, 130, 147, 170, 180. Show all the steps
11. First insert 10 and then insert 24. After these insertions, delete 37 and then delete 22 from the
following binary search tree. Draw the tree after each operation.
DAVIET CSE
DEPT

12. Insert 1, 29, 32 and 13 in the following Height balanced tree. For each insertion, draw the
balanced tree using AVL rotation.

13. 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 5. What is the
minimum number of keys in any non-root node?

14. Write the characteristics of AVL tree.


15. What is the meaning of height balanced tree? How re balancing is done in height balanced
tree.

Graph:
1. Consider the graph shown in below figure. Find depth-first and breadth first traversals of this
graph starting at A

.
2. Explain the breadth first search and depth first search tree traversal on the following graph.
DAVIET CSE
DEPT
3. Obtain the adjacency matrix A for the following graph. ..

ASSIGNMENT-6 HASHING AND FILE STRUCTURES


Hashing
1. What is Hashing and Advantages of Hashing?Explain any three Hashing functions.
2. List the features of a good hash function
3. Explain hash clash and its resolving techniques.
4. Define Hash Clash. Explain Primary Clustering, secondary clustering, rehashing and double hashing.

5. What is Collision ? explain Collision Resolution techniques with suitable examples.


4. 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?
DAVIET CSE
5. The integers given below are to be inserted in a hash table with 5 locations using chaining toDEPT
resolve collisions. Construct hash table and use simplest hash function.
1,2,3,4,5,10,21,22,33,34,15,32,31,48,49,50

File Structures
1. Explain the terms: File, Field, Record, Database, Key.
2. (i) Explain the structure of sequential file.
(ii) Explain the structure of indexed sequential files.
3. What is File Structure? State different File Organizations and discuss the advantages and
disadvantages of each of them.
4. Explain various multiple key access file organization in brief with advantages and
disadvantages of each method.

You might also like