Question 4.
A. interpreter,parser,reverse polish,bracting
B. isEmpty,peek,push,pop,clear
C. 7 5 6 * + 8 / 2 *
D. class Node {
int data;
Node next;
Node(int value){
[Link] = value;
[Link] = null;
}
}
Node head = null;
public void push(int elem){
Node elemt = new Node(elem);
[Link] = head;
head =elemt;
}
----------------------------------------------------------------------------------
question 5.
A. The array positions A[0], A[1],…, A[n] form a heap if each parent is greater or equal to its children
B. X
C.
-------------------------------------------------------------------------------------------------------------
question 5
c)
A) is a fixed-size array that wraps around when you reach the end.
B) No need to shift elements on insert/delete
C) public int dequeue(){
if (isEmpty()) {
[Link]("the queue is empty");
[Link](-1);
}
int to_delete = arr[front];
front = (front+1)%capacity;
count--;
return to_delete;
}
D) public void clear () {
for (int i = 0; i < [Link]; i++)
elems[i] = null;
front = rear = length = 0;
}