Language Bar

Wednesday, December 12, 2012



Question No: 17      ( Marks: 2 )
Which process places data at the back of the queue? Answer: (page 87)
enqueue(X) Place X at the rear/back of the queue.

Question No: 18      ( Marks: 2 )
How we can delete a node with two Childs in a binary search tree using its right sub tree. Answer:- (Page 263)
The node to be deleted has either left child (sub-tree) or right child (sub-tree).In this case we bypass the node in
such a way that we find the in-order successor of this node and then link the parent of the node to be deleted to this successor node. Thus the node was deleted.

Question No: 19      ( Marks: 2 )
Why we use Reference Variables. Give one example. Answer:-     Click here for detail
C++ references allow you to create a second name for the a variable that you can use to read or modify the
original data stored in that variable.
int x;
int& foo = x;

// foo is now a reference to x so this sets x to 56 foo = 56;
std::cout << x <<std::endl;

17. Define Reference Variable, Dangling Reference & Const
In the C++ programming language, a reference is a simple reference datatype that is less powerful but safer than the pointer type inherited from C. The name C++ reference may cause confusion, as in computer science
a reference is a general concept datatype, with pointers andC++ references being specific reference datatype implementations Dangling Reference & Const
Dangling pointers and wild pointers in computer encoding are pointers that do not point to a valid object of the suitable type. These are special cases of violations of memory safety

18. What is the use of Reference Variable, Give example? 3 Marks
A reference variable is used to refer a particular object Location which resides on a garbage collectable heap.
c++ supports one more type of variable called reference variable. In addition to pointer variable and value variable of reference variable behaves similar to both vaule variable and pointer variable. Reference variable has all access that variable has.

Question No: 18 ( Marks: 2 )
How we can avoid the problem of Dangling reference
To avoid dangling reference, dont return the reference of a local variable (Transient) from a function.

No comments:

Post a Comment



comments powered by Disqus