Ds Quiz 4 Cse D

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Ashishjn.mecs1
A
Ashishjn.mecs1
Community Contributor
Quizzes Created: 1 | Total Attempts: 159
Questions: 10 | Attempts: 159

SettingsSettingsSettings
Ds Quiz 4 Cse D - Quiz

There is no negative marking


Questions and Answers
  • 1. 

    Suppose a circular queue of capacity n elements is implemented with an array of n elements. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = -1. The conditions to detect queue full and queue empty are:

    • A.

      Full: (REAR+1) mod n = = FRONT, empty: (FRONT+1) mod n == REAR

    • B.

      Full: REAR == FRONT, empty: (REAR+1) mod n = = FRONT

    • C.

      Full: (FRONT+1) mod n = = REAR, empty: FRONT= =REAR=-1

    • D.

      Full: (REAR+1) mod n = = FRONT, empty: REAR = = FRONT= -1

    Correct Answer
    D. Full: (REAR+1) mod n = = FRONT, empty: REAR = = FRONT= -1
    Explanation
    The correct answer is Full: (REAR+1) mod n = = FRONT, empty: REAR = = FRONT= -1. This answer correctly represents the conditions to detect a full and empty queue in a circular queue implemented with an array. The condition for a full queue is when the next position after REAR is equal to FRONT, and the condition for an empty queue is when both REAR and FRONT are equal to -1.

    Rate this question:

  • 2. 

    The initial configuration of a queue is a, b, c, d, e ('a' is in the front end). To get the configuration e, d, c, b, a, one needs a minimum of :

    • A.

      3 deletion and 4 additions

    • B.

      4 deletion and 3 additions

    • C.

      4 deletion and 5 additions

    • D.

      None

    Correct Answer
    D. None
  • 3. 

    Which of the following is a collection of items into which items can be inserted arbitrarily and from which only the smallest item can be removed?

    • A.

      FIFO queue

    • B.

      Deque

    • C.

      Decreasing order priority queue

    • D.

      Increasing order priority queue

    Correct Answer
    D. Increasing order priority queue
    Explanation
    An increasing order priority queue is a collection of items where items can be inserted arbitrarily, but only the smallest item can be removed. This means that when inserting items into the priority queue, they are arranged in increasing order based on their priority. The item with the highest priority (smallest value) will always be at the front of the queue and can be removed. Other items can only be removed once they reach the front of the queue and become the smallest item.

    Rate this question:

  • 4. 

    If the MAX_SIZE is the size of the array used in the implementation of circular queue. How is rear manipulated while inserting an element in the queue? 

    • A.

      Rear=(Rear%1)+MAX_SIZE

    • B.

      Rear=Rear%(MAX_SIZE+1)

    • C.

      Rear=(Rear+1)%MAX_SIZE

    • D.

      Rear=Rear+(1%MAX_SIZE)

    Correct Answer
    C. Rear=(Rear+1)%MAX_SIZE
    Explanation
    The correct answer is Rear=(Rear+1)%MAX_SIZE. This is because when inserting an element in a circular queue, the rear pointer needs to be incremented to point to the next available position in the queue. However, if the rear pointer reaches the end of the array (MAX_SIZE), it needs to wrap around to the beginning of the array. The expression (Rear+1)%MAX_SIZE achieves this by incrementing the rear pointer by 1 and then taking the modulus of MAX_SIZE to ensure it stays within the bounds of the array.

    Rate this question:

  • 5. 

    Which representation of priority queue is more time and more space efficient, respectively. 

    • A.

      Ordinary Array for Each Priority and Linked List

    • B.

      Linked List and Ordinary Array for Each Priority

    • C.

      Circular Array for Each Priority and Linked List

    • D.

      Linked List and Circular Array for Each Priority

    Correct Answer
    C. Circular Array for Each Priority and Linked List
    Explanation
    A circular array for each priority and linked list is more time efficient because it allows for constant time access to the highest priority element in the queue. The circular array ensures that the elements with the highest priority are always at the front of the queue, making it easy to retrieve them. On the other hand, using a linked list for each priority allows for efficient insertion and removal of elements, which makes it more space efficient. This is because the linked list only requires memory for the elements that are actually in the queue, whereas the circular array needs memory for the maximum possible number of elements.

    Rate this question:

  • 6. 

    If the MAX_SIZE is the size of the array used in the implementation of circular queue, array index start with 0, Front point to the first element in the queue, and Rear point to the last element in the queue. Which of the following condition specify that circular queue is FULL? 

    • A.

      Front=Rear= -1

    • B.

      Front=(Rear+1)%MAX_SIZE

    • C.

      Rear=Front+1

    • D.

      Rear=(Front+1)%MAX_SIZE

    Correct Answer
    C. Rear=Front+1
  • 7. 

    In linked list implementation of a queue, front and rear pointers are tracked. Which of these pointers will change during an insertion into a NONEMPTY queue?

    • A.

      Only front pointer

    • B.

      Only rear pointer

    • C.

      Both front and rear pointer

    • D.

      None of the front and rear pointer

    Correct Answer
    B. Only rear pointer
    Explanation
    In a linked list implementation of a queue, the front pointer always points to the first element in the queue, while the rear pointer points to the last element. During an insertion into a nonempty queue, only the rear pointer will change because a new element is added to the end of the queue. The front pointer remains unchanged as it still points to the first element in the queue.

    Rate this question:

  • 8. 

    Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are:isEmpty(Q) – returns true if the queue is empty, false otherwise.delete(Q) – deletes the element at the front of the queue and returns its value.insert(Q, i) – inserts the integer i at the rear of the queue.Consider the following function:void f(queue Q){int i;if(!isEmpty (Q)) {i = delete(Q);f(Q)insert(Q, i);}}What operation is performed by the above function f? 

    • A.

      Leaves the queue Q unchanged

    • B.

      Reverse the order of elements in the queue Q

    • C.

      Deletes the element at the front of the queue Q and inserts it at the rear keeping the other elements in the same order

    • D.

      Empties the queue Q

    Correct Answer
    B. Reverse the order of elements in the queue Q
    Explanation
    The given function f recursively deletes the element at the front of the queue Q and inserts it at the rear, effectively reversing the order of elements in the queue. This is because the function first deletes the front element and stores it in variable i, then calls itself recursively on the remaining queue, and finally inserts the stored element i at the rear of the queue. This process is repeated until the queue becomes empty, resulting in the reversal of elements in the queue.

    Rate this question:

  • 9. 

    Suppose a circular queue of capacity 10 elements is implemented with an array of dimension 10. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables, respectively. Initially, FRONT = 1 and REAR = 5  ABCDE    What will be position of FRONT and REAR, after performing the following operations on the queue?ADD F, DELETE TWO LETTERS, ADD G, ADD H, DELETE FOUR LETTERS, ADD I 

    • A.

      FRONT = 8 and REAR = 0

    • B.

      FRONT = 8 and REAR = 1

    • C.

      FRONT = 7 and REAR = 0

    • D.

      FRONT = 7 and REAR = 9

    Correct Answer
    D. FRONT = 7 and REAR = 9
    Explanation
    After performing the given operations on the circular queue, the position of FRONT will be 7 and the position of REAR will be 9. This is because the initial positions of FRONT and REAR were 1 and 5 respectively. The operations ADD F and DELETE TWO LETTERS do not change the positions of FRONT and REAR. Then, ADD G and ADD H increment the REAR position by 1 each time. DELETE FOUR LETTERS decreases the REAR position by 4. Finally, ADD I increments the REAR position by 1. Thus, the final positions of FRONT and REAR are 7 and 9 respectively.

    Rate this question:

  • 10. 

    Consider a dequeue of capacity 10 elements is implemented with an array of dimension 10. The insertion and deletion operation can be carried out at either of LEFT and RIGHT end. Initially, LEFT = 1 and RIGHT = 5.  ABCDE     What will be status of LEFT and RIGHT, after performing the following operations on the queue?Add F on the left, Add G on the right, Add H on the right, Delete two letters from the left, Add I on the right, Add J on the left, Delete two letters from left. 

    • A.

      LEFT = 1 and RIGHT = 5

    • B.

      LEFT = 2 and RIGHT = 6

    • C.

      LEFT = 0 and RIGHT = 6

    • D.

      None

    Correct Answer
    D. None

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 17, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Oct 06, 2017
    Quiz Created by
    Ashishjn.mecs1
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.