Prepared by
Ch.Uday
Bhaskar
M.Anil Kumar
M.Raja Babu
S.Neelima
DATA STRUCTURES
INTRODUCTION
Introduction The Problem Solving Top down design Strategy Algorithms Vs Programs
Implementations of algorithms Program Verification The efficiency of algorithms
Algorithmic Notation Asymptotic Notation Mathematical Induction Analysis of Algorithms
Recurrence Relations.
RECURSION AND LINEAR SEARCH:
Preliminaries of algorithm, Algorithm analysis and complexity, Recursion: Definition, Design
Methodology and Implementation of recursive algorithms, Linear and binary recursion, recursive
algorithms for factorial function, GCD computation, Fibonacci sequence, Towers of Hanoi, Tail
recursion
List Searches using Linear Search, Binary Search, Fibonacci Search, Analyzing search
algorithms.
SORTING TECHNIQUES:
Basic concepts, Sorting by : insertion (Insertion sort), selection (heap sort), exchange (bubble
sort, quick sort), distribution (radix sort ) and merging (merge sort ) Algorithms.
STACKS AND QUEUES:
Basic Stack Operations, Representation of a Stack using Arrays, Stack Applications: Reversing
list, Factorial Calculation, In-fix- to postfix Transformation, Evaluating Arithmetic Expressions.
Queues: Basic Queues Operations, Representation of a Queue using array, Implementation of
Queue Operations using Stack, Applications of Queues-Round robin Algorithm, Enqueue,
Dequeue, Circular Queues, Priority Queues.
LINKED LISTS:
Introduction, single linked list, representation of a linked list in memory, Operations on a
single linked list, merging two single linked lists into one list, Reversing a single linked list,
applications of single linked list to represent polynomial expressions and sparse matrix
manipulation, Advantages and disadvantages of single linked list, Circular linked list, Double
linked list
TREES:
Basic tree concepts, Binary Trees: Properties, Representation of Binary Trees using arrays and
linked lists, operations on a Binary tree , Binary Tree Traversals, Creation of binary tree from inorder and pre(post)order traversals, Tree Travels using stack, Threaded Binary Trees.
ADVANCED CONCEPTS OF TREES:
Binary search tree, Basic concepts, BST operations: insertion, deletion, balanced binary trees
AVL Search Trees basic concepts , operations: insertion ,deletion. m-way search trees operations:
insertion ,deletion, B Trees, operations: insertion , deletion
GRAPHS:
Basic concepts, Representations of Graphs: using Linked list and adjacency matrix, Graph
algorithms Graph Traversals (BFS & DFS), Topological Sort, applications: Dijkstras shortest
path, Transitive closure, Minimum Spanning Tree using Prims Algorithm, warshalls Algorithm.
SETS:
Definition, Representation of Sets using Linked list, operations of sets using linked lists,
application of sets- Information storage using bit strings
ABSTRACT DATA TYPE
Introduction to abstraction, Model for an Abstract Data Type, ADT Operations, ADT Data
Structure, ADT Implementation of array, Linked list and stack.
1. ALGORITHMS
1.1 BASICS
I. Statements
1.
8.
9.
We write f(n) = (g(n)) (read as f(n) is theta of g(n)) ,if there exists two positive constants
c, d and positive integer p such that
c | g(n) | <= | f(n) | <= d | g(n) | for all n >= p
12. Define BIG O-notation
We write f(n) = O(g(n)) (read as f(n) is big oh of g(n)) ,if there exists a positive integer p,
positive number D such that
| f(n) | <= D | g(n) | for all n >= p
13. Define notation.
We write f(n) = (g(n)) (read as f(n) is omega of g(n)) ,if there exists a positive integer p,
positive number D such that
| f(n) | >= D | g(n) | for all n >= p
Medium:
14. What is the solution to the recurrence relation T(n) =2 T(|_ n/2 _| ) + n
T(n) =O(n logn )
15. What is the solution to the recurrence relation T(n) =2 T(|_ n _| ) + log n
O( log n log log n)
16. What is the solution to the recurrence relation T(n)=T(n-1)+n
O(n2)
17. What is the solution of the recurrence relation T(n)=9T(n/3) +n
(n2)
18. What is the solution of the recurrence relation T(n)=T(2n/3) + 1
(log n)
19. What is the solution of the recurrence relation T(n) = 3T(n/4) +n log n
(n log n)
20. What is the solution of the recurrence relation T(n) =T(n/2) + (1)
(log n)
III.
c. Both
d. None
c. Both
d. None
c. Both
d. None
c. Greedy
d. None
5.
c. Greedy
d. None
6.
7.
8.
9.
10.
b. 5
c. 6
d. 7
13.
b. min(f(n),g(n))
c. f(n)+g(n)
d. f(n)-g(n)
c. O(n)
d. O(n2)
15.
b. (n)
c. (n)
d. (35)
b. Quadratic
c. Logarithmic
d. Linear
18.
d. O(n2)
17.
c. O(n log n)
16.
b. O(n)
b. (80)
c. (log n)
d. (n)
When we say an algorithm has a time complexity of O (n), what does it mean?
a. The algorithm has n loops
b. The computation time taken by the algorithm is proportional to n
c. The algorithm is n times slower than a standard algorithm
d. There are n number of statements in the algorithm
19.
Read the following statements carefully, and choose the correct answer
I.
The notation is Anti Symmetric.
II.
The big Oh notation is Semi Equivalence.
a. (I) is FALSE but (II) is TRUE
20.
There are 4 different algorithms ALI, AL2, AL3, AL4 to solve a given problem
with the order log(n), log(log(n)), n log(n) ,n / log(n) respectively. Which is the
best algorithm
a. AL1
21.
b. AL2
c. AL3
d. AL4
22.
23.
b. MP
d. NP
1. a
c. MN
2.b
b. Reflexive
c. Transitive
d. all
3.b
4.a
5.b
6.d
7.c
8.b
9.a
10.a
11. b. 12.a
13.c
14.b
15.b
16.d
17.a
18.b
19.b
20.b
21. c
23.d
22.a
The method of defining a function in which the function being defined is applied
within its own definition is known as Recursion.
2.
for n<=1
for n>1
10. Write the recurrence relation for the recursive function of binary search.
T(n) = c
= T(n/2) + d
III.
for n<=1
for n>1
Easy:
1.
b. Linear Search
c. Tree Search
d. Hashing
2. The time complexity of binary search in best, worst cases for an array of size N is
a. N, N2
3.
b. N, N
c. Log N, N2
d. 1, log N
Which of the following is not a required condition for binary search Algorithm.
a. The list must be sorted
b. There should be the direct access to the middle element in any sublist
c. There must be mechanism to delete and/or insert elements in list
d. None
a. Queue
6.
d. None
c. O(n2)
b. O(log n)
d. O(n log n)
8.
c. Stack
7.
b. Linked List
c. O(n2)
b. O(logn)
d. O(n log n)
c. O(n2)
b. O(logn)
d. O(n log n)
Medium:
9.If memory for the run-time stack is only 150 cells(words), how big can N be in
Factorial(N) before encountering stack overflow?
a. 24
10.
b. 12
c. 26
d. 50
Sequential search has a time complexity of O(n), and binary search has a time complexity
of O(log(n)). What difference will it make when the size n is 1000?
a. You would not notice much difference because computers run very fast anyway
b. As n is 1000, binary search is twice as fast as sequential search
c. As n is 1000, binary search is 10 times as fast as sequential search
d. As n is 1000, binary search is 100 times as fast as sequential search.
11.A characteristic of the data that binary search uses but the linear search ignores is
the___________.
12.
13.
d. Pointer array
15.
16.
b. n/2
c. n
d. n-1
b. Recursion
c. Polish notation
d. None
2.d
13.d
14. a
3.c
4.d
5.c 6.a
7b
8.b
9.a
10.d 11.a
12.a
15.a 16.b
2. SORTING
2.1 INTRODUCTION TO SORTING
I. Statements/Definitions
1. Sorting is a process that organizes a collection of data into either ascending or
descending order.
2. Sorting algorithms are classified as either internal or external.
3. An internal sort requires that the collection of data fit entirely in the computers main
memory.
4. We can use an external sort when the collection of data cannot fit in the computers
main memory all at once but must reside in secondary storage such as on a disk.
Internal sorting algorithms
Distribution(Radix sort)
Merging(Merge sort)
b. O(n*n)
c. O(nlogn)
d. O(logn)
b. O (n*n)
c. O(nlogn)
d. O(logn)
b. O(n*n)
c. O(nlogn)
d. O(logn)
4. In a selection sort of n elements, how many times is the swap function called in the
complete execution of the algorithm?
a. 1
b. n 1
c. n log n
d. n
5. A sorting technique in which successive elements are selected in order and placed into
their proper sorted positions is called
a. Selection sort
b. Quick sort
c. Bubble sort
d. Merge sort
a. n*(n/2)
b. n*n
c. n(n-1)/2
d. none
c. n
d. log n
b. n(n-1)/2
b. n
c. n*n
d. 2*n
2.b
3.b
4.b
5.a
6.d
7.a
8.b
9.a
2.
b. O(n*n)
c. O(nlogn)
d. O(logn)
b. O(n*n)
c. O(nlogn)
d. O(logn)
5.
d. Quick sort
4.
c. Selection sort
3.
b. Insertion sort
b. O(n*n)
c. O(nlogn)
d. O(logn)
b. detrimental algorithm
c. both
d. none
Medium:
6.
What is the output of insertion sort after the 1st iteration given the following
sequence of numbers: 7 3 5 1 9 8 4 6
a. 3 7 5 1 9 8 4 6 b. 1 3 7 5 9 8 4 6
7.
9.
b. n(n+1)/2
12.
d. n*n
c. n
d. logn
11.
c. n
a. n*n
10.
d. 1 3 4 5 6 7 8 9
8.
c. 3 4 1 5 6 8 7 9
b. n(n-1)/2
c. n(n-1)/4
d. logn
b. a linear function of n
c. a logarithmic function of n
d. none
b. a linear function of n
c. a logarithmic function of n
d. none
2.b
3.b
4.a
5.c 6.a
7.a
8.c
9.b
10.c
11.
2.
b.O(n*n)
c.O(nlogn)
b.O(n*n)
c.O(nlogn)
b.O(n*n)
c.O(nlogn)
6.
d.O(logn)
d.O(logn)
5.
d. none
4.
c. Both
3.
b. Sinking sort
d.O(logn)
8.
The most exchanges that will be necessary for bubble sort for an array of length n
is
a.n
9.
b.n+1
c.n-1
d.n*n
Which of the following sorting methods would be most suitable for sorting a list
which is almost sorted
a. Bubble Sort
b. Insertion Sort
c. Selection Sort
d. Quick Sort
2.b
3.b
4.a
5.b
6.c
7.c
8.a
9.a
As the name implies, it is quick, and it is the algorithm generally preferred for sorting.
The quick sort algorithm was developed in 1960 by Tony Hoare.
Quick sort also known as Partition Exchange Sort is a divide and conquer algorithm.
Quick sort involves placing the pivot element (generally first element) in the correct
position, so that it divides the list into two parts such that the elements to the left of pivot
are less than pivot and elements to the right of pivot are greater than pivot.
5. Now we apply the technique to these sub arrays continuously until the entire array is
sorted.
II. Multiple Choice Questions
Easy:
1.
2.
b. External sorting
c. Both
d. none
b. quick sort
c. bubble sort
d. merge sort
4.
b. Greedy Approach
c. Back Tracking
5.
What pattern of splits gives the worst-case performance for quick sort?
a. Ascending order.
b. Descending order.
c. Any order.
d. None of the above.
Medium:
6.
7.
10.
d. O(logn)
b. O(n*n)
c. O(nlogn)
d. O(logn)
9.
c. O(nlogn)
8.
b. O(n*n)
b. O(n*n)
c. O(nlogn)
d. O(logn)
If one chooses the middle key as the pivot, what would be the Big-O value for the
Best case of the Quick Sort Algorithm?
a. n*n
b .n
c. a constant
d. n log n
12.
Which of the following activities is/are not relevant to the quick sort algorithm?
a. Initially divide the entire file into N sub-files.
b. Choose a pivot value and store it in a correct place.
c. The sorting technique is sorting by exchange.
d. The sorting technique is sorting by selection.
13.
If the last element is chosen as the pivot at each iteration, the Quick-sort tree for
the sequence in question 1 will have height
a.1
b.2
c. 3
d.4
14.
Given a large amount of highly random data which fits into the computers RAM,
the best choice for sorting would be
a. Bubble-sort b. Insertion-sort
c. Merge-sort
d. Quick-sort
15.
In Quick sort , after the completion of every pass the pivot/key element moves to
the ________ position.
a. First
b. second
c. middle
d. exact sorted position
2.b
3.b
12.a,d 13.c
4.a
14.d
5.b
15.d
6. c
7.b
8.c 9.d
10.c
Merge sort is a divide and conquer algorithm that was invented by John von
2.
Neumann in 1945
To sort elements Divide the unsorted array into two sub lists at the middle. Further
divide these sub lists into sub lists at their middles until each sub list contain only
3.
one element.
Merge these sub lists two at a time till we get the final sorted list with the
following steps:
i) Compare the sub-lists first elements.
ii) Remove the smallest element and put it into the result array.
iii) Continue the process until all elements have been put into the result array.
Medium:
II. Multiple choice questions
1.
2.
5.
d. O(logn)
b. O(n*n)
c. O(nlogn)
d. O(logn)
4.
c. O(nlogn)
3.
b. O(n*n)
b. O(n*n)
c. O(nlogn)
d. O(logn)
b.n-1
c.log(n)
d. nlogn
6.
Merge sort is based on the divide and conquer strategy consists of the following
steps
7.
Given two sorted lists of size m, n the number of comparisons needed in the worst
case by the merge sort algorithm is
a.mn
8.
b.max(m,n)
c.min(m,n)
d.m+n-1
9.
b. 4
d. 7
e. 14
10.
c. 5
b. halves
d. increases 4 times
b. n
c.log n
d. n*n
2.c
3.c
4.d
5.c
6.a
7.d
8.c
9.a
10.a
3.
element from the elements in unsorted list and their inclusion in sorted list.
This process continues until all elements have been selected from the unsorted
list.
4.
Heap sort is built on a data structure called heap and hence the name heap sort.
2.
4.
5.
c. O(nlogn)
d. O(logn)
3.
b. O(n*n)
b. O(n*n)
c. O(nlogn)
d. O(logn)
b. A[Parent(i)]<=A[i]
c. A[Parent(i+1)]>A[i]
d. A[Parent(i+1)]<a[i]
b. A[Parent(i)]<=A[i]
c. A[Parent(i+1)]>A[i]
d. A[Parent(i+1)]<a[i]
The number of operations required for heap sort regardless of the order of I
input
a. O(1)
6.
b. O(logn)
c. O(nlogn)
d. O(n*n)
b. O(log n)
c. (log n)
d. (n log n)
Complex:
8.
b. [10,7,6,2,4,7]
c. [10]
d. [10,6,7,2,4,6]
9.
10.
b. n log n
b. n log n
c. n*n
d. none
12.
d. none
11.
c. n*n
b. O(n)
c. O(nlogn)
d .none
The __________ data structure is a n array object that can be viewed as a nearly
complete binary tree.
a. stack
13.
b. queue
d. linked list
14.
c. binary heap
b. O(n log n)
c. O(log n)
d. O(n)
b. (log n)
c. (log n)
d. O(n)
7.d
10.b
2.c
3.a
12.c
13. c
14.c
4.b
5.c
6.d
8.c 9.a
11.b
Stack is a linear data structure which stores the elements in LIFO(Last In First
Out) order.
2.
The last element that is inserted will be the first to be removed from the stack. So
3.
4.
5.
6.
The process of adding a new element to the top of stack is called push operation.
The process of deleting an element from the top of the stack is called POP operation.
Reversing a list
Parentheses checking
Conversion of infix expression to postfix expression
Evaluation of postfix expression
Recursion
Towers of Hanoi
Easy:
1. The operation for adding an entry to a stack is traditionally called:
a. add
b. append
c. insert
d. push
4.
5.
b. peek
c. pop
d. remove
b. expression conversion
c. expression evaluation
If the sequence of operations - push(1), push(2), pop, push(1), push(2), pop, pop,
pop, push(2), pop are performed on a stack, the sequence of popped out values are
?
a. 2, 2, 1, 1, 2
b. 2, 2, 1, 2, 2
c. 2, 1, 2, 2, 1
d. 2, 1, 2, 2, 2
Medium:
6.
7.
8.
9.
b. pop
c. push
b. pop
c. push
10.
c. + cd * -
d. ab + - cd *
11.
b. abcd + - *
b. Array
c .Stack
d. Queue
b. Array
c .Stack
d. Queue
e. Dequeue.
12.
13.
c.650
d.588
14.
b.350
b. Stack
c. Array
d. Linked-list
b. Queue
c. Stack
d. Binary tree
2.c
3.d
4.d
11. c
12.b
13.b
14.c
5.d
6. d
7.b
8.c 9.d
10.c
3.3 QUEUE
I. Statements/Definitions
1.
2.
Queue is a linear data structure which stores data in FIFO(First In First Out)order.
A Queue is an ordered collection of items from which items may be deleted at one
end (called the front of the queue) and into which items may be inserted at the
3.
4.
1.
Which data structure allows deleting data elements from front and inserting at
rear?
a. Stacks
2.
b. Queues
c. Deques
If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then
removed one at a time, in what order will they be removed?
a. ABCD
3.
b. ABDC
c. DCAB
d. DCBA
Identify the data structure which allows deletions at both ends of the list but
insertion at only one end.
4.
a. Input-restricted deque
b. Output-restricted deque
c. Priority queues
d. None of above
A data structure where elements can be added or removed at either end but not in
the middle
a. Linked lists
b. Stacks
c. Queues
d. Deque
Complex:
5.
6.
c. Recursion
Which of the following data structure is the best example for the multitasking
systems?
a. Tree
7.
b. Queue
c. Stack
d. Linked List
To implement the Round Robin algorithm, which of the following data structure
is used?
a. Stack
b. Linear Queue
c. Circular Queue
2.d
3.a
4.d
5.a
6.b
7.b
d. Priority Queue
4. TREES&GRAPHS
4.1 TREE BASICS
I. Statements/Definitions
1.
A tree is a finite set of one or more nodes such that here is a specially designated node
called the root.
2.
The remaining nodes are partitioned into n 0 disjoint sets T1,,Tn, where each of
these sets is a tree. We call T1,,Tn the sub trees of the root.
3.
Root of the tree: The top node of the tree that is not a sub tree to other node, and has
two children of sub trees.
4.
5.
6.
7.
8.
9.
Node: It is stands for the item of information and the branches to other nodes.
The degree of a node: It is the number of sub trees of the node.
The degree of a tree: It is the maximum degree of the nodes in the tree
The parent node: a node that has sub trees is the parent of the roots of the sub trees
The child node: a node that is the roots of the sub trees are the children of the node
The Level of the tree: We define the level of a node by initially letting the root be at
level one
10. The depth of a tree: It also called height of a tree. It is the maximum level of any node
in the tree
II. Short Answers
Easy:
1. Define tree?
A tree is a non-linear data structure that consists of a root node and
potentially many
1.
2.
3.
4.
An AVL tree is a binary search tree which has the following properties:
1. The sub-trees of every node differ in height by at most one.
2. Every sub-tree is an AVL tree.
13. What are the operations of AVL tree?
There are three operations
1. Insertion
2. Deletion
3. Searching
Complex:
14. What is the purpose of using B tree?
By using the B tree dynamically we can increase and decrease the size of tree.
15. Define B tree?
The B-Tree has additional constraints to ensure the tree is always balanced, and the space
wasted by deletion never becomes excessive.
16. What are the advantages of trees?
Trees are so useful and frequently used, because they have some very serious advantages:
Trees
Trees
Trees
17. How many types of threaded binary trees and what are those?
There are two types of threaded binary trees those are
Single Threaded
Double threaded
18. What is single threaded binary tree?
Each node is threaded towards either (right)' the in-order predecessor or' successor.
19. What is double threaded binary tree?
Each
node
is
threaded
towards both
(left
&
right)'
the
in-order
21. What are the balance factor values for height balanced trees?
BF values for height balanced trees are -1, 0 and +1.
22. How to balance the AVL tree in case of tree is in unbalanced state?
By using the rotations we can balance the tree. There are two types of rotations. Those are
1) Single rotations
i)
LL rotation
ii)
RR rotation
2) Double rotations.
i)
LR rotation
ii)
RL rotation
III. Multiple Choice Questions
1.
2.
A Binary Tree whose every node has either zero or two children is called
a. Complete binary tree
d. None of above
In a binary tree, certain null entries are replaced by special pointers which
point to nodes higher in the tree for efficiency. These special pointers are called
a. Leaf
3.
b. branch
c. path
The in order traversal of tree will yield a sorted listing of elements of tree in
a. Binary trees b. Binary search trees
4.
d. thread
Which of the following is not the required condition for binary search algorithm?
Medium:
7.
When converting binary tree into extended binary tree, all the original nodes in binary
tree are
8.
d. None of above
The post order traversal of a binary tree is DEBFCA. Find out the pre order
traversal
a. ABFCDE
b. ADBFEC
c. ABDECF
d. ABDCEF
11.
12.
13.
c. Empty.
d. Full.
14.
15.
d. Path.
d. Null.
Complex:
16.
17.
d. atleast 1.
18.
While using header node in binary trees the condition LEFT [HEAD] =NULL
indicates a ___
a. Empty tree.
b. Tree is full.
c. Free space available.
d. Avail list full.
19.
The threads in a diagram of a threaded tree are usually indicated by ---a. Straight line.
b. Arrow.
c. Dotted line.
d. Curve.
20.
If node N is a terminal node in a binary tree then its -----a. Right tree is empty.
b. Left tree is empty.
c. Both left & right sub trees are empty.
d. Root node is empty.
3.b
15.b
4.c
16.a
17.b
5.a
18.a
6.b
7.a
19.c 20.c
8.c
9.d
10.a
4.2 GRAPHS
I .Statements/Definitions
1.
2.
3.
4.
5.
6.
7.
or a digraph.
A path in a graph is a sequence of vertices that are connected by edges.
A cycle in a directed graph is a path that starts and ends at the same vertex.
A graph with no cycles is called an acyclic graph.
Undirected Graph: The pairs in E are unordered pairs, i.e., there is no tail or head
8.
9.
10.
11.
referred to as simple
Undirected graph is connected - when every pair of vertices in V is connected by
12.
a path.
Directed graph strongly connected - when every two of vertices in V is reachable
from each other
A two-dimensional matrix, in which the rows represent source vertices and columns
represent destination vertices. Data on edges and vertices must be stored externally. Only
the cost for one edge can be stored between each pair of vertices.
3. Explain adjacency list representation?
Vertices are stored as records or objects, and every vertex stores a list of adjacent
vertices. This data structure allows the storage of additional data on the vertices.
Additional data can be stored if edges are also stored as objects, in which case each
vertex stores its incident edges and each edge stores its incident vertices.
4. How to visit the each vertex in the graph at most one time?
By using graph traversing techniques we can traverse the graph. There are two techniques
those are
1) Depth First Search
2) Breadth First Search
5. What are the operations of graphs?
2.
b. N
c.N+1
3.
b .Set
c. List
d. Queue
4.
5.
d. None of these
6.
Given an undirected graph G with V vertices and E edges, the sum of the degrees
of all vertices is
a. E
7.
b. 2E
d. 2V
A graph is said to be ________ if there is a path between any two of its nodes
a. Connected.
8.
c. V
b. Coupled.
c. Attached.
d. Allied.
9.
c. Inclusive.
d. Complete.
10.
b. Entire.
b. Marked.
c. Labeled.
d. Sticked.
c. Dir-graph.
d. Digraph.
b. Digraph.
11.
12.
13.
b. Reachable.
d. circular graph.
d. Directed.
14.
c. Connected.
d. both b and c.
b. Adjacent nodes.
Complex:
16.
A graph with no edges is known as empty graph. Empty graph is also known
as ?
a. Trivial graph
17.
c. Bipartite graph
d. None of these
18.
b. Regular graph
b. Regular graph
c. Tree
d. Not a graph
b. n*n
c. n^n
d. n^2
19.
20.
b. Hamiltonian
d. Path
21.
c. Tree
22.
a. Laterally connected.
b. Widely connected.
c. Un literally connected.
d. Literally connected.
23.
d. 2.
b. Queue.
c. Tree.
d. Array.
25.
c. 4.
24.
b. 3.
b. Tree.
c. Stack.
d. Queue.
26.
b. Stack
c. Heap
d. B-Tree
d. All of above
1.b
2.d
3.a
4.b
5.c
6.b
7.a
15.d
16.a
17.c
18.a
19.a
20.d
21.c
22.d
11.a
23.b
12.b
24.c
13.a 14.d
25.a
26.d
2.
3.
4.
5.
6.
mentioned.
In ADT, all the implementation details are hidden.
In short
ADT= TYPE+ Function names + Behaviour of each function
The abstract data type consists of following things
Data used along with its data type.
Declaration of functions which specify only the purpose. That means What is to
be done in Particular function has to be mentioned but how is to be done must
7.
be hidden.
Behavior of function can be specified
8.
together.
Thus ADT allows programmer to hide the implementation details. Hence it is
called abstract.
5.2 ADT OPERATIONS
Various Abstract Data Type operations are
1.
2.
3.
4.
5.
That can be used for ADT are arrays , Set , Linked list , Stack , Queues and so on.
Examples
1. ADT for Set
If you want to write ADT for a set of integers , then we will use following method
Abstract Data Type Set
Instances :Set is a collection of integer type of elements .
Preconditions :none
Operations :
1. Store( ) : This operation is for storing the integer element in a set.
2. Retrieve( ) : This operation is for retrieving the desired element from the given set.
3. Display( ) : This operation is for displaying the contents of set.
There is a specific method using which an ADT can be written. We begin with keyword
Abstract data type which is then followed by name of the data structure for which we want to
write an ADT. In above given example we have taken set data structure.
We must first write instances in which the basic idea about the corresponding data
structure must be given. Generally in this section definition of corresponding data
structure is given.
Using preconditions or post conditions we can mention specific conditions that must be
Truncation Method
Mid square Method
Folding Method
Division Method
Truncation Method
This is the simplest method for computing address from a key. In this method we take
only a part of the key as address.
A collision occurs whenever a key is mapped to an address that is already occupied.
Collision Resolution technique provides an alternate place in hash table where this key
can be placed.
Collision Resolution technique can be classified as:
1) Open Addressing (Closed Hashing)
a) Linear Probing
b) Quadratic Probing
c) Double Hashing
2.
ADT consists of
a. Type
3.
5.
d. All
b. basic operation
c. both
d. None
b. Basic operation
c. Both
d. None
6.
c. Behaviour
4.
b. Function names
b.ADT
c. Storage structure
d. File structure
7.
b. assignment
c. Primitive
d. Structured
8.
b. Assignment
c. Primitive
d. Structured
b. FIFO
c. FILO
d. None
9.
10.
c. Any of a or b
d. None
11.
b. FIFO
b. Pop
c. peek
d. None
12.
c. Tree
d. List
which of the following data structure is used for evaluation of post fix expression
a. Stack
13.
b. Stack
b. Array
c. Queue
d. Linked list
c. Both
d. None
Medium:
14.
15.
b. Preconditions
c. Operations
16.
d. All
a. Data Structure
d. Algorithm
c. Storage structure
d. File structure
17.
18.
b. Assignment
c. Primitive
d. Structured
Which of the following abstract data types can be used to represent a many to
many relation?
a. Tree
19.
c. Graph
d. b&c
20.
b. plex
d. Dope vector
Which of the following abstract data types can be used to represent a many to
many relation?
a. Tree
21.
b. Plex
c. Graph
d. b &c
22.
23.
A set is ___________
a. Collection of elements
d. None
24.
b. Integer set
d. None
b. Intersection
c. Join
d. None
25.
26.
d. None
b. Null set
c. Powerful set
d. Exponential set
28.
c. Both
27.
b. Linked list
b. Intersection
c. Equality
d. Dictionary
29.
Application of dictionary
a. Student register
30.
b. Telephone directory
c. Word dictionary
d. All
The situation in which the hash function returns same hash key is called
a. Clash
b. Collision
c. Synonym
d. None
Complex:
31.
32.
b. Synonyms
b. Location
b. Hash function
d. Memory
c. Hash domain
d. Mapping table
35.
c. Bucket
34.
d. None
33.
c. Antonym
d. All
36.
37.
d. None
38.
b. Closed addressing
c. Separate chaining
d. None
a. Open addressing
39.
b. Closed addressing
c. Separate chaining
d. None
b. Hashkey+i4%M
c. Hashkey2%M d. Hashkey+i2
40.
2.d
3.a
11.b
12.a
22.c
23.c
33.b
4.b
5.d
6. c
7.c
13.c 14.d
15.b
16b
17.c
24.c
25.c
26.a
27.d
28.d
29.d
30.b 31. b
34.d
35.a
36.d
37.a
38.c
39.a
40.b
18.d
8.b
9.a
19.d
20.d
10.d
21. a
32.c