Data Structure And Algorithm

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 Bmondal
B
Bmondal
Community Contributor
Quizzes Created: 2 | Total Attempts: 1,239
Questions: 20 | Attempts: 918

SettingsSettingsSettings
Data Structure And Algorithm - Quiz

Questions and Answers
  • 1. 

    The _____________ algorithm works by repeatedly scanning through the list, comparing adjacent elements, and swapping them if they are in the wrong order.

    • A.

      Bubble sort

    • B.

      Insertion Sort

    • C.

      Merge Sort

    • D.

      Selection sort

    Correct Answer
    A. Bubble sort
    Explanation
    Bubble sort is the correct answer because it is an algorithm that repeatedly scans through the list, compares adjacent elements, and swaps them if they are in the wrong order. This process is repeated until the list is sorted. Bubble sort is known for its simplicity but is not efficient for large lists.

    Rate this question:

  • 2. 

    The _____________ algorithm works by repeatedly scanning through the list, comparing adjacent elements, and swapping them if they are in the wrong order.

    • A.

      Bubble sort

    • B.

      Insertion Sort

    • C.

      Merge Sort

    • D.

      Selection sort

    Correct Answer
    A. Bubble sort
    Explanation
    Bubble sort is an algorithm that works by repeatedly scanning through the list, comparing adjacent elements, and swapping them if they are in the wrong order. This process is repeated until the list is sorted. In each pass, the largest element "bubbles" up to its correct position, hence the name "bubble sort".

    Rate this question:

  • 3. 

    A __________ is a list of elements in which items are always inserted at one end and deleted from the other end.

    • A.

      Queue

    • B.

      Linked List

    • C.

      Array

    • D.

      Stack

    Correct Answer
    A. Queue
    Explanation
    A queue is a data structure that follows the FIFO (First-In-First-Out) principle, where elements are inserted at one end called the rear and deleted from the other end called the front. This means that the first element inserted into the queue will be the first one to be removed. Therefore, a queue is the correct answer as it fits the description of a list of elements where items are always inserted at one end and deleted from the other end.

    Rate this question:

  • 4. 

    In ______________ traversal method, the root is processed before traversing the left and right subtrees.

    • A.

      Preorder

    • B.

      Inorder

    • C.

      Postorder

    • D.

      Preorder and postorder

    Correct Answer
    A. Preorder
    Explanation
    In Preorder traversal method, the root is processed before traversing the left and right subtrees. This means that the root node is visited first, followed by the traversal of the left subtree, and then the right subtree. This order of processing ensures that the root is always visited before its children, making it a pre-order traversal.

    Rate this question:

  • 5. 

    Identify the degree of a node B in the given figure.

    • A.

      1

    • B.

      2

    • C.

      3

    • D.

      0

    Correct Answer
    A. 1
    Explanation
    The degree of a node in a graph refers to the number of edges connected to that node. In the given figure, node B is connected to only one edge, which is represented by the number 1. Therefore, the degree of node B is 1.

    Rate this question:

  • 6. 

    Which of the following Big O Notations has constant order of growth?

    • A.

      O(n)

    • B.

      O(1)

    • C.

      O(n2)

    • D.

      O(log n)

    Correct Answer
    B. O(1)
    Explanation
    The Big O Notation O(1) has a constant order of growth. This means that the time complexity of the algorithm does not depend on the size of the input. It will always take the same amount of time to execute, regardless of the input size. This is because the algorithm has a fixed number of operations that it performs, and it does not increase or decrease with the input size. Therefore, O(1) represents a constant time complexity.

    Rate this question:

  • 7. 

    What is the order of growth of the bubble sort algorithm?

    • A.

      Constant

    • B.

      Linear

    • C.

      Quadratic

    • D.

      Logarithmic

    Correct Answer
    C. Quadratic
    Explanation
    The bubble sort algorithm has a quadratic order of growth. This means that as the size of the input increases, the time it takes to sort the elements using bubble sort increases quadratically. In other words, if the input size doubles, the time it takes to sort the elements will increase by a factor of four. This is because bubble sort compares and swaps adjacent elements multiple times until the entire list is sorted, resulting in a time complexity of O(n^2).

    Rate this question:

  • 8. 

    To implement __________ search algorithm, the list should be sorted.

    • A.

      Linear

    • B.

      Binary

    • C.

      Both

    • D.

      None

    Correct Answer
    B. Binary
    Explanation
    To implement the binary search algorithm, the list should be sorted. This is because the binary search algorithm works by repeatedly dividing the sorted list in half and comparing the target value with the middle element. If the list is not sorted, the algorithm will not be able to accurately determine the position of the target value, leading to incorrect results. Therefore, sorting the list is a prerequisite for successfully implementing the binary search algorithm.

    Rate this question:

  • 9. 

    Consider the algorithm to insert a node at the beginning of the link list and identify the error: 1. Assign value to the data field of the new node 2. Allocate memory for the new node 3. Make the next field of the new node point to the first node in the list. 4. Make START point to the new node.

    • A.

      There is no error

    • B.

      Step 3 to be changed as, Make the next field of the new node point to NULL.

    • C.

      The sequence is wrong, the correct sequence is 2->1->3->4

    • D.

      Step 4 to be changed as, Make the new node point to START.

    Correct Answer
    C. The sequence is wrong, the correct sequence is 2->1->3->4
    Explanation
    The given correct answer suggests that the error in the algorithm is that the sequence of the steps is incorrect. The correct sequence should be 2->1->3->4. This means that the new node should be inserted after the second node, making it the first node in the list.

    Rate this question:

  • 10. 

    Which of the following will be the postfix expression for the given infix expression:  ((C+(D*E))-F)

    • A.

      CDE*+F-

    • B.

      CDE+*F-

    • C.

      CDF*+E-

    • D.

      DCF*+E-

    Correct Answer
    A. CDE*+F-
    Explanation
    The given infix expression is ((C+(D*E))-F). To convert it to postfix, we follow the rules of postfix conversion. First, we encounter C, so we push it into the stack. Then, we encounter +, so we push it into the stack. Next, we encounter D, so we push it into the stack. After that, we encounter *, which has higher precedence than +, so we push it into the stack. Then, we encounter E and push it into the stack. Now, we encounter the closing parenthesis, so we pop all the operators from the stack until we reach the opening parenthesis and add them to the postfix expression. The next operator is -, which has lower precedence than *, so we push it into the stack. Finally, we encounter F, so we push it into the stack. We have reached the end of the expression, so we pop all the remaining operators from the stack and add them to the postfix expression. The resulting postfix expression is CDE*+F-.

    Rate this question:

  • 11. 

    What address would a node with an empty left child of a threaded binary tree store?

    • A.

      Inorder successor

    • B.

      Preorder predecessor

    • C.

      Preorder successor

    • D.

      Inorder predecessor

    Correct Answer
    D. Inorder predecessor
    Explanation
    In a threaded binary tree, a node with an empty left child would store the inorder predecessor. The inorder predecessor is the node that comes before the current node in the inorder traversal of the tree. Since the left child is empty, there is no node to the left of the current node, so the inorder predecessor is stored in the current node.

    Rate this question:

  • 12. 

    What will be the Inorder traversal of the given tree?

    • A.

      D H B E A F C I G J

    • B.

      A B D H E C F G I J

    • C.

      H D E B F I J G C A

    • D.

      A B D H E F C G J I

    Correct Answer
    A. D H B E A F C I G J
    Explanation
    The given tree's inorder traversal is D H B E A F C I G J.

    Rate this question:

  • 13. 

    Which of the following stack operations could result in stack underflow?

    • A.

      Is_empty

    • B.

      Pop

    • C.

      Push

    • D.

      Two or more of the above answers

    Correct Answer
    B. Pop
    Explanation
    The pop operation could result in a stack underflow. This is because when we try to pop an element from an empty stack, there are no elements to remove, leading to an underflow condition.

    Rate this question:

  • 14. 

    If a stack is represented in memory by using a linked list, then insertion and deletion of data will be done ___.

    • A.

      At the end of the list

    • B.

      At the beginning of the list

    • C.

      Anywhere in the list

    • D.

      At the beginning and end of the list respectively

    Correct Answer
    B. At the beginning of the list
    Explanation
    When a stack is represented in memory using a linked list, the insertion and deletion of data will be done at the beginning of the list. This is because in a linked list, adding or removing an element at the beginning is more efficient than doing it at the end. When inserting at the beginning, we simply need to update the head pointer to point to the new element, while when deleting at the beginning, we just need to update the head pointer to skip the first element. This allows for constant time complexity for both insertion and deletion operations.

    Rate this question:

  • 15. 

    If a stack is represented in memory by using an array, then what will be the stack overflow condition?

    • A.

      Top=-1

    • B.

      Top=0

    • C.

      Top=SIZE-1

    • D.

      Top=SIZE

    Correct Answer
    C. Top=SIZE-1
    Explanation
    In a stack represented in memory by using an array, the stack overflow condition occurs when the top of the stack reaches the maximum size of the array minus one (Top=SIZE-1). This means that the stack is full and there is no more space to add new elements to it. If the top of the stack exceeds this value (Top=SIZE), it would result in accessing memory beyond the array's bounds, causing a stack overflow error.

    Rate this question:

  • 16. 

    If a queue is represented in memory by using a linked list, then what will be the stack empty condition?

    • A.

      FRONT=0

    • B.

      FRONT=-1

    • C.

      FRONT=REAR

    • D.

      FRONT=NULL

    Correct Answer
    D. FRONT=NULL
    Explanation
    In a linked list representation of a queue, the front pointer points to the first element in the queue and the rear pointer points to the last element. When the queue is empty, both the front and rear pointers should be NULL, indicating that there are no elements in the queue. Therefore, the stack empty condition in this case would be FRONT=NULL.

    Rate this question:

  • 17. 

    Consider the following statement related to queue: A. The Insertion is done at REAR and deletion at FRONT end B. A queue is also known as LIFO list.

    • A.

      Statement A is true and B is False

    • B.

      Statement B is true and A is False

    • C.

      Statement A is False and B is False

    • D.

      Statement A is true and B is True

    Correct Answer
    A. Statement A is true and B is False
    Explanation
    The correct answer is that Statement A is true and B is False. This means that insertion is indeed done at the rear end of a queue, while deletion occurs at the front end. However, a queue is not known as a LIFO (Last In, First Out) list. Instead, a queue follows the FIFO (First In, First Out) principle, where the element that is inserted first is the one that will be deleted first.

    Rate this question:

  • 18. 

    In a binary search tree, all values in the left subtree of a node are ________ than the value of the node.

    • A.

      Smaller

    • B.

      Greater

    • C.

      Equal

    • D.

      Greater or Equal

    Correct Answer
    A. Smaller
    Explanation
    In a binary search tree, all values in the left subtree of a node are smaller than the value of the node. This is because binary search trees follow a specific ordering rule, where all values in the left subtree must be smaller than the parent node, and all values in the right subtree must be greater than the parent node. This allows for efficient searching and retrieval of values in the tree.

    Rate this question:

  • 19. 

    What is the tree empty condition for a Threaded Binary Tree?

    • A.

      The right child field of the header node is a thread pointing to itself

    • B.

      The left child field of the header node is NULL

    • C.

      The left child field of the header node is a thread pointing to itself

    • D.

      The root is NULL

    Correct Answer
    C. The left child field of the header node is a thread pointing to itself
    Explanation
    The tree empty condition for a Threaded Binary Tree is when the left child field of the header node is a thread pointing to itself. This means that there are no actual left child nodes in the tree, and the left child field is being used as a thread to navigate the tree. This condition indicates that the tree does not contain any elements or nodes.

    Rate this question:

  • 20. 

    Consider the algorithm of deleting a node from the beginning of a linked list and identify the error:                         1. Mark the first node in the list as current                         2. Make START point to the next node in sequence.                         3. Release the memory for the node marked as current.

    • A.

      The algorithm has no error

    • B.

      The sequence is wrong, the correct one is 3->1->2

    • C.

      The sequence is wrong, the correct one is 2->1->3

    • D.

      The sequence is wrong, the correct one is 3->2->1

    Correct Answer
    A. The algorithm has no error
    Explanation
    The given algorithm correctly deletes a node from the beginning of a linked list. It starts by marking the first node as the current node, then it updates the start pointer to point to the next node in the sequence, and finally, it releases the memory for the node marked as current. This sequence of steps ensures that the first node is properly removed from the linked list without any errors.

    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 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 21, 2012
    Quiz Created by
    Bmondal
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.