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

Here i s incorr e ct incom p l ete code for a stack. Assume the init function is

ID: 3545746 • Letter: H

Question

Here is incorrect incomplete code for a stack. Assume the init function is correct, push never gets called on a full stack, and pop never gets called on an empty stack.

typedef struct { int items[10]; int top

} stackT;

void init(stackT* mystack} {

mystack->top = 0;

}

void push(stackT* mystack, int value} {

items[top] = value;

mystack->top += 1;

}

int pop(stackT* mystack) {

return mystack->items[mystack->top];

}

a)mystack->items[mystack->top] =value;

b) mystack->items[mystack->top] = mystack->value;

c) mystack->items[top] =value;

d) items[mystack->top] u value;

e) items[top] =value;

a) mystack->top = 1;

b) mystack->top = -1;

c) mystack->top++;

d) mystack->top--;;

e) mystack->top +=   10;


3) What is the value of the postfix expression shown below?

15 5         I    6         3       +       7     -    4    *  +

a) 8                b) 10               c) 11     d)29               e) None of the Above

4) Consider implementing a queue with a linked list, with only a pointer to the front of the queue. Which of the functions, in this implementation, would still have an 0(1) run time? (Answer with a name that is appropriate based on the convention for queue functions.)

a) recurse         b) printAll        c) enqueue       d) dequeue       e) None of the Above

Explanation / Answer

answers:

1 (a)

2 (d)

3 (b)

4 (d)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote