Data Structures & AlgorithmsModerateGATE CSE
A circular queue is kept in an array of size 7. The front index is 5 and the queue currently holds 4 elements. At which index will the next element be inserted?
- A. 9
- B. 1
- C. 2
- D. 3
Correct answer: C. 2
Next free slot = (front + count) mod size = (5 + 4) mod 7 = 2.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is the postfix form of the infix expression a + b c - d / e?
- A singly linked list has 10 nodes numbered 1 to 10. Slow and fast pointers both start at node 1; the loop is while (fast != NULL &&…
- What is the maximum number of element comparisons a binary search (one three-way comparison per step) makes on a sorted array of 100…
- The sorted array [1, 1, 2, 2, 2, 3, 5, 5, 8] is de-duplicated in place by two pointers: a write index w starts at 1 and each element a[i]…
- The array [1, 2, 3, 4, 5, 6, 7, 8] is rotated left by 3 positions using three reversals: reverse the first 3 elements, reverse the…
- Keys 12, 22, 32, 13, 23 are inserted in this order into an empty hash table of size 10 using h(k) = k mod 10 and linear probing. At which…