Tuesday, November 29, 2005

Storage Management (UNIT V)

1) Define First-fit method
First-fit method is a method for choosing the free block for use, and the free list is traversed sequentially to find the first free block whose size is larger than or equal to the amount requested.


2) Define Compaction
The process of moving all the used nodes which are marked to one end of memory and all the available memory to the other end is called compaction.

3)Define Garbage collection. What are the phases in it?
Method of detecting and reclaiming free nodes is called garbage collection.
- Two phases:
- i) Marking Phase : Marks the nodes that are accessible with external pointer.
- ii) Collection Phase: Free the nodes that have not been marked.

GRAPHS (UNIT IV)

1) Define Graph.
A Graph consists of sets of nodes and a set of arcs. Each arc in a graph is specified by a pair of nodes.


2) What is a digraph?
If the pair of nodes that make up the arcs are ordered pairs, then the graph is called as a digraph.

3) Define the term incident.
A node n is incident to an arc x, if one of the two nodes in the ordered pair of nodes that constitutes x.

4) What is degree of node in a graph?
The degree of a node is the number of arcs incident to it.

5) What is indegree and outdegree?
Indegree of a node n is the number of arcs that have n as the head and the outdegree of n is the number of arcs that have n as the tail.

6) Define the term adjacent
A node n is adjacent to a node m, if there is an arc from m to n.

7) What is a weighted graph?
A graph in which there is a number associated with each arc is called as weighted graph.

8) What is cycle, cyclic graph and acyclic graph?
A path from a node to itself is called a cycle. A graph that has a cycle is called cyclic graph. The graph that do not have cycle is called acyclic graph.

9) What is capacity function?
Capacity function c(a,b), is defined as Let a, b are nodes. Adjacent(a,b) is tue , c(a,b) is the capacity of the pipe from a to b. If there is no pipe C(a,b)=0;

10) What is flow function?
The flow function f(a,b) is 0 if b is not adjacent to a, and the amount of water flowing from the pipe a to b otherwise.

11) What is a forest?
A forest may be defined as an acyclic graph in which every node has one or no predecessors.

12) What is a tree?
A tree may be defined as a forest in which only a single node called the root exists, and has no predecessors.

13) What is an ordered forest?
Any forest that consists of collection of trees that are ordered is called ordered forest.

14) What is a spanning forest?
Given a graph G, F is a spanning forest of G if
i) F is a subgraph of G containing all nodes of G
ii) F is an ordered forest containing trees t1, t2… tn
iii) Ti contains all nodes that are reachable in G from the root of Ti and are not contained in Tj for some j
must exist whenever an arc exists.

16) Define DFS and BFS.
DFS visits all nodes that are reachable from s. BFS visits all the successors of a visited node before visiting any successors of any of those successors.

17) What is a minimum spanning tree?
Minimum spanning tree is one in which the sum of the weights of the tree edges is as small as possible

Searching (UNIT III)

1) What are internal keys or embedded keys and external keys?
The key that is contained with in the record at a specific offset from the start of the record is called internal key or embedded key. The separate tables of keys that include pointers to the records are called external keys.


2) What is a primary key and secondary key?
The set of keys that is uniquely used to differentiate any two records is called primary key. The fields of a record which may not be unique is used for a particular search is called secondary key.

3) What is a search algorithm?
Search algorithm is an algorithm that accepts an argument a and tries to find a record whose key is a. It may return the entire record or a pointer to that record. If there is no match it return NULL record or NULL pointer.

4) What is search and insertion algorithm?
If the search is unsuccessful, a new record will be added to the table with the argument as key. This type of algorithm is called search algorithm.

5) What is search table or dictionary?
A table of records in which a key is used for retrieval is called search table or dictionary.

6) What are internal searches and external searches?
Searches in which the entire table is constantly in main memory are called internal searches; whereas that in which most of the table is kept in auxiliary storage is called external searches.

7) What is an ordered table?
The table in which there is a presumed relation exists among the records or their associated keys are called ordered table. The table that does not have any such specific relationship is called unordered table.

8) Write the simple procedure for sequential search.
For (i=0;i

Saturday, November 19, 2005

Sorting (UNIT III)

Two Mark Questions….

1) What is sorting?
Sorting is arranging or ordering the data in some logical order either increasing or decreasing.

2) What are the fundamental types of sorting?
i) Internal Sorting
ii) External Sorting

3) What is internal sorting?
If the data to be sorted remains in main memory and also the sorting is carried out in main memory it is called internal sorting.

4) What is external sorting?
If the data resides in auxiliary memory and is brought into main memory in blocks for sorting and then result is returned back to auxiliary memory is called external sorting.

5) What is stable sorting?
Sorting technique is said to be stable, if for all records i and j such that k[I]=k[j], if r[i] precedes r[j] in original file, r[i] precedes r[j] in sorted file also.

6) What is sorting by address?
In sorting the auxiliary table pointers may be used so that the pointers are moved instead of actual data. This reduces the time needed for sorting.

7) What are the factors to be considered while selecting a sorting method?
Three factors are:
i) Length of time for the programmer to code the sorting program.
ii) Amount of machine time necessary for running the program.
iii) Amount of space necessary for the program to execute.

8) List the names of some internal sorting methods.
i) Bubble sort
ii) Insertion sort
iii) Selection sort
iv) Shell sort
v) Quick sort
vi) Heap sort

9) Write about any one external sorting method?
Merge sort is an example of external sorting. This sorts the sub arrays and the sorted sub arrays are stored in an auxiliary table. Then the sorted sub arrays are brought in to main memory for merging and sorting.

10) What is bubble sort?
Bubble sort arranges the array of integers as x[i]<=x[j], 0<=I
This was given the name as each element bubbles to the proper position.

11) What is quick sort or partition exchange sort?
Quick sort moves the data item into the correct direction, with the following rules:
i) Select a pivot element, from the array x.
ii) Initialize the down and up as the lower bound and upper bound of array.
iii) Increment down pointer, until x[down]>a
iv) Decrement up pointer, until x[up]<=a v) If up>down, interchange x[down] with x[up]
vi) If up<=down, interchange x[up] with pivot.

12) What is Pivot?
The element around which a file is partitioned is called a pivot.

13) What are the different methods for choosing a pivot?
i) The median of the first, last and middle elements of the sub file to be sorted can be chosen as pivot.
ii) The mean sort uses the mean of the sub file as pivot for sorting.
iii) Bsort uses the middle element of subfile as pivot.

14) What is selection sort?
Selection sort is one in which successive elements are sorted in order and placed into their proper sorted position.

15) What is straight selection sort or push down sort?
Straight selection sort is an in-place sort, from which the largest element should be chosen and interchanged with the element at end.

16) What is binary tree sort?
In binary tree sort, a binary tree of descending priority queue is created first and inorder traversing of the tree gives a sorted list.

17) What is Heap sort?
Heap sort is also an in-place sort, which creates a binary search tree in which elements are to be sorted and stored.

18) What is descending heap/Max heap/Descending partially ordered queue?
Descending heap of size n is an almost complete binary tree of nodes such that the content of each node is less than or equal to the content of its father.

19) What is Ascending heap/Min heap?
Min heap is an almost complete binary tree such that the content of each node is greater than or equal to the content of its father.

20) What is the inequality/ condition for sequential representation of heap?
Info[j]<=info[(j-1)/2] for 0<=((j-1)/2)

Other Questions…


1) What is sorting and explain the various sorting methods.
2) Discuss about the efficiency considerations while selecting a sorting algorithm
3) What are the types of Exchange sorts. Explain algorithms with examples.
4) Explain bubble sort with example.
5) Explain Quick sort with example and their efficiency considerations.
6) What are the various ways of choosing a pivot in quick sort?
7) What is selection sort and write the general selection sort algorithm.
8) What is straight selection sort/ Push down sort?
9) Explain Binary tree sorts.
10) Explain with example- How sorting is performed in a heap with descending heap?
11) Write about simple insertion sort.
12) What is shell sort / Diminishing increment sort? Explain with example.
13) What is address calculation sort / Sorting by hasing?
14) Explain the external sorting methods.
15) Briefly explain about any four internal sorting methods.
16) Explain merge sort with example.
17) Explain Cook-Kim algorithm and what are the advantages of it?
18) Explain Radix sort / Radix exchange sort with example.


Works for You…

1) What is a sort decision tree?
2) What is sort by counting?
3) What is distribution sort?
4) What is odd-even transposition sort?
5) What is quadratic selection sort?
6) What is a tournament?
7) What is a almost complete ternary tree?
8) What is a ternary heap?
9) What is two way insertion sort?
10) What is merge insertion sort?
11) Sort the following list of numbers with the sorting methods mentioned with all steps in clear.
96 23 65 8 28 15 67 32
i) Bubble sort
ii) Quick sort
iii) Selection sort
iv) Heap sort
v) Simple insertion sort
vi) Shell sort
vii) Address calculation sort
viii) Merge sort
ix) Radix sort



Monday, November 14, 2005

TREES... (UNIT II)

Two Mark Questions…

1) Define Binary Tree
Binary tree is a finite set of elements that is either empty or is partitioned into three disjoint subsets- The root, left subtree and right subtree.


2) What is a father node, and left and right sons?
If A is the root of a binary tree and B is the root of its left or right subtree, then A is said to be the father of B and B is said to be the left or right son of A.

3) What is a leaf node?
The node that do not have any sons is called leaf node.

4) Define the term ancestor.
Node n1 is said to be the ancestor of node n2, if n1 is either the father of n2 or father of some ancestor of n2.

5) Define the term descendent.
Node n2 is said to be the descendant of node n1, if n2 is either the left or right son of node n1 or son of some descendant of n1.

6) Define the term left descendant
A node n2 is the left descendant of node n1, if n2 is either the left son of n1 or a descendant of the left son of n1.

7) Define the term right descendant.
A node n2 is the right descendant of node n1, if n2 is either the right son of n1 or a descendant of the right son of n1.

8) Define the term brothers.
Two nodes are brothers if they are the left and right sons of the same father.

9) What is a strictly binary tree?
The binary tree in which every nonleaf node has nonempty left and right subtrees, is called a strictly binary tree. (Include a diagrammatic example)

10) Define level of a binary tree.
The level of a binary tree is defined as, The root of the tree has level 0, and the level of any other node in the tree is one more than the level of its father.

11) Define Depth.
The depth of a binary tree is the maximum level of any leaf in the tree. This is same as the length of the longest path from the root to any leaf.

12) What is a complete binary tree.
A complete binary tree of depth d is the strictly binary tree all of whose leaves are at level d.

13) What si a almost complete binary tree?
A binary tree of depth d is an almost complete binary tree if:
i) Each leaf in the tree is either at level d or level d-1.
ii) For any node nd in the tree with the right descendant at level d, all the left descendants that are leaves should also be at level d.

14) How almost complete binary tree nodes can be numbered?
The nodes in almost complete binary tree are numbered so that, the root is assigned the number 1, and the left son is assigned a number twice that of its father, and the right son is one more than twice the number assigned to its father. (give example diagram)

15) What are the basic operations on a binary tree?
Let p be a pointer to a node and x be the information. Now, the basic operations are:
i) info(p)
ii) father(p)
iii) left(p)
iv) right(p)
v) brother(p)
vi) isleft(p)
vii) isright(p)
viii) maketree(x)
ix) setleft(p,x)
x) setright(p,x)

16) What is traversal. What are the types of traversal?
Traversal means visiting of nodes. There are three types of traversal
i) Preorder (depth-first order)
ii) Postorder
iii) Inorder (symmetric order)

17) Explain the steps for Depth-first order traversal.
Visit the root
Traverse the left subtree
Traverse the right subtree.

18) Explain the steps for Symmetric order traversal.
Traverse the left subtree
Visit the root
Traverse the right subtree.

19) Explain the steps for postorder traversal.
Traverse the left subtree
Traverse the right subtree.
Visit the root

20) What is a binary search tree.
A binary tree in which all the elements in the left subtree of a node n are less than the contents of n, and all the elements in the right subtree of n are greater than or equal to the contents of n is called a binary search tree.

21) What are internal nodes and external nodes?
The non leaf nodes are called internal nodes where as leaf nodes are called external nodes.

22) What are the methods to indicate the non existent nodes in a binary tree, when a sequential representation is made?
One way is to use negative numbers as null indicators in a positive binary tree.
Another way is to use a used field to indicate whether the node is in use or not.

23) How can you say recursive procedure is efficient than non recursive?
There is no extra recursion
The automatic stacking and unstacking make it more efficient
There is no extraneous parameters ans local variables used.

24) What is a thread?
Thread is a pointer from the right field of leaf node to its inorder successor.

25) What is a right-in-threaded binary tree?
The right field of each leaf node other than the right most leaf node, if it has pointer to the next inorder successor, we call it as a right in-threaded binary tree.

26) What is a left in-threaded binary tree?
A left in-threaded binary tree is one in which each NULL left pointer is altered to contain a thread to that node’s inorder predecessor.

27) Define left and right pre-threaded binary tress.
Left and right prethreaded binary trees can be defined as the binary trees in which th null pointers of the nodes are replaced by their preorder succcessors and predecessors.

28) What are Heterogeneous binary trees?
Heterogeneous binary trees are the binary trees whose nodes may contain different data types. (eg: Binary tree representation of expressions- Draw a diagram)

29) What are \Huffman trees?
Huffman trees are the trees which are generated with the frequency of each alphabet for encoding a message in bit string format.

30) What is a tree?
A tree is a finite nonempty set of elements in which one element is called the root and the remaining elements are partitioned into m>=0 disjoint subsets, each of which is itself a tree. Each element in a tree is called node.

31) What is a ordered tree?
A ordered tree is defined as a tree in which the subtrees of each node form an ordered set.The first son of the ordered tree is the oldest son of that node, and the last son as youngest.

32) Define the term forest.
Forest is an ordered set of ordered trees.

Other questions:
1) Write the algorithm for creating a binary search tree, which eliminate duplicates.
2) What is the advantage of linear array representation of binary tree over dynamic node representation?
3) What is the advantage of dynamic node representation of binary tree over linear array representation ?
4) Write the procedure for maketree(x).
5) Write the procedure for setleft(p,x).
6) Write the procedure for setright(p,x).
7) What are the disadvantage of using the same representation for leaf nodes and non leaf nodes? How could they be rectified?
8) Write the procedure for sequential representation of a binary tree.
9) Write the recursive procedure for inorder, postorder and preorder traversals of binary tree.
10) Write the non recursive procedure for inorder traversal in a binary tree.
11) Write the procedure for traversing the right in-threaded binary tree.
12) Explain Huffman algorithm in Detail (16)
13) Write the procedure for finding the Kth element in a Binary tree representation of List.
14) Write the procedure for deleting an element in a Binary tree representation of List.
15) What are the application of trees?

Works for you….
1) If there are m nodes in a binary tree at level l, then there can be atmost 2m nodes at level l+1. Is this statement true or false. State the reason.
2) Derive the equation to find the total number of nodes in a complete binary tree.
3) If the total number of nodes in a complete binary tree is 15, what is the depth of the binary tree?
4) If the depth of a complete binary tree is 9, what is the totall number of nodes in it?
5) Only one almost complete binary tree can be drawn with n nodes. Is this statement true or false. If false, give two alternate representations for an almost complete binary tree with 10 nodes.
6) Create a binary search tree for the following list of numbers.
13, 12, 56, 8, 4 ,78, 7, 2, 9, 34, 22
7) Create a binary search tree for the following list of numbers and write the inorder, postorder and preorder traversal results.
15,9,18,5,4,17,14,6,7,21,33
8) Represent the expression (A+B*C)$((A+B)*C) using binary tree and write the inorder, postorder and preorder traversal results.