Data Structures Algorithms Online Quiz

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 Nilanjanad
N
Nilanjanad
Community Contributor
Quizzes Created: 1 | Total Attempts: 1,638
Questions: 41 | Attempts: 1,683

SettingsSettingsSettings
Data Structures Algorithms Online Quiz - Quiz

.


Questions and Answers
  • 1. 

    Linked lists are best suited

    • A.

      For relatively permanent collections of data

    • B.

      For the size of the structure and the data in the structure are constantly changing

    • C.

      For both of above situation

    • D.

      For none of above situation

    Correct Answer
    B. For the size of the structure and the data in the structure are constantly changing
    Explanation
    Linked lists are best suited for situations where the size of the structure and the data in the structure are constantly changing. This is because linked lists allow for efficient insertion and deletion of elements at any position in the list, without the need to shift or resize the entire structure. The dynamic nature of linked lists makes them ideal for scenarios where the collection of data is frequently modified.

    Rate this question:

  • 2. 

    The complexity of merge sort algorithm is

    • A.

      .    O(n)

    • B.

      O(log n)

    • C.

      O(n2)

    • D.

      O(n log n)

    Correct Answer
    D. O(n log n)
    Explanation
    Merge sort is a divide and conquer algorithm that works by repeatedly dividing the unsorted list into smaller sublists until each sublist contains only one element. Then, it merges the sublists back together in a sorted manner. The time complexity of merge sort is O(n log n) because the list is divided into halves logarithmically, and each division requires linear time to merge the sublists. Therefore, the overall time complexity is proportional to the number of elements in the list multiplied by the logarithm of the number of elements, resulting in O(n log n).

    Rate this question:

  • 3. 

    Which of the following data structure is not linear data structure?

    • A.

      Arrays

    • B.

      Linked lists

    • C.

      Both of above

    • D.

      None of above

    Correct Answer
    D. None of above
    Explanation
    The correct answer is "None of above". This means that both arrays and linked lists are linear data structures. Arrays store elements in contiguous memory locations, allowing for constant-time access to any element. Linked lists, on the other hand, consist of nodes that are connected through pointers, allowing for efficient insertion and deletion operations. Therefore, both arrays and linked lists are examples of linear data structures.

    Rate this question:

  • 4. 

    In a circular linked list

    • A.

      Components are all linked together in some sequential manner.

    • B.

      There is no beginning and no end.

    • C.

      Components are arranged hierarchically

    • D.

      Forward and backward traversal within the list is permitted.

    Correct Answer
    B. There is no beginning and no end.
    Explanation
    In a circular linked list, there is no beginning and no end. Unlike a regular linked list where the last element points to null, in a circular linked list the last element points back to the first element, creating a loop. This allows for continuous traversal of the list in both forward and backward directions. As a result, any component in the list can be accessed from any other component, making it a convenient data structure for certain applications.

    Rate this question:

  • 5. 

    A linear collection of data elements where the linear node is given by means of pointer is called?

    • A.

      Linked list

    • B.

      Node list

    • C.

      Primitive list

    • D.

      None

    Correct Answer
    A. Linked list
    Explanation
    A linear collection of data elements where each element is connected to the next element through pointers is called a linked list. In a linked list, each element, known as a node, contains the data and a pointer to the next node in the sequence. This allows for efficient insertion and deletion of elements at any position in the list.

    Rate this question:

  • 6. 

    Which of the following operations is performed more efficiently by doubly linked list than by singly linked list?

    • A.

      Deleting a node whose location in given

    • B.

      Searching of an unsorted list for a given item

    • C.

      Inverting a node after the node with given location

    • D.

      Traversing a list to process each node

    Correct Answer
    A. Deleting a node whose location in given
    Explanation
    A doubly linked list is more efficient than a singly linked list when it comes to deleting a node whose location is given. This is because a doubly linked list allows for easier navigation in both directions, forward and backward, as each node contains references to both the next and the previous nodes. Therefore, when the location of a node is given, deleting it in a doubly linked list can be done in constant time, O(1), by simply updating the references of the previous and next nodes. In a singly linked list, on the other hand, deleting a node with a given location requires traversing the list to find the node before the given location, resulting in a time complexity of O(n), where n is the number of nodes in the list.

    Rate this question:

  • 7. 

    In linked list each node contain minimum of two fields. One field is data field to store the data second field is?

    • A.

      Pointer to character

    • B.

      Pointer to integer

    • C.

      Pointer to node

    • D.

      Node

    Correct Answer
    C. Pointer to node
    Explanation
    In a linked list, each node contains a minimum of two fields. The first field is the data field, which is used to store the actual data. The second field is a pointer to another node, which is used to link the nodes together and create the linked structure. This pointer points to the next node in the list, allowing traversal from one node to another. Therefore, the correct answer is "Pointer to node".

    Rate this question:

  • 8. 

    Consider the following definition in c programming language struct node { int data; struct node * next; } typedef struct node NODE; NODE *ptr; Which of the following c code is used to create new node?

    • A.

      Ptr=(NODE*)malloc(sizeof(NODE));

    • B.

      Ptr=(NODE*)malloc(NODE);

    • C.

      Ptr=(NODE*)malloc(sizeof(NODE*));

    • D.

      Ptr=(NODE)malloc(sizeof(NODE));

    Correct Answer
    A. Ptr=(NODE*)malloc(sizeof(NODE));
    Explanation
    The correct answer is "ptr=(NODE*)malloc(sizeof(NODE));". This code is used to dynamically allocate memory for a new node of type NODE. The sizeof(NODE) returns the size of the NODE structure, and malloc is used to allocate memory of that size. The (NODE*) typecast is used to convert the void pointer returned by malloc to a pointer of type NODE, which is then assigned to the ptr variable.

    Rate this question:

  • 9. 

    A variant of linked list in which last node of the list points to the first node of the list is?

    • A.

      Singly linked list

    • B.

      Doubly linked list

    • C.

      Circular linked list

    • D.

      Multiply linked list

    Correct Answer
    C. Circular linked list
    Explanation
    A circular linked list is a variant of a linked list in which the last node of the list points to the first node of the list. This creates a circular structure, allowing for easy traversal from any node to any other node in the list. This type of linked list is often used in applications where continuous looping or circular operations are required, such as in a round-robin scheduling algorithm or in implementing a circular buffer.

    Rate this question:

  • 10. 

    What kind of linked list is best to answer question like “What is the item at position n?”

    • A.

      Singly linked list

    • B.

      Doubly linked list

    • C.

      Circular linked list

    • D.

      Array implementation of linked list

    Correct Answer
    D. Array implementation of linked list
    Explanation
    An array implementation of a linked list is the best kind of linked list to answer the question "What is the item at position n?" This is because an array allows for constant time access to any element by its index. In an array implementation of a linked list, each element in the array represents a node in the linked list, and the index of the array corresponds to the position of the node. Therefore, it is efficient to directly access the item at position n by simply accessing the element at index n in the array.

    Rate this question:

  • 11. 

    ......... form of access is used to add and remove nodes from a queue.

    • A.

      LIFO, Last In First Out

    • B.

      FIFO, First In First Out

    • C.

      Both a and b

    • D.

      None of these

    Correct Answer
    B. FIFO, First In First Out
    Explanation
    The correct answer is FIFO, First In First Out. This form of access is used to add and remove nodes from a queue, where the first node that is added will be the first one to be removed. This is similar to a queue in real life, where the first person who enters the line will be the first one to leave.

    Rate this question:

  • 12. 

    In liked representation of stack ....... holds the elements of the stack.

    • A.

      INFO fields

    • B.

      TOP fields

    • C.

      LINK fields

    • D.

      NULL fields

    Correct Answer
    A. INFO fields
    Explanation
    In linked representation of a stack, the INFO fields hold the elements of the stack. This means that each node in the linked list representation of the stack contains an INFO field which stores the actual data element. The INFO fields are used to store the values that are pushed onto the stack and popped off the stack when needed.

    Rate this question:

  • 13. 

    ........ form of access is used to add remove nodes from a stack.

    • A.

      . LIFO

    • B.

      FIFO

    • C.

      Both A and B

    • D.

      None of these

    Correct Answer
    A. . LIFO
    Explanation
    LIFO (Last In, First Out) is the correct answer because it accurately describes the form of access used to add and remove nodes from a stack. In a stack, the last element that is added is the first one to be removed. This follows the LIFO principle, where the most recently added item is the first one to be accessed or removed. Therefore, LIFO is the appropriate form of access for a stack.

    Rate this question:

  • 14. 

    New nodes are added to the ......... of the queue

    • A.

      . Front

    • B.

      . Back

    • C.

      Middle

    • D.

      Both A and B

    Correct Answer
    B. . Back
    Explanation
    New nodes are added to the back of the queue. This means that when a new element is inserted into the queue, it is placed at the end or the back of the queue. The front of the queue remains unchanged, and elements are removed from the front of the queue.

    Rate this question:

  • 15. 

    In the linked representation of the stack ......... behaves as the top pointer variable of stack.

    • A.

      Stop pointer

    • B.

      Begin pointer

    • C.

      . Start pointer

    • D.

      Avail pointer

    Correct Answer
    C. . Start pointer
    Explanation
    In the linked representation of the stack, the "Start pointer" behaves as the top pointer variable of the stack. The "Start pointer" is responsible for keeping track of the topmost element in the stack, indicating the position where the next element will be inserted or removed. It points to the first node or element in the stack, making it the equivalent of the top pointer in a stack data structure.

    Rate this question:

  • 16. 

    In linked representation of stack the null pointer of the last node in the list signals ..........

    • A.

      Beginning of the stack

    • B.

      Bottom of the stack

    • C.

      Middle of the stack

    • D.

      In between some value

    Correct Answer
    B. Bottom of the stack
    Explanation
    In linked representation of a stack, the null pointer of the last node in the list signals the bottom of the stack. This means that when the null pointer is encountered, it indicates that there are no more elements below it in the stack. Therefore, the correct answer is "Bottom of the stack".

    Rate this question:

  • 17. 

    What happens when you push a new node onto a stack?

    • A.

      The new node is placed at the front of the linked list

    • B.

      The new node is placed at the back of the linked list

    • C.

      The new node is placed at the middle of the linked list

    • D.

      No Changes happens

    Correct Answer
    A. The new node is placed at the front of the linked list
    Explanation
    When a new node is pushed onto a stack, it is placed at the front of the linked list. This is because a stack follows the Last-In-First-Out (LIFO) principle, meaning that the most recently added element is the first one to be removed. By placing the new node at the front of the linked list, it ensures that it will be the first node to be accessed and removed when necessary.

    Rate this question:

  • 18. 

    A queue is a .........

    • A.

      FIFO

    • B.

      . LIFO

    • C.

      FILO

    • D.

      FILO

    Correct Answer
    A. FIFO
    Explanation
    A queue is a data structure where elements are added to the back and removed from the front, following the First-In-First-Out (FIFO) principle. This means that the element that has been in the queue the longest is the first one to be removed. In other words, the elements are processed in the same order they were added. This behavior is similar to a queue of people waiting in line, where the person who arrived first is the first one to be served.

    Rate this question:

  • 19. 

    Which of the following name does not relate to stacks?

    • A.

      . FIFO lists

    • B.

      LIFO lists

    • C.

      Piles

    • D.

      Push down lists

    Correct Answer
    A. . FIFO lists
    Explanation
    FIFO (First-In-First-Out) lists do not relate to stacks because they follow a different data structure called queues. Stacks, on the other hand, follow the LIFO (Last-In-First-Out) principle, where the last element added is the first one to be removed. LIFO lists, piles, and push down lists all relate to stacks as they follow the same LIFO principle.

    Rate this question:

  • 20. 

    The retrieval of items in a stack is ........... operation.

    • A.

      . push

    • B.

      . pop

    • C.

      Retrieval

    • D.

      Access

    Correct Answer
    B. . pop
    Explanation
    The retrieval of items in a stack is performed by the pop operation. When an item is popped from a stack, it is removed from the top of the stack and returned as the result of the operation. This allows for the retrieval of the most recently added item in the stack, following the Last In First Out (LIFO) principle.

    Rate this question:

  • 21. 

    The term push and pop is related to

    • A.

      Array

    • B.

      Lists

    • C.

      . Stacks

    • D.

      Trees

    Correct Answer
    C. . Stacks
    Explanation
    The terms "push" and "pop" are commonly used in the context of stacks. In a stack data structure, elements are added or removed from the top of the stack. "Push" refers to adding an element to the top of the stack, while "pop" refers to removing the top element from the stack. Therefore, the correct answer is Stacks.

    Rate this question:

  • 22. 

    Which is the pointer associated with the stack?

    • A.

      FIRST

    • B.

      FRONT

    • C.

      TOP

    • D.

      REAR

    Correct Answer
    C. TOP
    Explanation
    The pointer associated with the stack is the "TOP" pointer. This pointer keeps track of the topmost element in the stack, allowing for easy insertion and removal of elements from the top.

    Rate this question:

  • 23. 

    The elements are removal from a stack in .......... order.

    • A.

      Reverse

    • B.

      Hierarchical

    • C.

      Alternative

    • D.

      Sequential

    Correct Answer
    A. Reverse
    Explanation
    The elements are removed from a stack in reverse order, meaning that the last element added to the stack is the first one to be removed. This follows the principle of Last-In-First-Out (LIFO), where the most recently added element is the first one to be taken out.

    Rate this question:

  • 24. 

    The insertion operation in the stack is called .........

    • A.

      Insert

    • B.

      Push

    • C.

      . pop

    • D.

      Top

    Correct Answer
    B. Push
    Explanation
    The insertion operation in the stack is called "push". This operation adds an element to the top of the stack, increasing its size by one. The push operation is used to store new data in the stack, allowing for efficient and organized data storage and retrieval.

    Rate this question:

  • 25. 

    ...... is the term used to insert an element into stack.

    • A.

      Push

    • B.

      . Pull

    • C.

      . Pop

    • D.

      Pump

    Correct Answer
    A. Push
    Explanation
    Push is the term used to insert an element into a stack. When an element is pushed onto a stack, it is added to the top of the stack, becoming the new top element. This operation increases the size of the stack by one. The push operation is essential for adding new elements to a stack and maintaining the order in which elements are accessed and removed.

    Rate this question:

  • 26. 

    Stack follows the strategy of ........

    • A.

      LIFO

    • B.

      . FIFO

    • C.

      LRU

    • D.

      RANDOM

    Correct Answer
    A. LIFO
    Explanation
    The stack follows the strategy of LIFO, which stands for "Last In, First Out". This means that the last item added to the stack is the first one to be removed. It operates like a stack of plates, where the last plate added is the first one to be taken off when needed. This strategy is commonly used in programming and data structures, where the most recently added item is often the most relevant or needs to be accessed first.

    Rate this question:

  • 27. 

    .......... is the term used to delete an element from the stack.

    • A.

      Push

    • B.

      Pull

    • C.

      Pop

    • D.

      Pump

    Correct Answer
    C. Pop
    Explanation
    The term "Pop" is used to delete an element from the stack.

    Rate this question:

  • 28. 

    Deletion operation is done using ......... in a queue.

    • A.

      Front

    • B.

      Rear

    • C.

      . top

    • D.

      List

    Correct Answer
    A. Front
    Explanation
    In a queue, the deletion operation is done using the "front" of the queue. The front of the queue refers to the element that has been in the queue for the longest time and is the next element to be removed. When an element is deleted from a queue, the front is updated to point to the next element in the queue.

    Rate this question:

  • 29. 

    A pointer variable which contains the location at the top element of the stack is called .....

    • A.

      Top

    • B.

      Last

    • C.

      Final

    • D.

      End

    Correct Answer
    A. Top
    Explanation
    A pointer variable which contains the location at the top element of the stack is called "Top".

    Rate this question:

  • 30. 

    Which of the following is an application of stack?

    • A.

      Finding factorial

    • B.

      Tower of Hanoi

    • C.

      Infix to postfix

    • D.

         all of the above

    Correct Answer
    D.    all of the above
    Explanation
    All of the given options are applications of a stack. Finding factorial can be implemented using a stack to store intermediate results. The Tower of Hanoi problem can be solved using recursion and a stack data structure. Infix to postfix conversion also involves the use of a stack to rearrange the operators and operands. Therefore, all of the options mentioned are valid applications of a stack.

    Rate this question:

  • 31. 

    A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as a ?

    • A.

      Queue

    • B.

      Stack

    • C.

      Tree

    • D.

      Linked list

    Correct Answer
    A. Queue
    Explanation
    A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as a queue. In a queue, the first element to be inserted is the first one to be deleted (First-In-First-Out or FIFO). This data structure is commonly used in scenarios where elements need to be processed in the same order they were added, such as in scheduling tasks or managing requests.

    Rate this question:

  • 32. 

    The data structure required for Breadth First Traversal on a graph is?

    • A.

      Stack

    • B.

      Array

    • C.

      Queue

    • D.

      Tree

    Correct Answer
    B. Array
    Explanation
    The correct answer is Queue. Breadth First Traversal visits all the vertices of a graph in breadth-first order, i.e., it visits all the vertices at the same level before moving to the next level. In order to achieve this, a queue data structure is used. The vertices are inserted into the queue and then visited one by one in the order they were inserted, ensuring that the vertices at the same level are visited before moving to the next level. An array is not suitable for this traversal as it does not provide the required functionality of adding and removing elements in a specific order.

    Rate this question:

  • 33. 

    Let the following circular queue can accommodate maximum six elements with the following data front = 2 rear = 4 queue = _______; L, M, N, ___, ___ What will happen after ADD O operation takes place?

    • A.

      Front = 2 rear = 5 queue = ______; L, M, N, O, ___

    • B.

      Front = 3 rear = 5 queue = L, M, N, O, ___

    • C.

      Front = 3 rear = 4 queue = ______; L, M, N, O, ___

    • D.

      Front = 2 rear = 4 queue = L, M, N, O, ___

    Correct Answer
    A. Front = 2 rear = 5 queue = ______; L, M, N, O, ___
    Explanation
    After the ADD O operation takes place, the front remains at 2 and the rear is incremented to 5. The element "O" is added to the queue, resulting in the queue becoming "L, M, N, O, ___".

    Rate this question:

  • 34. 

    A queue is a ?

    • A.

      FIFO (First In First Out) list

    • B.

      LIFO (Last In First Out) list.

    • C.

      Ordered array

    • D.

      Linear tree

    Correct Answer
    A. FIFO (First In First Out) list
    Explanation
    A queue is a FIFO (First In First Out) list because it follows the principle that the first element added to the queue will be the first one to be removed. In other words, the elements are processed in the order they were added, resembling a line of people waiting for a service. This behavior is commonly used in computer science and data structures, where queues are used to manage tasks or requests in a sequential manner.

    Rate this question:

  • 35. 

    In Breadth First Search of Graph, which of the following data structure is used?

    • A.

      Stack

    • B.

      Queue

    • C.

      Linked list

    • D.

      None

    Correct Answer
    B. Queue
    Explanation
    In Breadth First Search of a graph, a queue is used as the data structure. This is because BFS explores all the vertices of a graph in breadth-first manner, meaning it visits all the vertices at the same level before moving to the next level. A queue is ideal for this purpose as it follows the First-In-First-Out (FIFO) principle, allowing vertices to be added to the end of the queue and removed from the front, ensuring that the vertices are visited in the order they were added.

    Rate this question:

  • 36. 

    If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what order will they be removed?

    • A.

      ABCD

    • B.

      DCBA

    • C.

      DCAB

    • D.

      ABCD

    Correct Answer
    A. ABCD
    Explanation
    The elements "A", "B", "C", and "D" will be removed in the order of ABCD. This is because a queue follows the First-In-First-Out (FIFO) principle, meaning that the element that was added first will be removed first. In this case, "A" is the first element to be added, so it will be the first one to be removed, followed by "B", "C", and "D" in that order.

    Rate this question:

  • 37. 

    In linked list implementation of a queue, where does a new element be inserted?

    • A.

      At the head of link list

    • B.

      At the tail of the link list

    • C.

      At the centre position in the link list

    • D.

      None

    Correct Answer
    B. At the tail of the link list
    Explanation
    In a linked list implementation of a queue, a new element is inserted at the tail of the linked list. This is because a queue follows the FIFO (First-In-First-Out) principle, where the element that has been in the queue the longest is the first one to be removed. By inserting the new element at the tail, it ensures that it will be the last element in the queue, and will be removed after all the previously inserted elements.

    Rate this question:

  • 38. 

    In the array implementation of circular queue, which of the following operation take worst case linear time?

    • A.

      Insertion

    • B.

      Deletion

    • C.

      To empty a queue

    • D.

      None

    Correct Answer
    D. None
    Explanation
    In the array implementation of a circular queue, all operations, including insertion, deletion, and emptying the queue, can be performed in constant time, regardless of the number of elements in the queue. This is because a circular queue uses a fixed-size array and keeps track of the front and rear elements using pointers that wrap around the array. Therefore, none of the operations take worst case linear time.

    Rate this question:

  • 39. 

    In linked list implementation of queue, if only front pointer is maintained, which of the following operation take worst case linear time?

    • A.

      Insertion

    • B.

      Deletion

    • C.

      To empty a queue

    • D.

      Both a) and c)

    Correct Answer
    D. Both a) and c)
    Explanation
    In a linked list implementation of a queue, if only the front pointer is maintained, both insertion and emptying the queue take worst case linear time.
    For insertion, since only the front pointer is maintained, we would need to traverse the entire linked list to reach the end and insert the new element, resulting in a linear time complexity.
    Similarly, to empty the queue, we would need to traverse the entire linked list and remove each element one by one, resulting in a linear time complexity as well.

    Rate this question:

  • 40. 

    . 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 formula is used to manipulate the rear pointer while inserting an element in a circular queue. By adding 1 to the current value of the rear pointer and then taking the modulo operation with MAX_SIZE, it ensures that the rear pointer wraps around to the beginning of the array if it reaches the end. This allows for the circular behavior of the queue, where new elements can be inserted even if there are empty spaces at the front of the array.

    Rate this question:

  • 41. 

    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
    B. Front=(rear+1)%MAX_SIZE
    Explanation
    The condition "Front=(rear+1)%MAX_SIZE" specifies that the circular queue is full. This condition checks if the front pointer is equal to the index obtained by adding 1 to the rear pointer and then taking the modulus of the maximum size of the array. If this condition is true, it means that the next position after the rear pointer is the same as the front pointer, indicating that the circular queue is full.

    Rate this question:

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 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 12, 2015
    Quiz Created by
    Nilanjanad
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.