Documente Academic
Documente Profesional
Documente Cultură
PART –A [2 Marks]
2. Define Algorithm?
Algorithm is a solution to a problem independent of programminglanguage. It consist of set
of finite steps which, when carried out for a given set of inputs, produce the corresponding
output and terminate in a finite time.
The average case efficiency of an algorithm is its efficiency for an average case input
of size n. It provides information about an algorithm behavior on a “typical” or “random”
input.
UNIT - II
Linked list consists of a series of structures, which are not necessarily adjacent in
memory. Each structure contains the element and a pointer to a structure containing its
successor. We call this theNext Pointer. The last cell’sNext pointer points to NULL.
The different types of linked list include singly linked list, doubly linked list and circular
linked list.
• Creation of a list
• Insertion of a node
• Deletion of a node
• Modification of a node
• It is not necessary to specify the number of elements in a linked list during its declaration
• Linked list can grow and shrink in size depending upon the insertion and deletion that
occurs in the list
• Insertions and deletions at any place in a list can be handled easily and efficiently
5. What is a pointer?
Pointer is a variable, which stores the address of the next element in the list.
In a simple linked list, there will be one pointer named as 'NEXT POINTER' to point the next
element, where as in a doubly linked list, there will be two pointers one to point the next
element and the other to point the previous element location.
In a doubly linked list, if the last node or pointer of the list, point to the first element of the
list, then it is a circularly linked list.
8. What is a stack?
Stack is a data structure in which both insertion and deletion occur at one end only. Stack is
maintained with a single pointer to the top of the list of elements. The other name of stack is
Last-in -First-out list.
10.What are the postfix and prefix forms of the expression? A+B*(C-D)/(P-R)
UNIT- III
K
A[0]………A[m-1] A[m] A[m+1]………A[n-1]
search here if K<A[m] search here if K>A[m]
4. What are binary search trees and what is it mainly used for?
Binary search trees is one of the principal data structures for implementing dictionaries. It is
a binary tree whose nodes contain elements of a set of orderable items, one element per node,
so that all elements in the left subtree are smaller than the element in the subtree’s root and all
elements in the right subtree are greater than it.
9. Define Heap.
A heap is a partially ordered data structure, and can be defined as a binary tree
assigned to its nodes, one key per node, provided the following two conditions are met
i.The tree’s shape requirement-The binary tree is essentially complete, that is all the
leaves are full except possibly the last level, where only some rightmost leaves will be
missing.
ii.The parental dominance requirement-The key at each node is greater that or equal to
the keys of its children
UNIT – IV
UNIT – V
2. What is backtracking?
Backtracking constructs solutions one component at a time and such partially
constructed solutions are evaluated as follows
i. If a partially constructed solution can be developed further without
violating the problem’s constraints, it is done by taking the first remaining legitimate
option for the next component.
ii.If there is no legitimate option for the next component, no alternatives for the
remaining component need to be considered. In this case, the algorithm backtracks to replace
the last component of the partially constructed solution with its next option.
3. What is the manner in which the state-space tree for a backtracking algorithm is
constructed?
In the majority of cases, a state-space tree for backtracking algorithm is constructed in
the manner of depth-first search. If the current node is promising, its child is generated by
adding the first remaining legitimate option for the next component of a solution, and the
processing moves to this child. If the current node turns out to be non-promising, the
algorithm backtracks to the node’s parent to consider the next possible solution to the
problem, it either stops or backtracks to continue searching for other possible solutions.
7. What is the basic operation in the Tower of Hanoi problem and give the recurrence
relation for the number of moves?
The moving of disks is considered the basic operation in the Tower of Hanoi problem
and the recurrence relation for the number of moves is given as M(n)=2M(n)+1 for n>1
M(1)=1