DS2 Marks
DS2 Marks
UNIT – I
Data Structures is a way of organizing data that considers the data to stored and their
relationship with each other. It is representation of the logical relationship between
individual elements of data
15.What is a pointer?
A pointer is a reference to a data structure. Important property of pointer is
that, as a single fixed size data item, it provides a homogeneous method of
referencing any data structure, regardless of the structures type or complexity.
20.What are primitive data structures? What are the associated operations?
It is the data structures that are directly operated upon by machine level
instructions. The associated operations are:
• CREATION – Creates a data structure
• DESTROY – destroys data structure
• SELECTION – Access data within a data structure
• UPDATE – Changes data in the data structure.
UNIT – II
PART- A Questions & Answers
9. What is deque?
A deque (Double-Ended-QUEue) is a linear list in which insertions and
deletions are made to and from either end of the structure.
10. Give the condition for the empty Q, full Q and one-entry Q.
Empty Queue : Rear<Front
Full Queue : Rear = Array size(N)
One-entry Queue : Front = Rear
11. Give the condition for empty stack and full stack
Empty Stack : Top = 0
Full Stack : Top = N
12. Convert the infix (a+b)*(c+d)/f into postfix & prefix expression.
Postfix : a b + c d + * f /
Prefix : / * + a b + c d f
14. Write down the algorithm for solving Towers of Hanoi problem
1. Push parameters and return address on stack.
2. If the stopping value has been reached then pop the stack to return to previous
level else move all except the final disc from starting to intermediate needle.
3. Move final discs from start to destination needle.
4) Move remaining discs from intermediate to destination needle.
5) Return to previous level by popping stack.
Stack:
The principle of operation of stack is LIFO. Insertion and deletion operations are
performed through one end of the stack.
Queue:
The principle of operation of Queue is FIFO. Insertion is made to right of of the
right most element in the queue and deletion consists of deleting the left most element in
the Queue.
21. Write an algorithm which insets a node into a linked linear list.
i) Check for underflow.
ii) Obtain the address of next free node.
iii) Remove free node from availability stack.
iv) Initialise field of new node.
v) Return address of new node.
42.What are the conditions that followed in the array implementation of queue?
Condition Situation
REAR<FRONT EMPTY QUEUE
FRONT==REAR ONE ENTRY QUEUE
REAR==ARRAY SIZE FULL QUEUE
43. What are the conditions that could be followed in a linked list implementations
of queue?
Condition Situation
REAR==HEAD EMPTY QUEUE
REAR==LINK(HEAD) ONE ENTRY QUEUE
NO FREE SPACE TO INSERT FULL QUEUE
44. What are the conditions that could be followed in a linked list implementations
of queue?
Condition Situation
(REAR MOD ARRAY SIZE +1 )==FRONT EMPTY QUEUE
(REAR MOD ARRAY SIZE +2 )==FRONT FULL QUEUE
FRONT==REAR ONE ENTRY QUEUE
14.What do you mean by Pivot node? How will you resolve the problem if there
are more than one pivot node?
Ans: A pivot node is the one whose balance factor has been switched from the value
of one to two, i.e. whose balance factor is not 1, -1,0. If there are two pivot node then
the lowest node which has imbalanced balance factor is selected as pivot node.
A directed binary tree for which each edge is labeled with a real number (weight)
is called as weighted tree.
* It progresses in top down fashion.
Collection of sub trees that are obtained when root node is eliminated is known
as forest
20.Write down the procedure for inserting a node into red black tree.
1. Always insert the node to be inserted as a red node
2. Check that the black height constraint remains intact.
3. If any red node has a red child then repair the color flip.
4. Define terminal node, height of the tree, & forest.
Ans: The nodes that have degree zero are called leaf or terminal node.
The height or depth of the tree is defined as the number of nodes visited in
traversing
a branch that leads to leaf node at the deepest level of the tree.
Forest is a set of n ≥ 0 disjoint tree, which are obtained when the root is
removed.
21.Give the space complexity for binary search algorithm?
The space complexity for binary search algorithm is (n+4) memory location.
where ‘n’→ no: of elements in array and ‘4’→ Global variable like low, high, mid and
value to be searched.
UNIT – IV
PART- A Questions & Answers
1. What is sorting?
Sorting is the operation of arranging the records of the table into some
sequential order according to an ordering criterion.
7. What is searching?
Searching is a process of finding a record in the table according to the
given key value. Searching is extensively used in data processing.
9. What is hashing?
Hashing is a process of finding the relative position in the list where we
expect to find the key , according to a given key value.
10. What is linear probing?
When a collision occurs, proceed down the list in sequential order until
vacant position is found. The key causing the collision is placed at the first vacant
position.
21.Give the Best, Average and worst case for successful and unsuccessful search.
Successful search:
* Best case=θ(1)
* Average case= θ(log n)
* Worst case= θ(log n)
Un Successful search:
sequence of n elements i.e. a [1], a [2]…. a [n], the general idea is to imagine them split
into 2 sets a [1], …a [(n/2)] and a [(n/2) +1], …. a [n].Each set is individually sorted, and
the resulting sorted sequence are merge to produce a single sorted sequence of
1. In merge sort 2n locations are needed. The additional n locations were needed
because we couldn’t reasonally merge 2 sorted sets in place.
2. Since merge sorts splits each set in to two approximately equal –sized
subsets, the maximum depth of the stack is proportional to logn.
26. What is the lower bound used for binary search? Explain
Ans: The lower bound used for binary search is decision tree.
The decision tree is a binary tree whose nodes are labeled from 1 to n and arranged as
per the following rules:
1. The root of the tree is labeled with the first entry to which the algorithm compares
K.
2. The left child of the root is that entry to which the algorithm compares K next if
K<E[I]
3. The right child of the root node is that entry to which the algorithm compares K
next if K>E[I].
27. What is the number of comparisons done in average case in binary search?
Ans: The number of comparisons for the average case in binary search is lg (n+1)-q,
where
q is the problem that the search is successful.
29. What do you mean by heap. Write the procedure for inserting an element
into the heap.
Ans: A heap is a complete binary tree with the property that the value at each node
should be as large as the value at its children.
To insert an element into the heap the steps are:
1. Add the new item at the bottom of the heap and compare the item with its parent.
if the parent is less than the item then bring the parent downward.
2. Repeat the step until the heap property is satisfied.
UNIT –V
PART- A Questions & Answers
19 5
10. What are the basic operations that can be performed on the data structures?
Ans: The basic operations that can be performed on the data structures are:
1. Traversing: Accessing each record exactly once so that certain items in the record
may be processed.
2. Searching: Finding the location of the record with a given key value or finding the
locations of all records, which satisfy one or more conditions.
3. Insertion: Adding a new record to the data structure.
4. Deletion: Deleting a record from the data structure.
5. Sorting: Arranging the records in some logical order
6. Merging: Combining the records in two different sorted file into a single sorted
file.
13.What do you mean by traversal and what are its two types?
Ans: The traversal of the graph is a process of moving through all the nodes of the
graph, visiting each one, at least once. There are two types of traversals namely
a) Depth first Search b) Breadth First Search.
14.What do you mean by tree arcs, backward arcs and cross arcs?
Ans: Tree Arc: Natural descent from one adjacent node to its next adjacent node
Backward arcs: It represents the cycles in the graph.
Cross arcs: The sets of edges that are not included in the Depth First Spanning.
Forest
1 2 1 2 2
3 3
Graph Subgraphs
1. What are the requirements that are needed for performing Backtracking?
To solve any problem using backtracking, it requires that all the solutions
satisfy a complex set of constraints. They are:
i. Explicit constraints.
ii. Implicit constraints.
12. What are the factors that influence the efficiency of the backtracking
algorithm?
The efficiency of the backtracking algorithm depends on the following
four factors. They are:
i. The time needed to generate the next xk
ii. The number of xk satisfying the explicit constraints.
iii. The time for the bounding functions Bk
iv. -The number of xk satisfying the Bk.
14. What are the searching techniques that are commonly used in Branch-and-
Bound method.
The searching techniques that are commonly used in Branch-and-Bound
method are:
i. FIFO
ii. LIFO
iii. LC
iv. Heuristic search