0% found this document useful (0 votes)
2 views4 pages

Questions

The document contains a series of programming-related questions and answers, focusing on data structures such as stacks, queues, and heaps. It includes code snippets for implementing a stack using linked nodes and a circular queue. Additionally, it discusses properties of heaps and methods for managing queue operations.

Uploaded by

ffppju866
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Questions

The document contains a series of programming-related questions and answers, focusing on data structures such as stacks, queues, and heaps. It includes code snippets for implementing a stack using linked nodes and a circular queue. Additionally, it discusses properties of heaps and methods for managing queue operations.

Uploaded by

ffppju866
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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;
}

You might also like