Data Structures: Question 1. What Is Data Structure?
Data Structures: Question 1. What Is Data Structure?
C Interview Questions
12. Question 12. What Do You Mean By Free Pool?
Answer :
Pool is a list consisting of unused memory cells which has its own pointer.
Maven Tutorial
17. Question 17. What Is A Priority Queue?
Answer :
The priority queue is a data structure in which the intrinsic ordering of the
elements (numeric or alphabetic)
Determines the result of its basic operation. It is of two types:
i) Ascending priority queue- Here smallest item can be removed (insertion is
arbitrary).
ii) Descending priority queue- Here largest item can be removed (insertion is
arbitrary).
CSS Advanced Interview Questions
18. Question 18. What Are The Disadvantages Of Sequential Storage?
Answer :
i) Fixed amount of storage remains allocated to the data structure even if it
contains less element.
ii) No more than fixed amount of storage is allocated causing overflow.
DBMS Interview Questions
19. Question 19. What Are The Disadvantages Of Representing A Stack Or
Queue By A Linked List?
Answer :
i) A node in a linked list (info and next field) occupies more storage than a
corresponding element in an array.
ii) Additional time spent in managing the available list.
Object Oriented Analysis and Design Tutorial
20. Question 20. What Is Dangling Pointer And How To Avoid It?
Answer :
After a call to free(p) makes a subsequent reference to *p illegal, i.e. though the
storage to p is freed but the value of p(address) remain unchanged .so the object
at that address may be used as the value of *p (i.e. there is no way to detect the
illegality).Here p is called dangling pointer.
To avoid this it is better to set p to NULL after executing free(p).The null pointer
value doesn’t reference a storage location it is a pointer that doesn’t point to
anything.
Maven Interview Questions
21. Question 21. What Are The Disadvantages Of Linear List?
Answer :
i) We cannot reach any of the nodes that precede node (p).
ii) If a list is traversed, the external pointer to the list must be persevered in order
to reference the list again.
22. Question 22. Define Circular List?
Answer :
In linear list the next field of the last node contain a null pointer, when a next field
in the last node contain a pointer back to the first node it is called circular list.
Advantages – From any point in the list it is possible to reach at any other point.
23. Question 23. What Are The Disadvantages Of Circular List?
Answer :
i) We can’t traverse the list backward.
ii) If a pointer to a node is given we cannot delete the node.
Computer architecture Interview Questions
24. Question 24. Define Double Linked List?
Answer :
It is a collection of data elements called nodes,
where each node is divided into three parts:
1. An info field that contains the information stored in the node.
2. Left field that contain pointer to node on left side.
3. Right field that contain pointer to node on right side.
Adv Java Interview Questions
o Question 25. Is It Necessary To Sort A File Before Searching A
Particular Item ?
Answer :
If less work is involved in searching a element than to sort and then extract, then
we don’t go for sort.
If frequent use of the file is required for the purpose of retrieving specific element,
it is more efficient to sort the file.
Thus it depends on situation.
o Question 26. What Are The Issues That Hamper The Efficiency In
Sorting A File?
Answer :
The issues are:
1. Length of time required by the programmer in coding a particular
sorting program.
2. Amount of machine time necessary for running the particular
program.
3. The amount of space necessary for the particular program .
Object Oriented Analysis and Design Interview Questions
o Question 27. Calculate The Efficiency Of Sequential Search?
Answer :
The number of comparisons depends on where the record with the argument key
appears in the table.
If it appears at first position then one comparison
If it appears at last position then n comparisons
Average=(n+1)/2 comparisons
Unsuccessful search n comparisons
Number of comparisons in any case is O (n).
C Interview Questions
o Question 34. What Is The Data Structures Used To Perform
Recursion?
Answer :
Stack. Because of its LIFO (Last In First Out) property it remembers its ‘caller’ so
knows whom to return when the function has to return. Recursion makes use of
system stack for storing the return addresses of the function calls.
Every recursive function has its equivalent iterative (non-recursive) function. Even
when such equivalent iterative procedures are written, explicit stack is to be used.
o Question 35. What Are The Notations Used In Evaluation Of
Arithmetic Expressions Using Prefix And Postfix Forms?
Answer :
Polish and Reverse Polish notations.
o Question 36. Convert The Expression ((a + B) * C - (d - E) ^ (f + G)) To
Equivalent Prefix And Postfix Notations?
Answer :
Prefix Notation:
^ – * +ABC – DE + FG
postfix Notation:
AB + C * DE – – FG + ^
Database Administration Interview Questions
o Question 37. List Out Few Of The Application Of Tree Data-
structure?
Answer :
The manipulation of Arithmetic expression, Symbol Table construction & Syntax
analysis.
o Question 38. List Out Few Of The Applications That Make Use Of
Multilinked Structures?
Answer :
Sparse matrix, Index generation.
o Question 39. What Is The Type Of The Algorithm Used In Solving The
8 Queens Problem?
Answer :
Backtracking.
o Question 40. In An Avl Tree, At What Condition The Balancing Is To
Be Done?
Answer :
If the ‘pivotal value’ (or the ‘Height factor’) is greater than 1 or less than –1.
o Question 93. Define A Stack?
Answer :
Stack is an ordered collection of elements in which insertions and deletions are
restricted to one end. The end from which elements are added and/or removed is
referred to as top of the stack. Stacks are also referred as piles, push-down lists
and last-in-first-out (LIFO) lists.
o Question 94. List Out The Basic Operations That Can Be Performed
On A Stack ?
Answer :
The basic operations that can be performed on a stack are
1. Push operation.
2. Pop operation.
3. Peek operation.
4. Empty check.
5. Fully occupied check.
o Question 95. State The Different Ways Of Representing Expressions?
Answer :
The different ways of representing expressions are
1. Infix Notation.
2. Prefix Notation.
3. Postfix Notation.
o Question 96. State The Advantages Of Using Infix Notations?
Answer :
1. It is the mathematical way of representing the expression.
2. It is easier to see visually which operation is done from first to last.
o Question 97. State The Advantages Of Using Postfix Notations?
Answer :
1. Need not worry about the rules of precedence.
2. Need not worry about the rules for right to left associativity.
3. Need not need parenthesis to override the above rules.
o Question 98. State The Rules To Be Followed During Infix To Postfix
Conversions?
Answer :
1. Fully parenthesize the expression starting from left to right. During
parenthesizing, the operators having higher precedence are first
parenthesized.
2. Move the operators one by one to their right, such that each operator
replaces their corresponding right parenthesis.
3. The part of the expression, which has been converted into postfix is to
be treated as single operand.
4. Once the expression is converted into postfix form, remove all
parenthesis.
o Question 99. State The Rules To Be Followed During Infix To Prefix
Conversions?
Answer :
1. Fully parenthesize the expression starting from left to right. During
parenthesizing, the operators having higher precedence are first
parenthesized.
2. Move the operators one by one to their left, such that each operator
replaces their corresponding left parenthesis.
3. The part of the expression, which has been converted into prefix is to
be treated as single operand.
4. Once the expression is converted into prefix form, remove all
parenthesis.
o Question 100. State The Difference Between Stacks And Linked
Lists?
Answer :
The difference between stacks and linked lists is that insertions and deletions
may occur anywhere in a linked list, but only at the top of the stack.
o Question 101. Mention The Advantages Of Representing Stacks
Using Linked Lists Than Arrays?
Answer :
1. It is not necessary to specify the number of elements to be stored in a
stack during its declaration, since memory is allocated dynamically at
run time when an element is added to the stack.
2. Insertions and deletions can be handled easily and efficiently.
3. Linked list representation of stacks can grow and shrink in size
without wasting memory space, depending upon the insertion and
deletion that occurs in the list.
4. Multiple stacks can be represented efficiently using a chain for each
stack.
o Question 102. Define A Queue?
Answer :
Queue is an ordered collection of elements in which insertions are restricted to
one end called the rear end and deletions are restricted to other end called the
front end. Queues are also referred as First-In-First-Out (FIFO) Lists.
o Question 103. Define A Priority Queue?
Answer :
Priority queue is a collection of elements, each containing a key referred as the
priority for that element. Elements can be inserted in any order (i.e., of alternating
priority), but are arranged in order of their priority value in the queue. The
elements are deleted from the queue in the order of their priority (i.e., the
elements with the highest priority is deleted first). The elements with the same
priority are given equal importance and processed accordingly.
o Question 104. State The Difference Between Queues And Linked
Lists?
Answer :
The difference between queues and linked lists is that insertions and deletions
may occur anywhere in the linked list, but in queues insertions can be made only
in the rear end and deletions can be made only in the front end.
o Question 105. Define A Deque?
Answer :
Deque (Double-Ended Queue) is another form of a queue in which insertions and
deletions are made at both the front and rear ends of the queue. There are two
variations of a deque, namely, input restricted deque and output restricted deque.
The input restricted deque allows insertion at one end (it can be either front or
rear) only. The output restricted deque allows deletion at one end (it can be either
front or rear) only.
o Question 106. Why You Need A Data Structure?
Answer :
A data structure helps you to understand the relationship of one data element
with the other and organize it within the memory. Sometimes the organization
might be simple and can be very clearly visioned.
Eg; List of names of months in a year –Linear Data Structure, List of historical
places in the world- Non-Linear Data Structure. A data structure helps you to
analyze the data, store it and organize it in a logical and mathematical manner.
o Question 107. What Do You Mean By Shortest Path?
Answer :
A path having minimum weight between two vertices is known as shortest path, in
which weight is always a positive number.
o Question 108. What Do You Mean By Articulation Point?
Answer :
If a graph is not biconnected, the vertices whose removal would disconnect the
graph are known as articulation points.
o Question 109. Define Biconnectivity?
Answer :
A connected graph G is said to be biconnected, if it remains connected after
removal of any one vertex and the edges that are incident upon that vertex. A
connected graph is biconnected, if it has no articulation points.
o Question 110. What Do You Mean By Back Edge?
Answer :
If w is the ancestor of v, then vw is called a back edge.
o Question 111. What Do You Mean By Tree Edge?
Answer :
If w is undiscovered at the time vw is explored, then vw is called a tree edge and v
becomes the parent of w.
o Question 112. Differentiate Bfs And Dfs?
Answer :
o Question 113. What Do You Mean By Breadth First Search (bfs)?
Answer :
BFS performs simultaneous explorations starting from a common point and
spreading out independently.
o Question 114. List The Two Important Key Points Of Depth First
Search?
Answer :
i) If path exists from one node to another node, walk across the edge – exploring
the edge.
ii) If path does not exist from one specific node to any other node, return to the
previous node where we have been before – backtracking.
o Question 115. Define Graph Traversals?
Answer :
Traversing a graph is an efficient way to visit each vertex and edge exactly once.
o Question 116. Name Two Algorithms Two Find Minimum Spanning
Tree?
Answer :
1. Kruskal’s algorithm.
2. Prim’s algorithm.
o Question 117. What Is A Minimum Spanning Tree?
Answer :
A minimum spanning tree of an undirected graph G is a tree formed from graph
edges that connects all the vertices of G at the lowest total cost.
o Question 118. What Are The Two Traversal Strategies Used In
Traversing A Graph?
Answer :
1. Breadth first search
2. Depth first search
o Question 119. When Is A Graph Said To Be Weakly Connected?
Answer :
When a directed graph is not strongly connected but the underlying graph is
connected, then the graph is said to be weakly connected.
o Question 120. What Is Meant By Strongly Connected In A Graph?
Answer :
An undirected graph is connected, if there is a path from every vertex to every
other vertex. A directed graph with this property is called strongly connected.
o Question 121. What Is An Acyclic Graph?
Answer :
A simple diagram which does not have any cycles is called an acyclic graph.
o Question 122. What Is A Cycle Or A Circuit?
Answer :
A path which originates and ends in the same node is called a cycle or circuit.
o Question 123. What Is A Simple Path?
Answer :
A path in a diagram in which the edges are distinct is called a simple path. It is
also called as edge simple.
o Question 124. Define Path In A Graph?
Answer :
The path in a graph is the route taken to reach terminal node from a starting node.
o Question 125. Define Indegree Of A Graph?
Answer :
In a directed graph, for any node v, the number of edges which have v as their
terminal node is called the indegree of the node v.
o Question 126. Define Outdegree Of A Graph?
Answer :
In a directed graph, for any node v, the number of edges which have v as their
initial node is called the out degree of the node v.
o Question 127. What Is A Weighted Graph?
Answer :
A graph in which weights are assigned to every edge is called a weighted graph.
o Question 128. What Is A Simple Graph?
Answer :
A simple graph is a graph, which has not more than one edge between a pair of
nodes than such a graph is called a simple graph.
o Question 129. What Is A Loop?
Answer :
An edge of a graph which connects to itself is called a loop or sling.
o Question 130. What Is A Undirected Graph?
Answer :
A graph in which every edge is undirected is called a directed graph.
o Question 131. What Is A Directed Graph?
Answer :
A graph in which every edge is directed is called a directed graph.
o Question 132. Define Adjacent Nodes?
Answer :
Any two nodes which are connected by an edge in a graph are called adjacent
nodes. For example, if an edge x ε E is associated with a pair of nodes (u,v) where
u, v ε V, then we say that the edge x connects the nodes u and v.
o Question 133. Define Graph?
Answer :
A graph G consist of a nonempty set V which is a set of nodes of the graph, a set
E which is the set of edges of the graph, and a mapping from the set for edge E to
a set of pairs of elements of V. It can also be represented as G=(V, E).
o Question 134. What Is The Need For Path Compression?
Answer :
Path compression is performed during a Find operation. Suppose if we want to
perform Find(X), then the effect of path compression is that every node on the
path from X to the root has its parent changed to the root.
o Question 135. What Do You Mean By Union-by-weight?
Answer :
Keep track of the weight ie; size of each tree and always append the smaller tree
to the larger one when performing UNION.
o Question 136. List The Abstract Operations In The Set?
Answer :
Let S and T be sets and e be an element.
SINGLETON(e) returns {e}.
UNION(S,T) returns S Ụ T.
INTERSECTION(S,T) returns S ∩ T.
FIND returns the name of the set containing a given element.
o Question 137. Define A Set?
Answer :
A set S is an unordered collection of elements from a universe. An element cannot
appear more than once in S. The cardinality of S is the number of elements in S.
An empty set is a set whose cardinality is zero. A singleton set is a set whose
cardinality is one.
o Question 138. What Do You Mean By Disjoint Set Adt?
Answer :
A collection of non-empty disjoint sets S=S1,S2,….,Sk i.e;each Si is a non-empty
set that has no element in common with any other Sj. In mathematical notation
this is: Si∩Sj=Ф. Each set is identified by a unique element called its
representative.
o Question 139. List The Applications Of Set Adt?
Answer :
Maintaining a set of connected components of a graph.
Maintain list of duplicate copies of web pages.
Constructing a minimum spanning tree for a graph.
2. Question 140. Define An Equivalence Relation?
Answer :
An equivalence relation is a relation R that satisfies three properties:
o (Reflexive) aRa, for all a ε S.
o (Symmetric) aRb if and only if bRa.
o (Transitive) aRb and bRc implies that aRc.
o Question 141. Define A Relation?
Answer :
A relation R is defined on a set S if for every pair of elements (a,b), a,b ε S, aRb is
either true or false. If aRb is true, then we say that a is related to b.
o Question 142. Mention One Advantage And Disadvantage Of Using
Quadratic Probing?
Answer :
Advantage: The problem of primary clustering is eliminated.
Disadvantage: There is no guarantee of finding an unoccupied cell once the table
is nearly half full.
o Question 143. List The Limitations Of Linear Probing?
Answer :
o Time taken for finding the next available cell is large.
o In linear probing, we come across a problem known as
clustering.
o Question 144. What Is The Need For Extendible Hashing?
Answer :
If either open addressing hashing or separate chaining hashing is used, the major
problem is that collisions could cause several blocks to be examined during a
Find, even for a well-distributed hash table. Extendible hashing allows a find to be
performed in two disk accesses. Insertions also require few disk accesses.
o Question 145. What Do You Mean By Rehashing?
Answer :
If the table gets too full, the running time for the operations will start taking too
long and inserts might fail for open addressing with quadratic resolution. A
solution to this is to build another table that is about twice as big with the
associated new hash function and scan down the entire original hash table,
computing the new hash value for each element and inserting it in the new table.
This entire operation is called rehashing.
o Question 146. What Do You Mean By Double Hashing?
Answer :
Double hashing is an open addressing collision resolution strategy in which
F(i)=i.hash2(X). This formula says that we apply a second hash function to X and
probe at a distance hash2(X), 2hash2(X),….,and so on. A function such as
hash2(X)=R-(XmodR), with R a prime smaller than Tablesize.
o Question 147. What Do You Mean By Secondary Clustering?
Answer :
Although quadratic probing eliminates primary clustering, elements that hash to
the same position will probe the same alternative cells. This is known as
secondary clustering.
o Question 148. What Do You Mean By Quadratic Probing?
Answer :
Quadratic probing is an open addressing collision resolution strategy in which
F(i)=i2. There is no guarantee of finding an empty cell once the table gets half full
if the table size is not prime. This is because at most half of the table can be used
as alternative locations to resolve collisions.
o Question 149. What Do You Mean By Primary Clustering?
Answer :
In linear probing collision resolution strategy, even if the table is relatively empty,
blocks of occupied cells start forming. This effect is known as primary clustering
means that any key hashes into the cluster will require several attempts to resolve
the collision and then it will add to the cluster.
o Question 150. What Do You Mean By Linear Probing?
Answer :
Linear probing is an open addressing collision resolution strategy in which F is a
linear function of i, F(i)=i. This amounts to trying sequentially in search of an
empty cell. If the table is big enough, a free cell can always be found, but the time
to do so can get quite large.
o Question 151. What Do You Mean By Probing?
Answer :
Probing is the process of getting next available hash table array cell.
o Question 152. What Are The Types Of Collision Resolution
Strategies In Open Addressing?
Answer :
o Linear probing.
o Quadratic probing.
o Double hashing.
o Question 153. What Do You Mean By Open Addressing?
Answer :
Open addressing is a collision resolving strategy in which, if collision occurs
alternative cells are tried until an empty cell is found. The cells h0(x), h1(x), h2(x),
…. are tried in succession, where hi(x)=(Hash(x)+F(i))mod Tablesize with F(0)=0.
The function F is the collision resolution strategy.
o Question 154. Write The Disadvantages Of Separate Chaining?
Answer :
o The elements are evenly distributed. Some elements may have
more elements and some may not have anything.
o It requires pointers. This leads to slow the algorithm down a bit
because of the time required to allocate new cells, and also essentially
requires the implementation of a second data structure.
o Question 155. Write The Advantage Of Separate Chaining?
Answer :
More number of elements can be inserted as it uses linked lists.
o Question 156. What Do You Mean By Separate Chaining?
Answer :
Separate chaining is a collision resolution technique to keep the list of all
elements that hash to the same value. This is called separate chaining because
each hash table element is a separate chain (linked list). Each linked list contains
all the elements whose keys hash to the same index.
o Question 157. What Are The Collision Resolution Methods?
Answer :
o Separate chaining or External hashing.
o Open addressing or Closed hashing.
o Question 158. What Do You Mean By Collision In Hashing?
Answer :
When an element is inserted, it hashes to the same value as an already inserted
element, and then it produces collision.
o Question 159. Write The Importance Of Hashing?
Answer :
o Maps key with the corresponding value using hash function.
o Hash tables support the efficient addition of new entries and
the time spent on searching for the required data is independent of the
number of items stored.
o Question 160. What Do You Mean By Hash Function?
Answer :
A hash function is a key to address transformation which acts upon a given key to
compute the relative position of the key in an array. The choice of hash function
should be simple and it must distribute the data evenly. A simple hash function is
hash_key=key mod tablesize.
o Question 161. What Do You Mean By Hash Table?
Answer :
The hash table data structure is merely an array of some fixed size, containing the
keys. A key is a string with an associated value. Each key is mapped into some
number in the range 0 to tablesize-1 and placed in the appropriate cell.
o Question 162. Define Hashing?
Answer :
Hashing is the transformation of string of characters into a usually shorter fixed
length value or key that represents the original string. Hashing is used to index
and retrieve items in a database because it is faster to find the item using the
short hashed key than to find it using the original value.
o Question 163. What Do You Mean By The Term "percolate Down"?
Answer :
When the minimum element is removed, a hole is created at the root. Since the
heap now becomes one smaller, it follows that the last element X in the heap
must move somewhere in the heap. If X can be placed in the hole, then we are
done.. This is unlikely, so we slide the smaller of the hole’s children into the hole,
thus pushing the hole down one level. We repeat this step until X can be placed in
the hole. Thus, our action is to place X in its correct spot along a path from the
root containing minimum children. This general strategy is known as percolate
down.
o Question 164. What Do You Mean By The Term "percolate Up"?
Answer :
To insert an element, we have to create a hole in the next available heap location.
Inserting an element in the hole would sometimes violate the heap order property,
so we have to slide down the parent into the hole. This strategy is continued until
the correct location for the new element is found. This general strategy is known
as a percolate up; the new element is percolated up the heap until the correct
location is found.
o Question 165. What Are The Applications Of Priority Queues?
Answer :
o The selection problem.
o Event simulation.
o Question 166. What Do You Mean By Heap Order Property?
Answer :
In a heap, for every node X, the key in the parent of X is smaller than (or equal to)
the key in X, with the exception of the root (which has no parent).
o Question 167. What Do You Mean By Structure Property In A Heap?
Answer :
A heap is a binary tree that is completely filled with the possible exception at the
bottom level, which is filled from left to right. Such a tree is known as a complete
binary tree.
o Question 168. What Are The Properties Of Binary Heap?
Answer :
o Structure Property.
o Heap Order Property.
o Question 169. What Is The Need For Priority Queue?
Answer :
In a multiuser environment, the operating system scheduler must decide which of
the several processes to run only for a fixed period of time. One algorithm uses
queue. Jobs are initially placed at the end of the queue. The scheduler will
repeatedly take the first job on the queue, run it until either it finishes or its time
limit is up and place it at the end of the queue if it does not finish. This strategy is
not appropriate, because very short jobs will soon to take a long time because of
the wait involved in the run.
Generally, it is important that short jobs finish as fast as possible, so these jobs
should have precedence over jobs that have already been running. Further more,
some jobs that are not short are still very important and should have precedence.
This particular application seems to require a special kind of queue, known as
priority queue. Priority queue is also called as Heap or Binary Heap.
o Question 170. What Are The Applications Of B-tree?
Answer :
o Database implementation.
o Indexing on non primary key fields.
o Question 171. What Do You Mean By 2-3-4 Tree?
Answer :
A B-tree of order 4 is called 2-3-4 tree. A B-tree of order 4 is a tree that is not
binary with the following structural properties:
o The root is either a leaf or has between 2 and 4 children.
o All non-leaf nodes (except the root) have between 2 and 4
children.
o All leaves are at the same depth.
o Question 172. What Do You Mean By 2-3 Tree?
Answer :
A B-tree of order 3 is called 2-3 tree. A B-tree of order 3 is a tree that is not binary
with the following structural properties:
o The root is either a leaf or has between 2 and 3 children.
o All non-leaf nodes (except the root) have between 2 and 3
children.
o All leaves are at the same depth.
o Question 173. Define B-tree Of Order M?
Answer :
A B-tree of order M is a tree that is not binary with the following structural
properties:
o The root is either a leaf or has between 2 and M children.
o All non-leaf nodes (except the root) have between [M/2] and M
children.
o All leaves are at the same depth.
o Question 174. What Is The Minimum Number Of Nodes In An Avl
Tree Of Height H?
Answer :
The minimum number of nodes S(h), in an AVL tree of height h is given by
S(h)=S(h-1)+S(h-2)+1. For h=0, S(h)=1.
o Question 175. Define Heap?
Answer :
A heap is defined to be a complete binary tree with the property that the value of
each node is atleast as small as the value of its child nodes, if they exist. The root
node of the heap has the smallest value in the tree.
o Question 176. List The Types Of Rotations Available In Splay Tree?
Answer :
Let us assume that the splay is performed at vertex v, whose parent and
grandparent are p and g respectively. Then, the three rotations are named as:
Zig: If p is the root and v is the left child of p, then left-left rotation at p would
suffice. This case always terminates the splay as v reaches the root after this
rotation.
Zig-Zig: If p is not the root, p is the left child and v is also a left child, then a left-
left rotation at g followed by a left-left rotation at p, brings v as an ancestor of g as
well as p.
Zig-Zag: If p is not the root, p is the left child and v is a right child, perform a left-
right rotation at g and bring v as an ancestor of p as well as g.
o Question 177. What Is The Idea Behind Splaying?
Answer :
Splaying reduces the total accessing time if the most frequently accessed node is
moved towards the root. It does not require to maintain any information regarding
the height or balance factor and hence saves space and simplifies the code to
some extent.
o Question 178. Define Splay Tree?
Answer :
A splay tree is a binary search tree in which restructuring is done using a scheme
called splay. The splay is a heuristic method which moves a given vertex v to the
root of the splay tree using a sequence of rotations.
o Question 179. What Do You Mean By Balance Factor Of A Node In
Avl Tree?
Answer :
The height of left subtree minus height of right subtree is called balance factor of
a node in AVL tree.The balance factor may be either 0 or +1 or -1.The height of an
empty tree is -1.
o Question 180. What Are The Categories Of Avl Rotations?
Answer :
Let A be the nearest ancestor of the newly inserted nod which has the balancing
factor ±2. Then the rotations can be classified into the following four categories:
Left-Left: The newly inserted node is in the left subtree of the left child of A.
Right-Right: The newly inserted node is in the right subtree of the right child of A.
Left-Right: The newly inserted node is in the right subtree of the left child of A.
Right-Left: The newly inserted node is in the left subtree of the right child of A.
o Question 181. What Do You Mean By Balanced Trees?
Answer :
Balanced trees have the structure of binary trees and obey binary search tree
properties. Apart from these properties, they have some special constraints,
which differ from one data structure to another. However, these constraints are
aimed only at reducing the height of the tree, because this factor determines the
time complexity.
Eg: AVL trees, Splay trees.
o Question 182. Define Avl Tree?
Answer :
An empty tree is height balanced. If T is a non-empty binary tree with TL and TR as
its left and right subtrees, then T is height balanced if
o TL and TR are height balanced and
o │hL - hR│≤ 1
Where hL and hR are the heights of TL and TR respectively.
o Question 183. Define Left-in Threaded Tree?
Answer :
Left-in threaded binary tree is defined as one in which each NULL pointers is
altered to contain a thread to that node’s inorder predecessor.
o Question 184. Define Right-in Threaded Tree?
Answer :
Right-in threaded binary tree is defined as one in which threads replace NULL
pointers in nodes with empty right sub-trees.
o Question 185. What Is An Expression Tree?
Answer :
An expression tree is a tree which is build from infix or prefix or postfix
expression. Generally, in such a tree, the leaves are operands and other nodes are
operators.
o Question 186. What Is The Use Of Threaded Binary Tree?
Answer :
In threaded binary tree, the NULL pointers are replaced by some addresses. The
left pointer of the node points to its predecessor and the right pointer of the node
points to its successor.
o Question 187. Why It Is Said That Searching A Node In A Binary
Search Tree Is Efficient Than That Of A Simple Binary Tree?
Answer :
In binary search tree, the nodes are arranged in such a way that the left node is
having less data value than root node value and the right nodes are having larger
value than that of root. Because of this while searching any node the value of the
target node will be compared with the parent node and accordingly either left sub
branch or right sub branch will be searched. So, one has to compare only
particular branches. Thus searching becomes efficient.
o Question 188. Define Ancestor And Descendant ?
Answer :
If there is a path from node n1 to n2, then n1 is the ancestor of n2 and n2 is the
descendant of n1.
o Question 189. What Do You Mean By General Trees?
Answer :
General tree is a tree with nodes having any number of children.
o Question 190. Define A Binary Search Tree?
Answer :
A binary search tree is a special binary tree, which is either empty or it should
satisfy the following characteristics:
o Every node has a value and no two nodes should have the
same value i.e) the values in the binary search tree are distinct.
o The values in any left sub-tree is less than the value of its
parent node.
o The values in any right sub-tree is greater than the value of its
parent node.
o The left and right sub-trees of each node are again binary
search trees.
o Question 191. State The Demerits Of Linked Representation Of
Binary Trees?
Answer :
o Given a node structure, it is difficult to determine its parent
node.
o Memory spaces are wasted for storing null pointers for the
nodes, which have one or no sub-trees.
o It requires dynamic memory allocation, which is not possible in
some programming language.
o Question 192. State The Merit Of Linked Representation Of Binary
Trees?
Answer :
Insertions and deletions in a node involve no data movement except the
rearrangement of pointers, hence less processing time.
o Question 193. State The Demerit Of Linear Representation Of Binary
Trees?
Answer :
Insertions and deletions in a node take an excessive amount of processing time
due to data movement up and down the array.
o Question 194. State The Merits Of Linear Representation Of Binary
Trees?
Answer :
o Storage method is easy and can be easily implemented in
arrays.
o When the location of a parent/child node is known, other one
can be determined easily.
o It requires static memory allocation so it is easily implemented
in all programming language.
o Question 195. What Are The Tasks Performed During Postorder
Traversal?
Answer :
o Traverse the left sub-tree.
o Traverse the right sub-tree.
o Process the root node.
o Question 196. What Are The Tasks Performed During Inorder
Traversal?
Answer :
o Traverse the left sub-tree.
o Process the root node.
o Traverse the right sub-tree.
o Question 197. What Are The Tasks Performed During Preorder
Traversal?
Answer :
o Process the root node.
o Traverse the left sub-tree.
o Traverse the right sub-tree.
o Question 198. What Are The Tasks Performed While Traversing A
Binary Tree?
Answer :
o Visiting a node.
o Traverse the left sub-tree.
o Traverse the right sub-tree.
o Question 199. What Are The Different Binary Tree Traversal
Techniques?
Answer :
o Preorder traversal.
o Inorder traversal.
o Postorder traversal.
o Levelorder traversal.
o Question 200. What Is Meant By Binary Tree Traversal?
Answer :
Traversing a binary tree means moving through all the nodes in the binary tree,
visiting each node in the tree only once.
o Question 201. State The Properties Of A Binary Tree?
Answer :
o The maximum number of nodes on level n of a binary tree is
2n-1, where n≥1.
o The maximum number of nodes in a binary tree of height n is
2n-1, where n≥1.
o For any non-empty tree, nl=nd+1 where nl is the number of leaf
nodes and nd is the number of nodes of degree 2.
o Question 202. Define A Right-skewed Binary Tree?
Answer :
A right-skewed binary tree is a tree, which has only right child nodes.
o Question 203. Define A Complete Binary Tree?
Answer :
A complete binary tree is a tree in which every non-leaf node has exactly two
children not necessarily to be on the same level.
o Question 204. Define A Full Binary Tree ?
Answer :
A full binary tree is a tree in which all the leaves are on the same level and every
non-leaf node has exactly two children.
o Question 205. Define Non-terminal Nodes In A Tree?
Answer :
All intermediate nodes that traverse the given tree from its root node to the
terminal nodes are referred as non-terminal nodes.
o Question 206. Define Terminal Nodes In A Tree?
Answer :
A node that has no children is called a terminal node. It is also referred to as leaf
node.
o Question 207. Define A Path In A Tree?
Answer :
A path in a tree is a sequence of distinct nodes in which successive nodes are
connected by edges in the tree.
o Question 208. Define A Binary Tree?
Answer :
A binary tree is a finite set of nodes which is either empty or consists of a root and
two disjoint binary trees called the left sub-tree and right sub-tree.
o Question 209. Define Forest?
Answer :
A tree may be defined as a forest in which only a single node (root) has no
predecessors. Any forest consists of a collection of trees.
o Question 210. What Do You Mean By Level Of The Tree?
Answer :
The root node is always considered at level zero, then its adjacent children are
supposed to be at level 1 and so on.
Here, node A is at level 0, nodes B and C are at level 1 and nodes D and E are at
level 2.
o Question 211. Define Depth And Height Of A Tree?
Answer :
The depth of the tree is the depth of the deepest leaf. The height of the tree is
equal to the height of the root. Always depth of the tree is equal to height of the
tree.
o Question 212. Define Depth And Height Of A Node?
Answer :
For any node ni, the depth of ni is the length of the unique path from the root to ni.
The height of ni is the length of the longest path from ni to a leaf.
o Question 213. Define Parent Node?
Answer :
The node which is having further sub-branches is called the parent node of those
sub-branches.
Here C is the parent node of D and E.
o Question 214. Define Internal Nodes?
Answer :
The nodes other than the root and the leaves are called internal nodes.
Where S is a tag for user defined data type which defines the structure student
and s1 is a variable of data type S.
o Question 229. Difference Between Abstract Data Type, Data Type
And Data Structure?
Answer :
o An Abstract data type is the specification of the data type
which specifies the logical and mathematical model of the data type.
o A data type is the implementation of an abstract data type.
o Data structure refers to the collection of computer variables
that are connected in some specific manner.
i.e) Data type has its root in the abstract data type and a data structure comprises
a set of computer variables of same or different data types.
o Question 230. State The Difference Between Queues And Linked
Lists?
Answer :
The difference between queues and linked lists is that insertions and deletions
may occur anywhere in the linked list, but in queues insertions can be made only
in the rear end and deletions can be made only in the front end.