GATE CS Arrays, Stacks and Queues questions
Practise Arrays, Stacks and Queues questions for GATE CS. Explore official PYQs and original topic-wise quizzes, check answers and view available solutions. Free, no sign-in.
Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.
20 on this page
Consider a stack and a queue . Both of them are initially empty and have the capacity to store ten elements each. The elements , and arrive one by one, in that order. When an element arrives, it is assigned either to (pushed on ) or to (enqueued to ). Once all the five elements are stored, the output is …
A meld operation on two instances of a data structure combines them into one single instance of the same data structure. Consider the following data structures: P. Unsorted doubly linked list with pointers to the head node and tail node of the list. Q. Min-heap implemented using an array. R. Binary Search Tree. Which ONE of the following options gives the …
Consider a stack data structure into which we can PUSH and POP records. Assume that each record pushed in the stack has a positive integer key and that all keys are distinct. We wish to augment the stack data structure with an time MIN operation that returns a pointer to the record with smallest key present in the stack without deleting the …
Let and be two stacks. has capacity of elements. has capacity of elements. already has elements: , and , whereas is empty, as shown below. …
Consider a sequence of elements , and . The following operations are performed on a stack and a queue both of which are initially empty. the elements of from to in that order into . the elements of from …
What is printed by the following program? #include<stdio.h> int main (int argc, char *argv[]) { int a[3][3][3] = {{1, 2, 3, 4, 5, 6, 7, 8, 9}, {10, 11, 12, 13, 14, 15, 16, 17, 18}, {19, 20, 21, 22, 23, 24, 25, 26, 27}}; int i = 0, j = 0, k = 0; for ( i = 0; i < 3; i ++) { for ( k = 0; k < 3; k++) printf(“%d”, a[i][j][k]); printf …
Consider the queues containing four elements and containing none (shown as the in the figure). The only operations allowed on these two queues are and The minimum number of operations on required to place the elements of …
Let be an array containing integers. Let be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of elements. Which one of the following choices is correct?
Consider the following sequence of operations on an empty stack.Consider the following sequence of operations on an empty queue. …
A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown in the figure. Let denote the number of nodes in the queue. Let 'enqueue' be implemented by inserting a new node at the head, and 'dequeue' be implemented by deletion of a node from the tail. Which one of the following is the time …
A circular queue has been implemented using a singly linked list where each node consists of a value and a single pointer pointing to the next node. We maintain exactly two external pointers FRONT and REAR pointing to the front node and the rear node of the queue, respectively. Which of the following statements is/are CORRECT for such a circular queue, so …
Let denote a queue containing sixteen numbers and be an empty stack. returns the element at the head of the queue without removing it from . Similarly returns the element at the top of without removing it from . Consider the algorithm given below. while Q is not Empty do if S is Empty OR Top(S) ≤ Head …
A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. Which one of the following statements is CORRECT ( refers to the number of items in the queue) ?
What is the output of the following C code? Assume that the address of is (in decimal) and an integer requires four bytes of memory. int main () { unsigned int x [4] [3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}}; printf ("%u, %u, %u", x + 3, *(x + 3), *(x + 2) + 3); }
Consider the C program below #include <stdio.h> int *A, stkTop; int stkFunc (int opcode, int val) { static int size=0, stkTop=0; switch (opcode) { case -1: size = val; break; case 0: if (stkTop < size ) A[stkTop++]=val; break; default: if (stkTop) return A[--stkTop]; } return -1; } int main() { int B[20]; A=B; stkTop = -1; stkFunc (-1, 10); stkFunc …
A Young tableau is a array of integers increasing from left to right and from top to bottom. Any unfilled entries are marked with , and hence there cannot be any entry to the right of, or below a . The following Young tableau consists of unique entries. …
Consider the following two C code segments. and are one and two dimensional arrays of size and respectively, where . Assume that in both code segments, elements of are initialized to and each element of array is initialized to . Further assume that when stored in main …
Given that hash table with slots that stores elements, the load factor for is _________.
The result evaluating the postfix expression is
Consider the following C program segment. # include <stdio.h> int main() { char s1[7] = "1234", *p; p = s1 + 2; *p = '0'; printf("%s", s1); } What will be printed by the program?
