Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Questions 4 and 5 assume that variables x,p, and q are defined as follows: int x

ID: 3531775 • Letter: Q

Question

Questions 4 and 5 assume that variables x,p, and q are defined as follows: int x=10; int *p, *q; Which of the following code segments includes a deference of an uninitialized pointer? *p = x; q = p; p = NULL; q = p; p = new int; q = p; *q = 30; p = new int; *p = x; p = new int; delete p; Recall that a pointer whose value is a memory location that has been returned to free storage is called a dangling pointer? p = new int; *p = x; delete p; p = new int; q = p; delete p; p = new int; q = p; delete p; *q = 10; p = new int; delete p; p = NULL; p = new int; delete p; Consider the foloowing sequence of function calls: Insert(l0); Insert(l5); Insert(30); Remove(l0); If the data structure is a stack, what is the value that is removed? If the data structure is a queue, what is the value that is removed? If X=2 and Y=3, find the value the stack contains after the execution of the following function call segment. Where: "add", pops two numbers from the stack and pushes their sum "mult", pops two numbers from the stack and pusn their product push(x); push(y); add; push(x); push(y) add; 10 12 13 15 Given the following queue implemented as a circular array rear=l front = 4 If two characters are deleted and then one is added, what would be the values of the pointers front and rear.

Explanation / Answer

1. A 30

B 10


2. A


3. rear 2

front 0


4. A. coz u have not allocated memory to 'p'


5. D. giving NULL to 'p' thats dangling