Assignments - Guru Tegh Bahadur Institute of Technology

advertisement
Assignments on Data Structures- Semester-3
Assignment-1
on
Fundamentals of Algorithm Analysis
Q1. Define an algorithm. What are the properties of an algorithm? What are the types of algorithms?
Q2. What is growth of function? Explain the following term:
(a)
(b)
(c)
(d)
(e)
Big oh Notation(O)
Big Omega Notation(Ω)
Big Theta Notation(Θ)
Little Oh Notation(o)
Little Omega Notation(ω)
Q3. Find the Big theta Notation for the following functions:
(a) f(n)= 79n³+44n
(b) f(n)=2 × 2𝑛 + 6𝑛2 + 3𝑛
(c) f(n)=27𝑛2 + 16𝑛 + 25
Q4. Find the Big oh(O) Notation for the following functions:
(a) f(n) = 10𝑛2 + 7
(b) f(n) = 5𝑛3 + 𝑛2 + 3𝑛 + 2
(c) f(n) = 3 × 2𝑛 + 4𝑛2 + 5𝑛 + 3
Q5. Find the Big oh(Ω) Notation for the following functions:
(a) f(n) = 27𝑛2 + 16𝑛
(b) f(n) = 3𝑛3 + 4𝑛
(c) f(n) = 2𝑛 + 6𝑛2 + 3𝑛
GURU TEGH BAHADUR INSTITUTE OF TECHNOLOGY
Assignments on Data Structures- Semester-3
Assignment-2
on
Arrays and Linked List
Q1. Write a Program implementing insertion operation in an array.
Q2. Run Time Memory Allocation is known as?
Q3. Write the merits and demerits of using Arrays and Linked List for linear data structures.
Q4. Given an Array A(20.. 50,20..40). The elements are stored in Column Major Order. What is the
starting location of A (32,23) ?
Q5. Which of the following: singly-linked list or doubly-linked list implementations are more
complex?
Q6. Write functions Insert and Remove which add and remove nodes from ordered single linked list
based on the Node value?
Q7. Write an algorithm to reverse a list.
Q8. What are the advantage and disadvantage of using Circular Linked List?
Q9. Write an algorithm to insert a node at a given position in a doubly linked list.
Q10. Give the algorithm of searching in linked list when list is sorted.
Q11. Write a function to remove the nodes with repetitive data in a linked list?
GURU TEGH BAHADUR INSTITUTE OF TECHNOLOGY
Assignments on Data Structures- Semester-3
Assignment-3
on
Stack, Queue
Q1. What do you mean by queue? What are the practical applications of queue?
Q2. Compare different implementations of queue. Write a function to delete elements in circular
queue.
Q3. Explain queue.give the algorithm of deletion in the circular queue.
Q4. Consider the following queue ,where queue is a circular queue having 6 memory cells.
Front=2 ,Rear=4 Queue: _ ,A,C,D,_,_ Describe queue as following operation take place:
a)
b)
c)
d)
F is added to the queue
Two letters are deleted
R is added to the queue
S is added to the queue
Q5. Difference between linear queue and circular queue.
Q6. Convert the expression ((A + B) * C - (D - E) ^ (F + G)) to equivalent Prefix and Postfix
notations.
Q7. Describe stack operation.
Q8. Write the prefix form of A ** -B + C
Q9. Let a and b denote positive integers. Suppose a function Q is defined recursively as follows:
Q(a,b)= 0
if a<b
=q(a-b,b)+1
if b<=a
a) Find the value of Q(2,3) and Q(14,3).
b) What does this function do? Find Q(5861,7).
Q10. Write a program of stack where element will be pushed from last position of array.
Q11. Take a stack of size 5.Push the element 5,10,15,20. Now do the following operations and show
the stack in figure.
i)
ii)
iii)
iv)
v)
Pop
Push 2
Push 4
Push 6
Pop
Q12. Consider the following stack of characters, where STACK is allocated N=8 memory cells:
STACK: A,C,D,F,K,___ , ____ , _____
Do the following:
GURU TEGH BAHADUR INSTITUTE OF TECHNOLOGY
Assignments on Data Structures- Semester-3
a)
b)
c)
d)
e)
f)
g)
h)
i)
j)
POP(STACK,ITEM)
POP(STACK,ITEM)
PUSH(STACK,L)
PUSH(STACK,P)
POP(STACK,ITEM)
PUSH(STACK,R)
PUSH(STACK,S)
POP(STACK,ITEM)
When will overflow occur?
When will C be deleted before D?
GURU TEGH BAHADUR INSTITUTE OF TECHNOLOGY
Assignments on Data Structures- Semester-3
Assignment-4
On
Trees
Q1. Suppose the following sequence list the nodes of a binary tree T in pre-order and in-order
respectively:
Pre order:
G,B,Q,A,C,K,F,P,D,E,R,H
In order:
Q,B,K,C,F,A,G,P,E,D,H,R
Draw the diagram of the tree.
Q2. Write an algorithm to find minimum spanning tree of the given graph.
Q3. How a binary tree is different from binary search tree.
Q4. Define Binary trees. How it can be represented in the memory.
Q5. Draw a binary Tree for the expression : A * B - (C + D) * (P / Q)
Q6. Define threaded binary tree.
Q7. Define binary search tree. Construct a binary search tree by inserting the following numbers
in order of their occurrence:
50, 33, 44, 22, 77, 35, 60, 40
Q8. Draw the B-tree of order 3 created by inserting the following data arriving in sequence - 92 24
6 7 11 8 22 4 5 16 19 20 78
Q9. Suppose the following list of letters is inserted in order into an empty binary search tree:
J,R,D,G,T,E,M,H,P,A,F,Q
a) Find the final tree T
b) Find in order traversal of T
Q10. What do you mean by height balanced tree? How a height balanced tree is different from a
binary search tree. What do u mean by rebalancing of height balanced tree. Explain with
example.
Q11. Explain AVL trees. Construct an AVL search tree by inserting the following elements in
order of their occurrence.
64, 1, 44, 26, 13, 110, 98, 85
GURU TEGH BAHADUR INSTITUTE OF TECHNOLOGY
Assignments on Data Structures- Semester-3
Assignment-5
on
Graphs, Searching , Sorting and File Organization
Q1. Write notes on:
a) B-trees
b) Sequential file organization
c) Inverted files
Q2. Define bubble sort. Give the algorithm and explain it with example. Suppose the following
numbers are stored in an array A. 32, 51, 27, 85, 66, 23, 13 and 57. Sort the array using
bubble sort.
Q3. What is the average number of comparisons needed in a sequential search to determine the
position of an element in an array of 100 elements, if the elements are ordered from largest to
smallest?
Q4. What do u mean by searching. What are the conditions for binary search. Explain the
algorithm for the binary search.
Q5. What do you mean by hashing? How do you resolve collision in hashing?
Q6. Give the complexity of all sorting algorithms.
Q7. Write an algorithm for radix sort.
Q8. Illustrate Shell Sort with gap set (4, 2, 1) and gap set(5, 3,1)
76, 31, 40, 44, 61, 55, 32, 34, 5
Q9. What are the various ways to store the Graphs in Memory?
Q10. Compare Sequential and random file organization.
Q11. Discuss Random file Organization and various techniques used for randomization.
Q12. Explain various techniques for overflow / collision resolution in case of hashing.
Q13. Find out the adjacency matrix and adjacency list for the graph given below-
A
B
D
C
GURU TEGH BAHADUR INSTITUTE OF TECHNOLOGY
E
Assignments on Data Structures- Semester-3
Q14. Show all the passes using insertion sort with the following list13,33,27,77,12,43,10,432,112,90
Q15. Get the hash index in table size 11 for the following list23,54,49,32,66,16,5
Avoid the collision resolution with linear probing technique.
Q15. Apply the mid square method to get the hash index of table size 97 for following keys1123,1234,1012,1034,1103,1005
Q16. Get the hash index in table size 19 for following string“Suresh”, “Deepali”,”Mohini”,”Vinay”,”Rajesh”
GURU TEGH BAHADUR INSTITUTE OF TECHNOLOGY
Download