Programming and data structure miscellaneous
- Aliasing in the context of programming languages refers to
-
View Hint View Answer Discuss in Forum
Aliasing describes a situation in which a data location in memory can be accessed through different symbolic names in the program. Thus, modifying the data through one name implicitly modifies the values associated to all aliased names, which may not be expected by the programmer. As a result, aliasing makes it particularly difficult to understand, analyze and optimize programs. Thus, multiple variables having same memory location.
Correct Option: A
Aliasing describes a situation in which a data location in memory can be accessed through different symbolic names in the program. Thus, modifying the data through one name implicitly modifies the values associated to all aliased names, which may not be expected by the programmer. As a result, aliasing makes it particularly difficult to understand, analyze and optimize programs. Thus, multiple variables having same memory location.
- The most appropriate matching for the following pairs is
X. depth first search 1. heap Y. breadth-first search 2. queue Z. sorting 3. stack
-
View Hint View Answer Discuss in Forum
X. depth first search is done in stack.
Y. breadth first search is done in queue
Z. sorting is done in a heap.Correct Option: C
X. depth first search is done in stack.
Y. breadth first search is done in queue
Z. sorting is done in a heap.
- The most approximate matching for the following pairs
X. m = malloc (5); m = NULL; 1. using dangling pointers Y. free (n); n- > value = 5; 2. using uninitialized pointers Z. char *p; *p = ‘a’; 3. lost memory
is
-
View Hint View Answer Discuss in Forum
X - A pointer is assigned to NULL without freeing memory so a clear example of memory leak. Y - Trying to retrieve value after freeing it so dangling pointer. Z - Using uninitialized pointers.
Correct Option: D
X - A pointer is assigned to NULL without freeing memory so a clear example of memory leak. Y - Trying to retrieve value after freeing it so dangling pointer. Z - Using uninitialized pointers.
- The process of assigning load addresses to the various parts of the program and adjusting the code and date in the program to reflect the assigned addresses is called
-
View Hint View Answer Discuss in Forum
The process of assigning load addresses to the various parts of the program and adjusting the code and date in the program to reflect the assigned addresses is called relocation. Suppose any default location say x is added to all the addresses in the code leading to correct references. So, it is assembler whose output must distinguish those portions of the instructions and addresses that are relocatable.
Correct Option: C
The process of assigning load addresses to the various parts of the program and adjusting the code and date in the program to reflect the assigned addresses is called relocation. Suppose any default location say x is added to all the addresses in the code leading to correct references. So, it is assembler whose output must distinguish those portions of the instructions and addresses that are relocatable.
- Consider the following program :
Program P2
var n : int :
procedure W (var x:int)
begin
x = x + 1;
print x;
end procedure D
begin
varn:int;
n = 3;
W (n);
End
begin || begin P2
n = 10;
D;
end
If the language has dynamic scopping and parameters are passed by reference, what will be printed by the program?
-
View Hint View Answer Discuss in Forum
n = 10 given but not passed to D. In D, n = 3 &W(n) increments by 1. So n = n + 1 = 4.
Hence (d) is correct option.Correct Option: D
n = 10 given but not passed to D. In D, n = 3 &W(n) increments by 1. So n = n + 1 = 4.
Hence (d) is correct option.