int tob(int b, int* arr) {
int i;
for (i = 0; b > 0; i++) {
if (b % 2) arr[i] = 1;
else arr[i] = 0;
b = b / 2;
}
return i;
}
int pp(int a, int b) {
int arr[20];
int i, tot = 1, ex, len;
ex = a;
len = tob(b, arr);
for (i = 0; i < len; i++) {
if (arr[i] == 1)
tot = tot * ex;
ex = ex * ex;
}
return tot;
}Related Programming & Data Structures PYQs
The preorder traversal of a binary search tree is 15, 10, 12, 11, 20, 18, 16, 19. Which one of the following is the postorder trav…
What is the worst case time complexity of inserting n^2 elements into an AVL-tree with n elements initially?
What is the worst case time complexity of inserting n elements into an empty linked list, if the linked list needs to be maintaine…
Consider the following C program: ```c #include <stdio.h> int main() { int a[4][5] = { {1, 2, 3, 4, 5}, {6, 7…
Consider a double hashing scheme in which the primary hash function is h1(k) = k mod 23, and the secondary hash function is h2(k) …
In a balanced binary search tree with n elements, what is the worst case time complexity of reporting all elements in range [a, b]…
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.