Sie sind auf Seite 1von 25

Data Structure and Algorithms

UNIT – I

PART- A Questions & Answers

1.Define data structure.


Data Structure is a way of representing data that contains both the data item & their
relationship with each other

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

2. Mention applications of Data structure?


a. Database Management Systems
b. Operating Systems
c. Compiler Design
d. Graphics
e. Artificial Intelligence.

3.Explain the types of Data Structure?


1. PRIMITIVE
These are basic structures and are directly operated upon by the machine
instructions.
a. Integer
b. Float
c. Char
d. Pointer.
2. NON-PRIMITIVE
This type of data structure emphasize on structuring of a group of
homogeneous or heterogeneous data items.
a. Arrays
b. Lists
i. Linear Lists
a. Stack
b. Queue
ii. Non Linear List
a. Graph
b. Tree
c. Files

4. Define ADT (Abstract Data Type)?


An ADT is a mathematical model with a collection of operations defined
on that model.
5.Define Linear data structure?
Linear data structures are data structures having a linear relationship between its
adjacent elements. Eg. Linked List.

6. Define Non Linear data structure?


Non Linear data structures are data structures don’t have a linear relationship
between its adjacent elements, but had the hierarchical relationship. Ex. Graph, Tree.

7. Define storage structure.


The representation of a particular data structure in the memory of a computer is
called a storage structure.

8. Define file structure.


A storage structure representation in auxiliary memory of the compute is known
as file structure.

9. What do you mean by recursive procedure?


A procedure that contains a procedure call to itself, or a procedure call to a second
procedure which eventually causes the first procedure to be called is known as recursive
procedure.

10.What do you mean by addressing function?


An addressing function for a data structure consisting of n elements is a function
which maps the ith element of the data structure onto an integer between one and n.

11. What are the two types of recursive function?


1. Primitive recursive function.
2. Non primitive recursive function.

12. What are the four major parts in an iterative process


1) Initialization
2) Decision
3) Computation
4) Update

13.Differentiate function & procedure


A function is a sub algorithm which is used when one wants a single value
returned to the calling routine.
A procedure is a sub algorithm which does not return any value explicitly

14.How the character information is represented in memory?


A character is represented in memory as a sequence of bits where a
distinctive bit sequence is assigned to each character in the character set.
Character sets are encoded in fixed length bit sequences.

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.

16.What are the primitive functions associated with string?


• Create a string of text
• Concatenating two strings to form another string
• Search and replace a given string
• Test for the identity of a string
• Compute the length of a string

17.What is Recursion. Give an example.


Recursion is a conditional call by procedures or functions to itself.
Eg: Factorial Computation, Ackermann’s Function, GCD

18. What are the different types of data structures?


i) Primitive data structure
ii) Non primitive data structure.

19. What do you mean by primitive data structure?


Primitive data structure is concerned with structuring of data at their most
primitive level within a computer, that is the data structures are directly operated upon by
machine-level instructions
eg) Integers, real number, characters

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.

21.What are the composite functions related with string?


• LEN
• MATCH
• SPAN
• FIND

22.How to express a string in algorithm notation?


A string is represented within single quotes. A single quote contained within
a string is represented by 2 single quotes. An empty string is expressed as ‘‘.

UNIT – II
PART- A Questions & Answers

1. Define stack and list the operations on stack


It is a linear data structure that follows the LIFO(Last-in-First-Out) strategy in which
both insertions or deletions are performed at only one end called TOP.
The operations are:
• PUSH – Insertion
• POP – Deletion

2. Define Queue and list the operations on queue


It is a linear data structure that follows the FIFO(First-in-First-Out) strategy in which
both insertion occur through one end called REAR and deletion occur through
another end called FRONT.
The operations are:
 INSERT– Insertion
 REMOVE - Deletion

3. Give some applications of stack


 Implementing Subroutine calls in Compiler
 Recursion
 Evaluation of Arithmetic Expression

4. Give some applications of Queue


 Simulation
 Operating System
 Project Scheduling

5. Define singly linked list.


A singly linked list is a list structure in which each node contains a single pointer
field that points to the next node in the list, along with a data field.
Head
AAA BBB CCC DDD
6. Define doubly linked list.
A doubly linked list is a list structure in which each node contains two pointer fields:
BLINK – points to the previous node in the list, FLINK – points to the successive
node in the list
Head
AAA BBB CCC DDD
7. Define dummy header.
Dummy header is a head node in the linked list before the actual data nodes. It is also
called as the pre-first node of the list. It contains the number of data nodes in the list,
type of data stored in the nodes.

8. Explain priority queue.


A queue in which items are inserted or removed from any position based on some
property such as priority of the task to be processed is referred to as Priority Queue.

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

13. Write the steps required to evaluate the postfix expression.


• Repeatedly read characters from postfix expression
• If the character read is operand, push the value associated with it onto
the stack
• If it is operator, pop the top two values from stack, apply the operator
to them and push the result back onto the stack.

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.

15. What are different types of Linked List?


Single linked list
Double linked list
Circular linked list

16. What are different types of Circular Linked List?


Circular Single linked list
Circular double linked list
17.Define singly linked linear list.
A simple way to represent a linear list is to expand each node to contain a link or
pointer to the next node. This representation is called a one-way chain or singly linked
linear list.
18.Differentiate a stack from a Queue.

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.

19. List out the advantages of circular linked list.


i) In circular lined list every node is accessible from a given node.
ii) Deletion operation can be done without knowing the address of first node
iii) Concatenation and splitting become more efficient.

20. What do you mean by priority Queue?


A Queue in which we are able to insert items or remove items from any position
based on some property is often referred to as a priority 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.

22. What do you mean by recursive procedure?


A procedure that contains a procedure call to itself, or a procedure call to a second
procedure which eventually causes the first procedure to be called is known as recursive
procedure.

23. Write down the application of stack.


i) Balancing of symbol
ii) Evaluation of postfix expression
iii) Conversion of infix to postfix expression.
iv) Conversion of postfix to object code
v) Recursion

24. What do you mean by array of structure?


An array of structure is simply an array whose elements are structures. These
elements have identical names, levels and subparts.
25. Write down the algorithm for converting infix expression to postfix form
1. Initialise stack contents to the special symbol #
2. Scan the left most symbol in the given infix expression and denot it as current
input symbol.
3. Repeat thru step t while the current input symbol is not #
4. Remove and output all stack symbols whose precedence values are grater than
or equal to the procedure of the current input symbol.
5. Push current input symbol on to the stack.
6. Scan the left most symbol in the infix expression and let it be the current input
symbol.

26. What do you mean by a list?


List is an ordered set of variable number of elements to which insertions and
deletions can be made.

27. What do you mean by Linear data structure?


Linear data structure is defined as a list which displays the relationship of
adjacency between elements.

28. What are the three stages of problem solving aspect.


i) Selection of an appropriate mathematical model
ii) Formulation of algorithms based on the choice made in stage I
iii) The design of storage structures for the data structure.

29.Write down the algorithm for removing an element from stack


i) Check for underflow on stack.,
ii) Decrement pointer
iii) Return former top element of stack.

30. List the basic operations carried out in a linked list?


a. Creation of list
b. Insertion of list
c. Deletion of list
d. Modification of list
e. Traversal of List

31. Define a stack?


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” and “push-down lists”.

32. Define a queue?


Queue 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 the rear end and the end from which deletions are made is referred to as
front end.

33. Difference between Arrays and Linked List?

Arrays Linked List


Size of any array is fixed Size of list is variable
It is necessary to specify the number of It is not necessary to specify the number of
elements during declaration elements during declaration
Insertion and deletions are difficult and Insertions and deletions are done in less
costly time
It occupies less memory than a linked list It occupies more memory
Coding is easy Careful coding is needed to avoid memory
errors.

34. What is single linked list?


It is a linear data structure which consists a pointer field that points to the
address of its next node(successor) and the data item.

35. Define HEAD pointer and NULL pointer?


HEAD It contains the address of the first node in that list.
NULL It indicates the end of the list structure.

36. What is meant by dummy header?


It is ahead node in the linked list before the actual data nodes.

37. Define double linked list?


It is linear data structure which consists of two links or pointer fields
Next pointer points to the address of the next(successor) node.
Previous pointer points to the address of the previous(predecessor) node.

38. Define Circular linked list?


It is a list structure in which last node points to the first node there is no null
value.

39. Write operations that can be done on stack?


PUSH and POP

40. Mention applications of stack?


a. Expression Parsing
b. Evaluation of Postfix
c. Balancing parenthesis
d. Tower of Hanoi
e. Reversing a string
41. Define Infix, prefix and postfix notations?
Infix operators are placed in between the operands
Prefix operators are placed before the operands
Postfix Operators are placed after the operands.

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

45.Define Circular queue?


A circular queue allows the queue to wrap around upon reaching the end of the
array.

46. What is the Time complexity of a circular queue?


Insertion and deletion can be carried out in a fixed amount. The time complexity
is given by O(1).

47. Write the application of queue?


Image component Labeling.

48. What do you mean by Cursor?


The Old languages like Fortran.,Basic does not have pointer concepts. To make
pointer based implementation , the cursor is used . Each cursor node contains the data
element and a position field to store the index position of the next node. Array structure is
used to implement the cursor.
49.hat do you mean by array of structure?
An array of structure is simply an array whose elements are structures. These
elements have identical names, levels and subparts.

50. Define some applications of Linked list.


• Polynomial Manipulation
• Linked Dictionary
• Multiple-precision Arithmetic

51.Define linked queue and linked stack.


Queue implemented with Linked List representation is called Linked
Queue and the Stack implemented with a linked list is called a Linked Stack.

52.What is associative list?


An associative list can be viewed as a linear list in which each element or node of the
list contains two or more information items.. Each element is referenced through an
associated name.
UNIT – III
PART- A Questions & Answers

1. Define tree and subtree.


Tree is a non-linear data structure that represents hierarchical relationships
between
the individual data items.
Subtree is a subset of a tree that itself is a tree.

2. What is a binary tree?


Binary tree is a tree where each node has no more than two child nodes.

3. What are the different traversals of a tree?


The different traversals of a tree are:
Preorder (NLR)
Inorder (LNR)
Postorder (LRN)

4. What are the applications of a tree?


The applications of a tree are:
Computer science Applications - Evaluation of algebraic expression
Data processing - Information management system ,
File oriented applications

5. State the ordering property of binary Tree


For any given data item X in the tree every node in the left subtree of X
contains
only the items that are less than or equal to X with respect to particular type of
ordering.
Every node in the right subtree contains only the items that are greater than or equal
to X
with respect to the same ordering.

6. State the insertion rule.


If the element to be inserted is less than the root node follow the left path
otherwise follow the right path and insert the element.

7. Define the term spanning forest as it is associated with a digraph.


The depth first search (DFS) decomposes the graph into a set of trees with
cross
arcs connecting various nodes on different trees within this set. The set of trees is
called
depth first spanning forest.

8. What is a spanning tree?


A spanning tree of a graph is an undirected tree consisting of only those
edges
necessary to connect all the nodes in the original graph.
9.What is 2-3 tree?
A 2-3 tree is defined as a tree in which all non-terminal nodes have either
2 or 3 children and all leaf nodes have the same path length from the root node.
Only leaf contains values and non leaf indicate the path taken to the leaf.

10.What is height balanced tree?


It is a balanced tree with all the nodes have a balance factor of +1 (Left
Heavy), 0 (Balanced), -1 (Right Heavy)

11.What is weight balanced tree?


It is a balanced tree where each node has a information field which
contains the name of the node and the number of times the node has been visited.

12.What is Height balanced tree (AVL tree)?


Ans: It is binary search tree with the property that each node should have a balance
factor. The balance factor is the difference between the height of the nodes left
subtree and right subtree.

13.What is rotation in height balanced tree?


Ans: Rotation is the conversion of one tree to other. A rotation involves a few pointer
changes and changes the structure of the tree while preserving the search tree
property. There are four types of rotation:
1. Left of Left
2. Right of Right.
3. Right of Left
4. Left of Right.

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.

15.What is red black tree?


Ans: A tree is red black tree iff:
1. The root should be black in color.
2. No red node has a red child.
3. The black length of all external paths from a node u is the same; this value is
called the black height of u.
16.Define weighted tree.

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.

17. Define forest.

Collection of sub trees that are obtained when root node is eliminated is known
as forest

18.Define black depth convention in red black tree.


Ans: In black depth convection the red black tree is drawn in such a way that all the
red nodes are on the same level as their parents.

19.Define Cluster and critical cluster.


Ans: Cluster It is a set of internal nodes consisting of a black node and all the red
nodes that can be reached from the black node by following only non black edges.
Critical Cluster: If any node in a cluster is reached by a path of length greater than
one from the root of the cluster, the cluster is called critical cluster.

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.

22.What are called as internal nodes and external nodes?

In a binary decision tree,


→ circular nodes are called as internal nodes.
→ square nodes are called as external nodes.
Example:

23. Give the relationship between E, I, As (n) and Au (n)?

The relationship between E, I, As (n) and Au (n) are:


As (n)= 1+I/n
Au (n) =E/(n+1)
As (n)=(1+1/n) Au (n)-1
where As (n) be the average number of comparisons in an successful search. Au (n) is the
average number of comparisons in an unsuccessful search.

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.

2. What is internal sorting?


Internal Sorting is a method of retaining all the data to be stored in
primary memory

3. What is external sorting?


It is defined as the movement of data from secondary to primary in larger
blocks.

4. What are the objectives of sorting technique?


• Reduce the wholesale data movement
• Move data from secondary to primary in larger blocks
• If possible, retain all the data in main memory

5. What is the idea behind selection sorting?


It is called as Exchange Sort.
i. Begin with first record in the table
ii. Search is performed to locate the smallest element, interchange it
with first record.

6. What is the idea behind Bubble sorting?


Instead of finding the smallest record and then interchange, Bubble sort
interchange two records immediately upon discovering that they are out of order.

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.

8. What is Linear search?


Linear search scan each entry in the table in a sequential manner until the
desired record is found. Efficiency: O(n)

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.

11. What is response time in terms of hashing?


The response time to insert or fetch a particular entry is the sum of the
times taken to evaluate the hashing function and to perform the indicated
operation.

12. Define trie structure.


A trie structure is a complete m-ary tree in which each node consists of m
components. These components correspond to letters and digits. It occurs
frequently in the area of information, organization and retrieval

13. What are the various methods to build a hashing function?


• Division method
• Mid-square method
• Folding Method
• Digit analysis
• Length dependent method

14. What are the two classes of collision resolution techniques?


• Open addressing
• Chaining

15. What is a critical node?


The node in the height balanced tree which makes the tree unbalanced,
while performing insertion or deletion is called as a critical node

16. What is the idea behind external sorting?


The basic idea is to begin by sorting small batches of records from a file in
internal memory. This batches are called run lists or initial runs or initial strings.

17. What is tape sorting?


Sorting done on magnetic tape is called as Tape sorting. The process of
sorting involves a significant amount of record-at-a-time retrieval and
comparison.

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:

* Best case= θ(log n)


* Average case= θ(log n)
* Worst case= θ(log n)

22.What is merge sort and give it’s time complexity?

In merge sort, the elements are to be sorted in non-decreasing order. Given a

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

‘n’elements. The time complexity is O (nlogn) for worst case.

23.Mention the draw back of merge sort?

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.

24.How quick sort is better than merge sort?


In quick sort, the division of sub arrays is made so that the sorted sub arrays do
not need to be merged later. This is accomplished by rearranging the elements a [1:n]
such that a[i]≤a[j] for all I between 1 and m all j between m+1 and n for some m,
1≤m≤n.Thus the elements in a[1:m] and a[m+1:n] can be independently sorted. No merge
is needed.

25. Give the performance measurement of quick sort’s merge sort?


Both merge sort and quick sort uses recursive version, but quick sort is faster
than merge sort. Even though both algorithms requires O(nlogn) time on the average,
quick sort usually performs well in practice.
How searching is performed in an ordered array?
Ans: Searching in ordered array can be performed by the following methods:
1. Linear search
2. Binary Search
Linear search has W(n)=n
Binary search has W(n)= lg(n+1) . Binary search is better than linear search
because the number of comparisons is reduced in binary search.

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.

28. Write down the algorithm for linear search.


Ans: int search(E,n,K)
int ans,I ;
for(I=0;I<n;I++)
if(k==E[I])
ans=I;
break;
return ans;

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

1. What is directed edge and undirected edge?


Ans: The edge, which is directed from one node to another, is called directed edge
i.e.’ one – way’ and the edge that has no specific direction is called undirected edge
i.e. ’two-way’.

2. Define directed graph and undirected graph.


Ans: The graph in which the edges are directed, it is called directed graph and the
graph in which the edges are undirected it is called undirected.

Undirected graph Directed graph


3. Define mixed graph.
Ans: The graph that has both directed and undirected graph is called mixed graph.
4. Define loop.
Ans: An edge in a graph, which joins a node to itself, is called loop. It can be
considered as both directed and undirected.
5. Define multi edge (parallel).
Ans: In either directed or undirected, we may have nodes that are connected to more
than one edge; such edges are called multi edge (parallel).

6. Define multigraph and simple graph.


Ans: A graph is called a multigraph , when it ha some multi edges(parallel)
A graph is called a simple graph , when its nodes are not connected by more than one
edge.

7. Define weighted graph.


Ans: A graph is called weighted if weights are assigned to every edge . It is denoted
as triple G=(V,E,W) Where V- Set of Vertices, E- Set of Edges and W- Weights
assigned.
7

19 5

8. What do you mean by isolated node and null graph?


Ans: The graph, which contains node that is not adjacent to any other node is called
isolated node. The graph, which has only isolated node is called null graph.

9. What do you mean by time space tradeoff?


Ans: Time space tradeoff is the situation in which if we try to reduce the amount of
space used then the execution time will be increased and if we try to reduce the
execution time then the space required would be increased.

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.

11.How are graphs represented?


Ans: The graphs can be represented by two techniques:
1. Adjacency matrix
2. Adjacency List

12.What are the advantages of graphs represented using matrices?


Ans: This type of method has the following advantages:
a) It is easy to store and manipulate the matrices since the graphs are
represented in terms of computers.
b) It is used to obtain paths, connected presence of edges etc.

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

15. Define Transpose graph.


Ans: The transpose graph of diagraph G is denoted as GT, is graph that results from
reversing the direction of each edge in G.

16.What do you directed acyclic graph?


Ans: The directed acyclic graph is a directed graph in which no cycles are present. It
is abbreviated as DAG. An undirected acyclic graph is called an undirected forest. If
the graph is also connected, it is a free tree, or undirected tree.

17.Define the term spanning forest as it is associated with a digraph.


The depth first search (DFS) decomposes the graph into a set of trees with
cross
arcs connecting various nodes on different trees within this set. The set of trees is
called
depth first spanning forest.

18. What is a spanning tree?


A spanning tree of a graph is an undirected tree consisting of only those
edges
necessary to connect all the nodes in the original graph.

19. How a graph is converted into a matrix?


A graph containing n nodes is represented by matrix with m rows and n
columns
and it is formed by placing 1 in the i th row and jth column of the matrix if there is an
edge
between i and j.
M [ i ] [ j ] = 0 (presence of edge )
M [ i ] [ j ] != 0 (absence of edge )

20. Define degree of a node.


For an undirected graph, the number of edges connected directly to the
node is
called the degree of a node.

21. Mention the two graph traversal methods.


The two graph traversal methods are:
Depth first search (DFS )
Breadth first search (BFS)

22. What is a PERT graph?


A PERT graph is a finite digraph with no parallel edges or cycles in which
there
is exactly 1 source node and 1 sink node. Each edge in this graph is assigned a
weight
value.

23. What is a critical path?


Critical path is the path from the source node to the sink node such that if any
activity on the path is delayed by an amount t, then the entire path is delayed by t.

24. What are the applications of graph?


Expert system
Artificial intelligence
Cybernetics
Transportation system.

25. What is a dope vector?


A dope vector contains the information that will help us to interpret the
array’s
actual data item where it is actually located. It contains Rank of the array, number
of
dimensions, total number of elements and the physical location of array in the linear
sequence.

26. What is a sparse matrix?


Sparse matrix is a matrix which contains very low percentage of non-
zero
entries.

27.Define symmetric diagraph.


Ans: A symmetric diagraph is a directed graph such that for every edge vw there is a
reverse edge wv.

28.Explain adjacency relation.


Ans: If (u, v) is a undirected edge in E (G) then we say vertices u and v are adjacent
and edge (u,v) is incident on vertices u and v.
If <u,v> is directed edge then the vertex u is adjacent to v and the vertex v is adjacent
from u.

29.Define sub graph?


Ans: A sub graph of a graph G=(V,E) is aa graph G`=(V`,E`) such that V`⊆V and
E`⊆ E.

1 2 1 2 2

3 3

Graph Subgraphs

30. Give some examples where graphs can be used.


Ans: Graphs can used in many places like:
1. It can be used for representing Airline route map
2. It can be used in representing Flowcharts etc.

UNIT – V BACKTRACKING & BRANCH AND BOUND

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.

2. Define explicit constraint.


They are rules that restrict each xi to take on values only from a give set.
They depend on the particular instance I of the problem being solved. All tuples that
satisfy the explicit constraints define a possible solution space.

3. Define implicit constraint.


They are rules that determine which of the tuples in the solution space of I
satisfy the criteria function. It describes the way in which the xi must relate to each
other.

4. Define state space tree.


The tree organization of the solution space is referred to as state space
tree.

5. Define state space of the problem.


All the paths from the root of the organization tree to all the nodes is
called as state space of the problem

6. Define answer states.


Answer states are those solution states s for which the path from the root
to s defines a tuple that is a member of the set of solutions of the problem.

7. What are static trees?


The tree organizations that are independent of the problem instance being
solved are called as static tree.

8. What are dynamic trees?


The tree organizations those are independent of the problem instance
being solved are called as static tree.

9. Define a live node.


A node which has been generated and all of whose children have not yet
been generated is called as a live node.

10. Define a E – node.


E – node (or) node being expanded. Any live node whose children are
currently being generated is called as a E – node.

11. Define a dead node.


Dead node is defined as a generated node, which is to be expanded further/
all of whose children have been generated.

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.

13. Define Branch-and-Bound method.


The term Branch-and-Bound refers to all the state space methods in which
all children of the E-node are generated before any other live node can become the E-
node.

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

15. State 8 – Queens problem.


The problem is to place eight queens on a 8 x 8 chessboard so that no two
queen “attack” that is, so that no two of them are on the same row, column or on the
diagonal.

16. State Sum of Subsets problem.


Given n distinct positive numbers usually called as weights , the problem
calls for finding all the combinations of these numbers whose sums are m.

17. State m – colorability decision problem.


Let G be a graph and m be a given positive integer. We want to discover
whether the nodes of G can be colored in such a way that no two adjacent nodes
have the same color yet only m colors are used.

18. Define chromatic number of the graph.


The m – colorability optimization problem asks for the smallest integer m
for which the graph G can be colored. This integer is referred to as the chromatic
number of the graph.

19. Define a planar graph.


A graph is said to be planar iff it can be drawn in such a way that no two
edges cross each other.

20. Define a Hamiltonian cycle.


Let G = (V, E) be a connected graph with n vertices. A Hamiltonian cycle
is a round-trip path along n edges of G that visits every vertex once and returns to its
starting position.

Das könnte Ihnen auch gefallen