Toughest Data Structure Exam 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 Maheshjangid962
M
Maheshjangid962
Community Contributor
Quizzes Created: 2 | Total Attempts: 361
Questions: 66 | Attempts: 258

SettingsSettingsSettings
Toughest Data Structure Exam Quiz! - Quiz


Data structure is the specific way to store and organize information so that the data can be successfully accessed. For this quiz, you should understand what a valid list operation is, the name of the second child vertex on a binary tree, all trees' property, how many children each vertex has, etc. This quiz will thoroughly prepare you for the most challenging data structure exam.


Questions and Answers
  • 1. 

    Insert, Append, Delete, and Next are all valid list operations.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The statement mentions four list operations: Insert, Append, Delete, and Next. These are all commonly used operations in list manipulation. Insert is used to add an element at a specific position in the list, Append is used to add an element at the end of the list, Delete is used to remove an element from the list, and Next is used to move to the next element in the list. Therefore, all four operations mentioned are valid list operations.

    Rate this question:

  • 2. 

    Postfix notation may not contain negative numbers.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Postfix notation, also known as Reverse Polish Notation (RPN), is a mathematical notation in which operators are placed after their operands. In postfix notation, negative numbers are represented by using a unary minus operator before the number. Therefore, it is not possible to directly represent negative numbers in postfix notation without using the unary minus operator. Hence, the statement that postfix notation may not contain negative numbers is true.

    Rate this question:

  • 3. 

    An ordered tree in which each vertex has 0, 1, or 2 children.

    Correct Answer
    Binary Tree
    Explanation
    A binary tree is a type of ordered tree where each vertex can have at most two children. This means that each vertex can have either 0, 1, or 2 children. The term "binary" refers to the fact that each vertex can have a maximum of two children. In a binary tree, the left child is typically smaller than the parent, and the right child is typically larger. This type of tree is commonly used in computer science and data structures due to its efficient search and traversal properties.

    Rate this question:

  • 4. 

    The name of the second child of a vertex on a binary tree.

    Correct Answer
    Right Child
    Explanation
    The second child of a vertex on a binary tree is called the right child. In a binary tree, each vertex can have at most two children - a left child and a right child. The left child is the first child and the right child is the second child. Therefore, the correct answer is "Right Child".

    Rate this question:

  • 5. 

    A node connected via edges to a higher node.

    Correct Answer
    Child
    Explanation
    The term "child" refers to a node that is connected via edges to a higher node. In a hierarchical structure, such as a tree, a child node is one level below its parent node. The relationship between a parent and child node indicates that the child is subordinate or dependent on the parent. Therefore, the correct answer is "child."

    Rate this question:

  • 6. 

    If "X" is a descendent of "Y", then "Y" is a __________ of "X".

    Correct Answer
    Ancestor
    Explanation
    If "X" is a descendant of "Y", it means that "X" is a later generation or offspring of "Y". Therefore, "Y" must be an ancestor of "X", as an ancestor refers to an earlier generation or parent from which someone is descended.

    Rate this question:

  • 7. 

    All the descendents of a vertex.

    Correct Answer
    Sub Tree
    Explanation
    A subtree refers to all the descendants of a specific vertex in a tree structure. It includes the vertex itself and all its child vertices, as well as their children and so on. In other words, a subtree is a smaller tree within the larger tree, formed by selecting a particular vertex and all its descendants.

    Rate this question:

  • 8. 

    The length of the longest path from a vertex to a leaf that is a descendent of the vertex.

    • A.

      Height

    • B.

      Depth

    Correct Answer
    A. Height
    Explanation
    The length of the longest path from a vertex to a leaf that is a descendant of the vertex is referred to as the height of the vertex. The height of a vertex measures the distance from the vertex to the farthest leaf in the tree. It is important in determining the overall structure and balance of a tree.

    Rate this question:

  • 9. 

    All parents have the same depth, but not necessarily the same height.

    • A.

      True - parents

    • B.

      False - siblings

    Correct Answer
    B. False - siblings
    Explanation
    This statement is false because siblings are individuals who share at least one parent. While siblings may have the same depth (meaning they have a common ancestor), they do not necessarily have the same height, which refers to the generation level or distance from the root of the family tree. Siblings can have different heights depending on their birth order and age differences.

    Rate this question:

  • 10. 

    Property of all trees.

    • A.

      #Edges = #Nodes - 1

    • B.

      #Nodes = #Edges - 1

    Correct Answer
    A. #Edges = #Nodes - 1
    Explanation
    In a tree, the number of edges is always one less than the number of nodes. This is because a tree is a connected graph with no cycles, and every edge connects two nodes. So, if we have "n" nodes in a tree, we will have "n-1" edges.

    Rate this question:

  • 11. 

    An ordered tree in which each vertex has either no children, one child, or two children.

    • A.

      Sub Tree

    • B.

      Ordered Tree

    • C.

      Binary Tree

    Correct Answer
    C. Binary Tree
    Explanation
    A binary tree is a type of ordered tree where each vertex can have either no children, one child, or two children. This means that every vertex in a binary tree can have either zero, one, or two child vertices. Other types of ordered trees, such as a sub tree, do not have this specific restriction on the number of child vertices. Therefore, the given correct answer is binary tree.

    Rate this question:

  • 12. 

    Every vertex has two children or is a leaf.

    • A.

      Perfect Binary Tree

    • B.

      Full Binary Tree

    Correct Answer
    B. Full Binary Tree
    Explanation
    A full binary tree is a type of binary tree where every vertex has either two children or is a leaf. This means that every node in the tree has either zero or two children, and there are no nodes with only one child. Therefore, the given statement aligns with the definition of a full binary tree.

    Rate this question:

  • 13. 

    What is the In Order Traversal:give your answer like 2 3 5 6 7

    Correct Answer
    6 13 17 27 33 42 48
    Explanation
    The given sequence of numbers is already in ascending order. In an in-order traversal of a binary tree, the left subtree is visited first, followed by the root, and then the right subtree. Since the given sequence is already sorted, it can be considered as an in-order traversal of a binary tree with no left or right subtrees. Therefore, the answer is the same as the given sequence: 6 13 17 27 33 42 48.

    Rate this question:

  • 14. 

    The "best case" search time for a B.S.T. is O(n). (where n = the number of nodes in the tree)

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    ^worst case

    Rate this question:

  • 15. 

    A Red-Black tree is a BST tree.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    A Red-Black tree is a type of self-balancing binary search tree (BST). It follows the properties of a BST, where each node has a key value and its left child has a smaller key, while its right child has a larger key. Additionally, a Red-Black tree also maintains the color property, where each node is either red or black, and it satisfies the following conditions: the root is black, all leaves (null nodes) are black, and no two adjacent nodes are red. Therefore, a Red-Black tree is indeed a BST.

    Rate this question:

  • 16. 

    A BST tree is always balanced.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    AVL

    Rate this question:

  • 17. 

    All AVL trees are BST.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    An AVL tree is a self-balancing binary search tree (BST) that maintains its balance factor, which is the difference between the heights of its left and right subtrees, within a certain range. Since AVL trees are a type of BST, they inherit all the properties of a BST, including the property that the value of each node's left child is less than the value of the node itself, and the value of each node's right child is greater than the value of the node itself. Therefore, all AVL trees are BSTs.

    Rate this question:

  • 18. 

    For a normal (double-linked) binary tree, 8 pointers are assigned to each node.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    4

    Rate this question:

  • 19. 

    Inserting a node in an AVL tree will sometimes change the height of the tree.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    When a node is inserted into an AVL tree, it may cause an imbalance in the tree, which means that the heights of the left and right subtrees of some nodes may differ by more than 1. In order to maintain the balance property of the AVL tree, rotations are performed to restore the balance. These rotations can change the height of the tree because they may change the positions of nodes and the lengths of paths from the root to the leaves. Therefore, inserting a node in an AVL tree can indeed change the height of the tree.

    Rate this question:

  • 20. 

    A hash table tends to perform better overall (bot time and space) than an array, linked list, or balanced B.S.T.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    A hash table is a data structure that allows for efficient insertion, deletion, and retrieval of elements. It uses a hash function to map keys to indices in an array, allowing for constant time complexity for these operations on average. In contrast, arrays, linked lists, and balanced binary search trees have varying time complexities for these operations. Arrays have constant time complexity for accessing elements but require shifting elements for insertion and deletion. Linked lists have constant time complexity for insertion and deletion but require traversal for accessing elements. Balanced binary search trees have logarithmic time complexity for all operations. Therefore, a hash table generally performs better overall in terms of time and space efficiency compared to these other data structures.

    Rate this question:

  • 21. 

    Linear probing is not a good solution for clustering.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Linear probing is a technique used in hashing to resolve collisions by sequentially searching for the next available slot in the hash table. However, it is not a good solution for clustering because it can lead to clustering of elements in adjacent slots. This means that if multiple elements hash to the same slot, they will be placed next to each other in the table, causing inefficient access and potentially increasing the likelihood of further collisions. Therefore, linear probing can result in poor performance and decreased efficiency in clustered data.

    Rate this question:

  • 22. 

    Linear probing uses the number of times the rehash function has been applied as a value in the hash formula.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Linear probing is a collision resolution technique used in hash tables. When a collision occurs, linear probing searches for the next available slot in the hash table by incrementing the index. The given statement is true because in linear probing, the number of times the rehash function has been applied (also known as the probing sequence) is used as a value in the hash formula. This helps to determine the next index to be checked during the probing process.

    Rate this question:

  • 23. 

    What is the disadvantage of using buckets for collision resolution?

    • A.

      The search is long

    • B.

      It takes longer to walk down

    • C.

      Wasted space

    • D.

      Not knowing how big the bucket is

    • E.

      The return time

    Correct Answer(s)
    B. It takes longer to walk down
    C. Wasted space
    D. Not knowing how big the bucket is
    Explanation
    The disadvantage of using buckets for collision resolution is that it takes longer to walk down the buckets, resulting in slower search times. Additionally, using buckets can lead to wasted space as some buckets may remain empty while others become overcrowded. Another drawback is not knowing how big each bucket is, which can make it difficult to estimate the number of elements in each bucket and affect the efficiency of the collision resolution strategy.

    Rate this question:

  • 24. 

    Choose two ways to resolve problems following a deletion in a list using linear probing.

    • A.

      Use recursion

    • B.

      Using chain down the list

    • C.

      Shift Everything

    • D.

      Insert null in deleted vairable

    Correct Answer(s)
    C. Shift Everything
    D. Insert null in deleted vairable
    Explanation
    To resolve problems following a deletion in a list using linear probing, one way is to shift everything. This means that after deleting an element, all the elements that come after it in the list are shifted one position to the left to fill the gap. Another way is to insert null in the deleted variable. This means that instead of physically removing the element from the list, it is marked as null or empty, indicating that it has been deleted. These two approaches help maintain the integrity and order of the list after a deletion has occurred.

    Rate this question:

  • 25. 

    Reading a book (cover to cover) is an example of Pre Order Traversal.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Pre-order traversal is a method used in tree data structures where the root node is visited first, followed by the left subtree, and then the right subtree. Similarly, when reading a book from cover to cover, we start with the first page (root), then move on to the next pages on the left (left subtree), and finally continue with the pages on the right (right subtree). Therefore, reading a book from cover to cover can be considered an example of pre-order traversal.

    Rate this question:

  • 26. 

    Which are Binary Trees?

    • A.

      A

    • B.

      B

    • C.

      C

    • D.

      D

    • E.

      E

    Correct Answer(s)
    A. A
    B. B
    C. C
    D. D
    E. E
    Explanation
    The answer includes all of the options A, B, C, D, and E. This suggests that all of these options are examples of binary trees.

    Rate this question:

  • 27. 

    Which are Full Binary Trees?

    • A.

      A

    • B.

      B

    • C.

      C

    • D.

      D

    • E.

      E

    Correct Answer(s)
    A. A
    B. B
    D. D
    E. E
    Explanation
    Full binary trees are binary trees in which every node has either 0 or 2 children. In option A, all the nodes have either 0 or 2 children, making it a full binary tree. Similarly, option B, D, and E also satisfy this condition, as all the nodes in these options have either 0 or 2 children. Therefore, options A, B, D, and E are full binary trees.

    Rate this question:

  • 28. 

    Reading a book (cover to cover) is an example of Post Order Traversal

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Pre order

    Rate this question:

  • 29. 

    A In Order traversal may be used to print an arithmetic expression

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Pre order

    Rate this question:

  • 30. 

    For a normal (double linked) binary tree, __ pointers are assigned to each node

    Correct Answer
    2
    Explanation
    In a normal (double linked) binary tree, two pointers are assigned to each node. This is because in a binary tree, each node has a left child pointer and a right child pointer. These pointers are used to navigate through the tree and access the left and right child nodes of a particular node. Therefore, in order to maintain the structure and connectivity of the binary tree, two pointers are assigned to each node.

    Rate this question:

  • 31. 

    The maximum height of a 14-node B.S.T. is 13

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    15

    Rate this question:

  • 32. 

    The minimum height of a 14-node B.S.T. is 5

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    3

    Rate this question:

  • 33. 

    The process of creating a B.S.T. (requires/does not require) sorting data.

    • A.

      Requires

    • B.

      Does Not Require

    Correct Answer
    A. Requires
    Explanation
    To create a Binary Search Tree (BST), sorting of data is required. A BST is a binary tree where each node has a key greater than all keys in its left subtree and smaller than all keys in its right subtree. In order to maintain this property, the data needs to be sorted while creating the BST. Without sorting, it would be impossible to ensure that the keys are placed correctly in the tree, violating the BST property. Therefore, the process of creating a BST requires sorting the data.

    Rate this question:

  • 34. 

    In Stack Methods: ____ removes the top object of the stack and returns it.

    • A.

      PUSH(X)

    • B.

      POP()

    • C.

      SIZE()

    • D.

      IsStackEmpty()

    • E.

      TOP()

    Correct Answer
    B. POP()
    Explanation
    The POP() method in stack removes the top object of the stack and returns it. This method is used to retrieve and remove the most recently added element from the stack. It decreases the size of the stack by one and returns the element that was removed.

    Rate this question:

  • 35. 

    In Stack Methods: ____ Inserts object X onto the stack.

    • A.

      PUSH(X)

    • B.

      POP()

    • C.

      SIZE()

    • D.

      IsStackEmpty()

    • E.

      TOP()

    Correct Answer
    A. PUSH(X)
    Explanation
    PUSH(X) is the correct answer because it is the method used to insert an object X onto the stack. The PUSH(X) operation adds the element X to the top of the stack, increasing the size of the stack by 1. This operation is commonly used in stack data structures to add new elements and maintain the LIFO (Last-In-First-Out) property.

    Rate this question:

  • 36. 

    In Stack Methods: ____ Returns a boolean inidcating if the stack is empty.

    • A.

      PUSH(X)

    • B.

      POP()

    • C.

      SIZE()

    • D.

      IsStackEmpty()

    • E.

      TOP()

    Correct Answer
    D. IsStackEmpty()
    Explanation
    The method isStackEmpty() returns a boolean value indicating whether the stack is empty or not. This method can be used to check if there are any elements present in the stack before performing any operations. If the stack is empty, the method will return true, otherwise it will return false.

    Rate this question:

  • 37. 

    In Stack Methods: ____ rreturns the # of objects in the stack.

    • A.

      PUSH(X)

    • B.

      POP()

    • C.

      SIZE()

    • D.

      IsStackEmpty()

    • E.

      TOP()

    Correct Answer
    C. SIZE()
    Explanation
    The correct answer is SIZE() because the SIZE() method is used to determine the number of objects present in the stack. It returns the count of objects in the stack, allowing us to know the current size of the stack.

    Rate this question:

  • 38. 

    In Stack Methods: ____ returns the top object of the stack without removing it.

    • A.

      PUSH(X)

    • B.

      POP()

    • C.

      SIZE()

    • D.

      IsStackEmpty()

    • E.

      TOP()

    Correct Answer
    E. TOP()
    Explanation
    The TOP() method returns the top object of the stack without removing it. This means that it allows us to access the element at the top of the stack without modifying the stack itself. It is useful when we want to peek at the top element without actually removing it from the stack.

    Rate this question:

  • 39. 

    Which are the Stack Methods?

    • A.

      Enqueue(X), Dequeue(), Size(), isQueueEmpty(), Front()

    • B.

      POP(), PUSH(X), SIZE(), isStackEmpty(), TOP()

    • C.

      Size(), Front(), Push(X), Pop()

    Correct Answer
    B. POP(), PUSH(X), SIZE(), isStackEmpty(), TOP()
    Explanation
    The correct answer includes the methods POP(), PUSH(X), SIZE(), isStackEmpty(), and TOP(). These methods are commonly used in stack data structures. POP() is used to remove the top element from the stack, PUSH(X) is used to add an element to the top of the stack, SIZE() is used to determine the number of elements in the stack, isStackEmpty() is used to check if the stack is empty, and TOP() is used to retrieve the top element of the stack without removing it.

    Rate this question:

  • 40. 

    ______ is a data structure in which elements are added to the rear and removed from the front. A First-In-First-Out (FIFO) structure.

    Correct Answer
    queue
    Explanation
    A queue is a data structure that follows the First-In-First-Out (FIFO) principle, meaning that the element added first will be the first one to be removed. Elements are added to the rear of the queue and removed from the front. This ensures that the order in which elements are added is preserved when removing them, making it suitable for scenarios such as managing tasks or processing requests in the order they were received.

    Rate this question:

  • 41. 

    Which are the Queue Methods?

    • A.

      Enqueue(X), Dequeue(), Size(), isQueueEmpty(), Front()

    • B.

      POP(), PUSH(X), SIZE(), isStackEmpty(), TOP()

    • C.

      Size(), Front(), Push(X), Pop()

    Correct Answer
    A. Enqueue(X), Dequeue(), Size(), isQueueEmpty(), Front()
    Explanation
    The correct answer includes the methods Enqueue(X), Dequeue(), Size(), isQueueEmpty(), and Front(). These methods are commonly used in queue data structures. Enqueue(X) is used to add an element to the back of the queue, Dequeue() is used to remove an element from the front of the queue, Size() returns the number of elements in the queue, isQueueEmpty() checks if the queue is empty, and Front() returns the element at the front of the queue without removing it.

    Rate this question:

  • 42. 

    ____ is the technique used for inserting and accessing elements in a list in a relative constant time by manipulating the key to identify its location in the list.

    Correct Answer
    hashing
    Explanation
    Hashing is a technique used for inserting and accessing elements in a list in a relative constant time by manipulating the key to identify its location in the list. This is achieved by applying a hash function to the key, which generates a unique index or address for each element in the list. This allows for efficient retrieval and insertion of elements, as the location of the element can be determined quickly based on its key.

    Rate this question:

  • 43. 

    A _____ function used to manipulate the key of an element in a list to identify its location in the list.

    Correct Answer
    hash
    Explanation
    The correct answer is "hash" because a hash function is commonly used to manipulate the key of an element in a list to determine its location within the list. A hash function takes an input (the key) and produces a unique output (the hash value) that is used as an index to store or retrieve the element in a data structure, such as a hash table or dictionary. This allows for efficient searching, inserting, and deleting of elements in the list based on their keys.

    Rate this question:

  • 44. 

    ___ is the condition resulting when two or more keys produce the same hash location.

    Correct Answer
    collision
    Explanation
    Collision is the correct answer because it refers to the condition where two or more keys in a hash table produce the same hash location. This can occur when different keys are mapped to the same index in the hash table, causing a collision. When a collision happens, additional techniques like chaining or open addressing are used to resolve it and store multiple keys at the same index.

    Rate this question:

  • 45. 

    Resolving a hash collision by sequentially searching a hash table beginning at the location returned by the hash function.

    • A.

      Clustering

    • B.

      Bucket

    • C.

      Linear Probing

    • D.

      Chain

    Correct Answer
    C. Linear Probing
    Explanation
    Linear probing is a technique used to resolve hash collisions in a hash table. When a collision occurs, instead of immediately finding an empty slot in the table, linear probing sequentially searches the table starting from the location returned by the hash function. It checks each subsequent slot until an empty slot is found, allowing the item to be inserted into the table. This process helps to minimize clustering, where consecutive collisions occur in the same location, by spreading out the items more evenly throughout the table.

    Rate this question:

  • 46. 

    A linked list of elements that share the same hash location.

    • A.

      Clustering

    • B.

      Bucket

    • C.

      Linear Probing

    • D.

      Chain

    Correct Answer
    D. Chain
    Explanation
    In this context, a chain refers to a linked list of elements that share the same hash location. This means that when multiple elements have the same hash value, they are stored in a linked list structure, with each element pointing to the next one in the list. This allows for efficient storage and retrieval of elements with the same hash value, as they can be accessed by traversing the linked list.

    Rate this question:

  • 47. 

    An Array is what kind of data structure.

    • A.

      Linear

    • B.

      Non- Linear

    • C.

      Complex

    • D.

      All the above

    • E.

      None

    Correct Answer
    A. Linear
    Explanation
    The correct answer is Linear because an array is a type of data structure that stores elements in a sequential manner, where each element can be accessed using its index. The elements in an array are stored in contiguous memory locations, making it easy to traverse the elements in a linear fashion.

    Rate this question:

  • 48. 

    While inserting an item in an array of integers which loop is right, where pos is the pos at which insertion is to be made(assume array starts from 1 and N is the max no. of items in the array.)

    • A.

      For(i=pos;i>=1;i--) { A[i] = A[i+1]; }

    • B.

      For(i=pos ; i

    • C.

      For(i=N; i>=pos;i--) { A[i] = A[i+1]; }

    • D.

      For(i=N; i>=pos;i--) { A[i+1] = A[i] }

    • E.

      For(i=N; i

    Correct Answer
    D. For(i=N; i>=pos;i--) { A[i+1] = A[i] }
    Explanation
    The correct loop is "for(i=N; i>=pos;i--) { A[i+1] = A[i] }". This loop starts from the last element of the array and moves backwards towards the position where the insertion is to be made. It shifts each element one position to the right, creating space for the new item to be inserted. By using "A[i+1] = A[i]", the value of the current element is assigned to the next position, effectively shifting the elements to the right. This loop ensures that all elements after the insertion position are shifted to the right, making room for the new item.

    Rate this question:

  • 49. 

    To delete an item from an array which loop is correct, where p is the position of deletion( assume array starts from 1 and N is the max no. of items in the array.)

    • A.

      For(i=N;i>=pos;i--) { a[i] = a[i+1]; }

    • B.

      For(i=pos;i

    • C.

      For(i=pos;i

    • D.

      For(i=pos-1;i

    • E.

      None

    Correct Answer
    B. For(i=pos;i
    Explanation
    The correct loop to delete an item from an array at position p is "for(i=pos;i

    Rate this question:

  • 50. 

    What is the contents of the array after the execution of the following program :-int a[] = {10,30, 20, 10, 30, 40};for(i=1;i<=6;i++) {   for(j=i+1 ; j<= 6; j++)   {      if(a[i] == a[j])      {         a[j] = 0;      }}

    • A.

      Same

    • B.

      10,10, 20, 20, 30, 40

    • C.

      10,0 20, 0, 30, 40

    • D.

      10,30, 20, 0, 0, 40

    • E.

      40, 30 ,10, 0, 0, 0

    Correct Answer
    D. 10,30, 20, 0, 0, 40
    Explanation
    The program is checking for duplicate elements in the array and replacing them with 0. The outer loop iterates through each element of the array, and the inner loop compares it with the subsequent elements. If a duplicate is found, the inner loop replaces the duplicate element with 0.

    In the given array, the first element 10 has a duplicate at index 4, so it is replaced with 0. The second element 30 has a duplicate at index 5, so it is also replaced with 0. The resulting array after executing the program will be 10, 30, 20, 0, 0, 40.

    Rate this question:

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.