Please wait...

Computer Science Test - 12
Result
Computer Science Test - 12
  • /

    Score
  • -

    Rank
Time Taken: -
  • Question 1/10
    5 / -1

     In which data structure insertion and deletion takes place from different end?

    Solutions

    The correct option is Queue

    CONCEPT:

    A queue is an ordered linear data structure, following the FIFO strategy.

    Insertion in a queue happens at the rear end and deletion happens at the front.

    The queue maintains the front and rear pointers to indicate the beginning and end of the queue.

    On performing an enqueue operation the rear pointer increases by 1 as shown

    enqueue(Queue, x)

    On performing a dequeue operation the front pointer increases by 1 as shown

    dequeue(Queue)

  • Question 2/10
    5 / -1

    Which of the following is an application of Deque?
    Solutions

    Correct option is All of the above

    CONCEPT:

    A queue is an ordered linear data structure, following the FIFO strategy.

    Insertion in a queue happens at the rear end and deletion happens at the front 

    BUT

    Deque or Double Ended Queue is a linear data structure where the addition and removal of element(s) can happen from any end, i.e. head/front or tail/rear.

    There is no restriction on the side from which addition/removal of elements should happen, so it can be used to implement a stack or queue in the program.

    So all the applications of Stack and Queue can be performed by Deque

     

    In the above question:

    Checking whether parenthesis is balanced in an expression, Reversing a given string are the application of stack

    Checking whether a string is a palindrome can be done using deque 

  • Question 3/10
    5 / -1

    Stacks and Queues are example of
    Solutions
    • Basic data type (Primitive Data Structure): Integer, Real, Boolean, Character; Primitive data types are also called simple data types since they cannot be further divided
    • Non- primitive data structure is divided into linear data structure and non-linear data structure

     

    1. Linear data structure: elements(data) form a sequence or a linear list.

    Examples: Arrays, Linked List, Stacks and Queues

    2. Non-Linear data structure: data are not arranged in sequence.

    Example: Trees, Graphs

  • Question 4/10
    5 / -1

    Elements “5”, “9”, “2” and “4” are placed in a queue and are deleted one at a time. In what order will they be removed?
    Solutions

    The correct option is 5924

    CONCEPT:

    A queue is an ordered linear data structure, following the FIFO strategy.

    We will add the elements using enqueue() method and the queue looks like:

    On deleting elements one by one from the front using the dequeue() method we get 5 9 2 4 as a sequence.

  • Question 5/10
    5 / -1

    Which operations will not be required if you want to implement Queue using Deque?
    Solutions

    The correct option is DELETIONREAR

    CONCEPT:

    Deque or Double Ended Queue is a linear data structure where the addition and removal of element(s) can happen from any end.

    Deque provides the following operations:

    • INSERTFRONT: This operation inserts a new element at the front of the deque. 
    • INSERTREAR: This operation inserts a new element at the rear of the deque.
    • DELETIONFRONT: This operation removes an element from the front of the deque.
    • DELETIONREAR: This operation removes one element from the rear of the deque.

     

    A queue is an ordered linear data structure, following the FIFO strategy. 

    In a queue, insertion happens at the rear end and deletion happens at the front so we only require two of the above operations 

    which are:

    • INSERTREAR: This operation inserts a new element at the rear of the deque.
    • DELETIONFRONT: This operation removes an element from the front of the deque.

     

    Hence DELETIONREAR is not a required operation/method for the implementation of a Queue.

  • Question 6/10
    5 / -1

    Consider the below-given queue

    REAR

    102

    78

    21

    95

    16

    15

    17

    FRONT

    How many dequeue operations needed to delete the smallest element from the queue?
    Solutions

    Deletion takes place at the FRONT of the queue.

    15 is the smallest element in the given queue.

    1st deque operation:

    REAR

    102

    78

    21

    95

    16

    15

    FRONT

     

    17 is deleted

    2nd deque operation:

    REAR

    102

    78

    21

    95

    16

    FRONT

     

    15 is deleted

    Therefore, the number of deque operation needed to delete 15 is 2.
  • Question 7/10
    5 / -1

    Carefully observe the below given queue

    REAR

    22

    57

    96

    68

    19

    15

    28

    FRONT

     

    How many dequeue operations needed to delete the largest element from the queue?
    Solutions

    Key Points 

    • Insertion and deletion in queues take place from the opposite ends of the list.
    • The insertion takes place at the rear of the list and the deletion takes place from the front of the list.
    • Deletion takes place at the FRONT of the queue.
       

    Analysis:-

    96 is the largest element in the given queue.

    1st deque operation:

     

    REAR

    22

    57

    96

    68

    19

    15

    FRONT

     

    28 is deleted

    2nd deque operation:

    REAR

    22

    57

    96

    68

    19

    FRONT

     

    15 is deleted

    3rd operation:

    REAR

    22

    57

    96

    68

    FRONT

     

    19 is deleted

    4th operation:

    REAR

    22

    57

    96

    FRONT

     

    68 is deleted

    5th operation:

    REAR

    22

    57

    FRONT

     

    96 is deleted

    Therefore, the number of deque operation needed to delete 96 is 5.
  • Question 8/10
    5 / -1

    Which method is used to check whether the queue has any element or not?
    Solutions

    A correct answer is an option (2)

    IS EMPTY

    Concept:-

    Before we remove an element for a queue (q) it must be checked whether the queue (q) still has some element that is to check whether the queue (q) is empty or not. If it is not empty then the dequeue (deletion) operation can be performed to remove the front element. This test is performed by comparing the value of the front with the sentinel value -1.

    Syntax:

    def isEmpty(myQueue):
     if len(myQueue)==0:
     return True
    else:
     return False

    Additional InformationQueue:- A queue is a non-primitive linear data structure. It is a homogeneous collection of elements. In which new elements are added (insertion) can take place at one end of the list is called the rear of the list and deletion can take only at the other end is called the front of the list. The behaviour of the queue is like a FIFO (First-In-First-Out).

  • Question 9/10
    5 / -1

    A queue contains elements A1, A2, A3, A4, and A5. If the stored elements are deleted one by one, what will be the order of the deletion of elements from the queue.
    Solutions

    The correct option is (4)

    A1A2A3A4A5

    Concept:-

    Queue follows the FIFO approach. i.e. First in First Out Approach. So, the order of the deletion of elements is A1A2A3A4A5.

    After deletion one by one order of deletion of elements 

    A1A2A3A4A5

    Key Points

    • Whenever an element is removed or deleted from the queue the value of front is increment by 1 that is front = front +1.
    • A queue is an abstract data type or a linear data structure in which the first element is added from one end, known as the back, and the existing element is removed from the opposite end, known as the front.

    Additional Information 

    The enqueue() is the operation for adding an element into Queue.

    The dequeue() is the operation for removing an element from Queue.

  • Question 10/10
    5 / -1

    Typical time requirement for operations on queues is:
    Solutions

    Typical time requirement for operations on queues is O(1)

    Key Points

    Insertion

    Insertion operation in a queue, a new node is added, new node points to rear pointer of the queue and the rear pointer points to new node; This operation takes a constant amount of time, Therefore, the complexity of insertion in the queue is O(1).

    Deletion

    Deletion operation in a queue, element to be deleted is a front element, address of the front pointer is stored in a temporary variable, the front pointer points to its immediate next node and location stored in a temporary variable is free; This operation takes a constant amount of time, Therefore, the complexity of insertion in a queue is O(1)

    Additional Information

    • Queue is data structure which is First in First Out (FIFO) or Last in Last Out (LILO) which means the element which is inserted first comes out first form the queue or the elements inserted last comes out last from the queue
    • Breadth First Search (BFS) algorithm traverses a graph in a breadthwise manner and uses a queue to remember to get the next vertex to start a search, when a dead end occurs in any iteration.
User Profile
-

Correct (-)

Wrong (-)

Skipped (-)


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
Get latest Exam Updates
& Study Material Alerts!
No, Thanks
Click on Allow to receive notifications
×
Open Now