Data Structure And Algorithm Quiz: Test!

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 Lethao.2c08
L
Lethao.2c08
Community Contributor
Quizzes Created: 3 | Total Attempts: 2,227
Questions: 10 | Attempts: 1,779

SettingsSettingsSettings
Data Structure And Algorithm Quiz: Test! - Quiz


Are you familiar with data structure and algorithms? This quiz can help you to test your knowledge regarding both. A data structure is a named location that can be employed to keep and arrange the information. The algorithm is a series of steps to solve a specific problem. Learning data structures and algorithms allow us to write efficient and optimized computer programs. An algorithm is a step-by-step procedure that requires a set of instructions. The quiz below lets you test your memory about these two computer terminologies.


Questions and Answers
  • 1. 

    Suppose you have a directed graph representing all the flights that an airline flies. What algorithm might be used to find the best sequence of connections from one city to another?

    • A.

      A shortest-path algorithm.

    • B.

      A minimum spanning tree algorithm.

    • C.

      Breadth first search.

    • D.

      Depth first search.

    Correct Answer
    A. A shortest-path algorithm.
    Explanation
    A shortest-path algorithm would be used to find the best sequence of connections from one city to another in a directed graph representing all the flights that an airline flies. This algorithm is designed to find the shortest path between two nodes in a graph, taking into account the weights or distances associated with each edge. By applying a shortest-path algorithm to the directed graph of flights, the algorithm can determine the sequence of connections that minimizes the total distance or time required to travel from one city to another.

    Rate this question:

  • 2. 

    Suppose cursor points to a node in a linked list (using the node definition with member functions called data and link). What Boolean expression will be true when the cursor points to the tail node of the list?

    • A.

      (cursor->link( ) == NULL)

    • B.

      (cursor->data( ) == 0.0)

    • C.

      (cursor->data( ) == NULL)

    • D.

      (cursor == NULL)

    Correct Answer
    A. (cursor->link( ) == NULL)
    Explanation
    The Boolean expression (cursor->link( ) == NULL) will be true when the cursor points to the tail node of the linked list. This is because the link member function of the cursor, when pointing to the tail node, will return NULL, indicating that there is no next node in the list.

    Rate this question:

  • 3. 

    Which of the following represents the sequence of nodes visited in a post-order traversal of the binary tree T shown below?

    • A.

      U X Z Q W Y V P

    • B.

      X Z U W Y Q V P

    • C.

      U X W Q Z Y V P

    • D.

      U Q X W P V Z Y

    Correct Answer
    C. U X W Q Z Y V P
    Explanation
    The correct answer is U X W Q Z Y V P. In a post-order traversal, the left subtree is visited first, followed by the right subtree, and finally the root node. Starting from the root node U, we visit its left child X, then its left child W, and then its left child Q. We then visit the right subtree of Q, which consists of Z and Y. Finally, we visit the right subtree of U, which consists of V and P. Therefore, the correct sequence of nodes visited in a post-order traversal of the binary tree T is U X W Q Z Y V P.

    Rate this question:

  • 4. 

    What does a run-time analysis usually count?

    • A.

      The number of arithmetic and other operations required for the program to run

    • B.

      The number of seconds plus the number of megabytes

    • C.

      The number of seconds required for the program to run

    • D.

      The number of megabytes required for the program to run

    Correct Answer
    A. The number of arithmetic and other operations required for the program to run
    Explanation
    A run-time analysis usually counts the number of arithmetic and other operations required for the program to run. This analysis helps in understanding the efficiency and performance of the program by measuring the computational complexity. By counting the number of operations, developers can identify bottlenecks and optimize the program to improve its efficiency.

    Rate this question:

  • 5. 

    Figure 2 is the array representation of a binary tree shown in Figure 1. What should be put into space "a"?

    • A.

      3

    • B.

      5

    • C.

      4

    • D.

      2

    Correct Answer
    C. 4
    Explanation
    In the given binary tree represented by Figure 2, the number 4 should be put into space "a". This is because the numbers in the array representation of a binary tree are placed in a specific order. The order in which the numbers are placed is determined by traversing the binary tree in a specific manner, such as in a pre-order, in-order, or post-order traversal. Without further information about the traversal method used, it is difficult to determine the exact position of "a" in the array. However, based on the given options, the number 4 is the only logical choice to put into space "a".

    Rate this question:

  • 6. 

    Consider the following pseudo code: declare a stack of characters while ( there are more characters in the word to read ) { read a character push the character on the stack } while ( the stack is not empty ) { write the stack's top character to the screen pop a character off the stack } What is written to the screen for the input "cartets"?

    • A.

      Ccaarrtteettss

    • B.

      Cartets

    • C.

      Serc

    • D.

      Stetrac

    Correct Answer
    D. Stetrac
    Explanation
    The given pseudo code reads each character in the word "cartets" and pushes them onto the stack. Then, it writes the top character of the stack to the screen and pops it off the stack until the stack becomes empty. Therefore, the characters are written in reverse order, resulting in "stetrac" being written to the screen.

    Rate this question:

  • 7. 

    Given a graph G in the box. What is the order of nodes visited using DFS, starting from node a

    • A.

      A b c d e f k g h i j l

    • B.

      A c b g l k h i j f e d

    • C.

      A f e d c k g b h i j l

    • D.

      A c d e f k b g h i j l

    Correct Answer
    B. A c b g l k h i j f e d
    Explanation
    The order of nodes visited using DFS, starting from node a, is as follows: a, c, b, g, l, k, h, i, j, f, e, d.

    Rate this question:

  • 8. 

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

    • A.

      Top

    • B.

      Pop

    • C.

      Is_empty

    • D.

      Push

    Correct Answer
    B. Pop
    Explanation
    The stack underflow occurs when we try to remove an element from an empty stack. In other words, if we try to perform the "pop" operation on an empty stack, it will result in a stack underflow. Therefore, the correct answer is "pop".

    Rate this question:

  • 9. 

    Which of the following is an appropriate description concerning the list and/or array structures?

    • A.

      Using a subscript for each element in an array, quick access to any element can be achieved. The array structure allows any data to be inserted or deleted simply by modifying pointers.

    • B.

      The number of operations is fixed in inserting or deleting an element in an array; it does not depend on the position of the element in the array

    • C.

      The list structure is similar to the array structure in that all data elements of the same type are sequentially lined up. In the list structure, the logical arrangement is the same as the physical arrangement.

    • D.

      The list structure allows any data to be inserted or deleted simply by modifying pointers. But, after the data was deleted, the cells that contained the data remain as garbage in memory

    Correct Answer
    D. The list structure allows any data to be inserted or deleted simply by modifying pointers. But, after the data was deleted, the cells that contained the data remain as garbage in memory
    Explanation
    The correct answer states that the list structure allows for the insertion or deletion of data by modifying pointers. However, it also mentions that after the data is deleted, the cells that contained the data remain as garbage in memory. This means that the memory occupied by the deleted data is not automatically freed up, potentially leading to memory wastage.

    Rate this question:

  • 10. 

    There are two important operations on a stack: PUSH and POP. PUSH adds the new data to the top of the stack leaving previous data below, and POP removes and returns the current top data of the stack. When the operations shown below are sequentially executed, which of the following is the correct combination of the values x and y? Here, the size of the stack is big enough to hold the entire data. “PUSH(a)” inserts the data a into the stack, and “POP(b)” removes the data b from the stack. [Operations] PUSH (5); PUSH (3); PUSH (6); PUSH (1); x = POP (  ); PUSH (7); y = POP (  ); What are the value of X and Y?

    • A.

      Answer a)

    • B.

      Answer b)

    • C.

      Answer c)

    • D.

      Answer d)

    Correct Answer
    B. Answer b)
    Explanation
    The given operations are executed sequentially. First, the values 5, 3, 6, and 1 are pushed onto the stack. Then, the value of x is obtained by popping the topmost element, which is 1. After that, the value 7 is pushed onto the stack. Finally, the value of y is obtained by popping the topmost element, which is 7. Therefore, the correct combination of x and y is 1 and 7, respectively.

    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
  • Jul 24, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • May 02, 2012
    Quiz Created by
    Lethao.2c08
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.