PLEASE CHECK.IMPORTANT

Monday, December 1, 2008

TECHNICAL QUESTIONS

What is the use of fflush() function?

Posted:

Suppose we read a sentence using scanf e.g. “My name is ABC” in a string. Printing this string using a printf statement prints “My”. Go for another successive scanf. It reads from the input stream… which still is having “name is ABC”. Hence pritning the string this time shows “name”. Solution to this is a fflush statement after first printf. This [...]

Explain how performance of algorithm is analysed?

Posted:

The performance of an algorithm is analysed by the time complexity as well as its space complexity though both the complexities are trafe-offs between them. If time complexity increases then space complexity decreases & vice-versa. Also the best & worst cases of the time complexities are considered while determining the efficiency of the algorithm

Is it possible to implement trees using arrays ? If yes, how?

Posted:

Yes, it is possible. Here is an example of implementing a binary tree: Consider an attay : a[n]; Place the root in first position. and let the current position to be i = 0; place left node at the position: 2i+1 place right node at the position: 2i+2. Repeat these steps.

What does abstract data type means?

Posted:

If for a particular collection of data only the structure of data and the functions to be performed on the data is defined but the implementation is not defined,then such a collection of data is called Abstrct data type.

A list is ordered from smaller to largest when a sort is called. Which sort would take the longest time to execute?

Posted:

I am not sure about the answer.But I think the answer is “Selection Sort” whose order is O(n^2) irrespective of the elements order.I guess all other sorts somehow depend on the order of elements

What is binary tree?

Posted:

A binary tree is a tree which has every node has exactly two links i.e left and right link

What are the parts of root node?

Posted:

A root node contains data part and has link part. i.e links to its child. if it is binary tree it has two links i.e left child and right child

How many different binary trees and binary search trees can be made from three nodes that contain the key values 1, 2 & 3?

Posted:

for binary search tree, no of trees, (2^n)-n… here 8-3=5 trees… u can draw n see… for binary tree, no of trees n(2^n)-n here 3*5=15… replace node in each bst with other two values and see

Stack can be described as a pointer. Explain.

Posted:

Because stack will contain a head pointer which will always point to the top of the Stack. All Stack Operations are done using Head Pointer. Hence Stack ca be Described as a Pointer

What do you mean by: Syntax Error, Logical Error, Runtime Error?

Posted:

Syntax Error-Errors in coding which do not follw language syntax format. It can occur by human mistak in typing & due lack knowledge of language .EX - Ram are a boy. error correct- Ram is a boy. Logical Error- Here is correct, program will execute properly but not give answer correct. [...]

What does abstract data type means?

Posted:

If for a particular collection of data only the structure of data and the functions to be performed on the data is defined but the implementation is not defined,then such a collection of data is called Abstrct data type.

What is the average number of comparisons in a sequential search?

Posted:

f(n)= 1.Pn + 2.Pn + 3.Pn +…+ N.Pn where Pn = 1/N f(n)= 1.1/N +2.1/N + 3.1/N+….+N.1/N = (1+2+3+….+N)1/N = N(N+1)/2N = (N+1)/2

Which one is faster? A binary search of an orderd set of elements in an array or a sequential search of the elements.

Posted:

binary search if of order log n where as sequential search is of order n binary search is faster

What is a data structure?

Posted:

Data Structure means how the data is organised in memory

How is it possible to insert different type of elements in stack?

Posted:

you ca implement stack with union datatype… u may think of structures.. but struct use storin of all values and mem allocated for all in each.. but in union only one at a time… this is right i think

Parenthesis are never needed in prefix or postfix expressions. Why?

Posted:

Basically Parenthesis indicate the operations which need to be carried out first ie according to the BODMAS rule..SO in case of postfix or prefix expression they are actualy conversions of the orginal standard equation.Where the brackets have already been taken into consideration,,,and the formed prefix/postfix expression is the correct order of expansion of a given mathematical [...]

What are the parts of root node?

Posted:

A root node contains data part and has link part. i.e links to its child. if it is binary tree it has two links i.e left child and right child

How would you sort a linked list?

Posted:

using merge sort. http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html

What is the average number of comparisons in a sequential search?

Posted:

f(n)= 1.Pn + 2.Pn + 3.Pn +…+ N.Pn where Pn = 1/N f(n)= 1.1/N +2.1/N + 3.1/N+….+N.1/N = (1+2+3+….+N)1/N = N(N+1)/2N = (N+1)/2

What do you mean by: Syntax Error, Logical Error, Runtime Error?

Posted:

Syntax Error-Errors in coding which do not follw language syntax format. It can occur by human mistak in typing & due lack knowledge of language .EX - Ram are a boy. error correct- Ram is a boy. Logical Error- Here is correct, program will execute properly but not give answer correct. EX- Table [...]

No comments: