void insert(Q, x) {
push(S1, x);
}
void delete(Q) {
if (stack-empty(S2)) then {
if (stack-empty(S1)) then {
print("Q is empty");
return;
}
else while (!(stack-empty(S1))) {
x = pop(S1);
push(S2, x);
}
}
x = pop(S2);
}Related Programming & Data Structures PYQs
Consider this C code to swap two integers and these five statements: ```c void swap(int *px, int *py) { *px = *px - *py; *…
Consider the following C-function in which a[n] and b[m] are two sorted integer arrays and c[n+m] be another integer array. ```c v…
A 3-ary max heap is like a binary max heap, but instead of 2 children, nodes have 3 children. A 3-ary heap can be represented by a…
Suppose the elements 7, 2, 10 and 4 are inserted, in that order, into the valid 3-ary max heap [9, 5, 6, 8, 3, 1]. Which one of th…
An array A[1..10, 1..20] is stored in row-major order with base address 1000. If each element occupies 4 bytes of memory, what is …
If an integer array arr[10] is defined in C, what does the expression 'arr' represent when used in pointer arithmetic?
Free account benefits
Turn practice into measurable progress
Public PYQs and reference pages stay free. Sign in when you want GATEverse to remember what you studied and guide what to practise next.