adplus-dvertising
frame-decoration

Question

Consider the following sequence of operations :

(i) Pointer p1 is set to point at a new heap-dynamic variable.
(ii) Pointer p2 is assigned p1’s value.
(iii) The heap dynamic variable pointed to by p1 is explicitly de-allocated, but p2 is not changed by the operation.

This situation leads to which of the following :

a.

p1 becomes a dangling pointer

b.

p2 becomes a dangling pointer

c.

Both p1 and p2 are now dangling pointers

d.

Neither p1 nor p2 is now a dangling pointer

Answer: (b).p2 becomes a dangling pointer

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Consider the following sequence of operations : (i) Pointer p1 is set to point at a new heap-dynamic variable. (ii) Pointer p2 is assigned p1’s value. (iii) The heap dynamic...

Similar Questions

Discover Related MCQs

Q. Cyclometric complexity of a flow graph G with n vertices and e edges is

Q. For a B-tree of height h and degree t, the total CPU time used to insert a node is

Q. The time complexity to build a heap with a list of n numbers is

Q. The value of postfix expression:

8 3 4 + - 3 8 2 / + * 2 $ 3+ is

Q. Consider the following statements for priority queue:

S1: It is a data structure in which the intrinsic ordering of the elements does determine the result of its basic operations.
S2: The elements of a priority queue may be complex structures that are ordered on one or several fields.

Which of the following is correct?

Q. Give as good a big-O estimate as possible for the following functions:

(nlogn+n^2)(n^3+2) and (n!+2^n)(n^3+log(n^2+ 1))

Q. In any n-element heap, the number of nodes of height h is

Q. A vertex cover of an undirected graph G(V, E) is a subset V1 ⊆ V vertices such that

Q. Suppose you want to delete the name that occurs before “Vivek” in an alphabetical listing. Which of the following data structures shall be most efficient for this operation?

Q. The postfix expression AB+CD–* can be evaluated using a

Q. The post order traversal of a binary tree is DEBFCA. Find out the preorder traversal.

Q. The number of colours required to properly colour the vertices of every planer graph is

Q. A binary search tree is a binary tree :

Q. The Inorder traversal of the tree will yield a sorted listing of elements of tree in

Q. Which of the following data structure is linear type ?

Q. To represent hierarchical relationship between elements, which data structure is suitable?

Q. Consider the following pseudo code segment :

K:=0
 for i1:= l to n
  for i2:= 1 to i1
   :
   :
   :
    for im:= 1 to im–1
     K:= K+1

The value of K after the execution of this code shall be

Q. Number of binary trees formed with 5 nodes are

Q. The following postfix expression is evaluated using a stack

823^/23* + 51* –

The top two elements of the stack after first * is evaluated

Q. Consider the following pseudo-code :

If (A > B) and (C > D) then
A = A + 1
B = B + 1
Endif

The cyclomatic complexity of the pseudo-code is