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.
The inorder and preorder traversal of a binary tree are d, b, e, a, f, c, g and a, b, d, e, c, f, g respectively. The postorder traversal of the binary tree is:
A.
D, e, b, f, g, c, a
B.
E, d, b, g, f, c, a
C.
E, d, b, f, g, c, a
D.
D, e, f, g, b, c, a
Correct Answer
A. D, e, b, f, g, c, a
Explanation The postorder traversal of a binary tree follows the pattern of visiting the left subtree, then the right subtree, and finally the root node. By observing the given inorder and preorder traversals, we can determine the root node (a) and the left and right subtrees. The left subtree consists of nodes (d, b, e) and the right subtree consists of nodes (f, c, g). By applying the postorder traversal pattern, we can determine that the postorder traversal of the binary tree is d, e, b, f, g, c, a.
Rate this question:
2.
Finding the location of the element with a given value is:
A.
Traversal
B.
Search
C.
Sort
D.
None of above
Correct Answer
B. Search
Explanation The given question is asking about the process of finding the location of an element with a given value. The correct answer is "Search" because searching refers to the process of looking for a specific element or value in a data structure or array. It involves examining each element until the desired element is found or determining that the element does not exist in the data structure.
Rate this question:
3.
Arrays are best data structures
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
A. For relatively permanent collections of data
Explanation Arrays are best data structures for relatively permanent collections of data because arrays provide efficient access to elements based on their index. Once the elements are stored in an array, they can be accessed directly using their index position, making it suitable for collections that do not frequently change in size or content. Arrays also have a fixed size, which makes them ideal for storing a fixed number of elements. However, if the size of the structure and the data in the structure are constantly changing, other data structures like linked lists or dynamic arrays may be more appropriate.
Rate this question:
4.
The operation of processing each element in the list is known as
A.
Sorting
B.
Merging
C.
Inserting
D.
Traversal
Correct Answer
D. Traversal
Explanation Traversal is the correct answer because it refers to the process of accessing and processing each element in a list or data structure. It involves visiting each element one by one, without any specific order or arrangement. Sorting, merging, and inserting are operations that involve rearranging or modifying the elements in a list, while traversal simply involves accessing them.
Rate this question:
5.
Which of the following data structure is linear data structure?
A.
Trees
B.
GrapHs
C.
Arrays
D.
None of above
Correct Answer
C. Arrays
Explanation Arrays are a linear data structure because they store elements in a sequential manner. Each element in an array is accessed by its index position, which starts from 0 and increments by 1. This allows for efficient traversal and retrieval of elements. Arrays have a fixed size and are contiguous in memory, making them suitable for applications that require random access to elements. Trees and graphs, on the other hand, are non-linear data structures as they have hierarchical or interconnected relationships between elements.
Rate this question:
6.
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 random access to elements. Linked lists, on the other hand, store elements in separate nodes that are connected through pointers. Both arrays and linked lists have a linear arrangement of elements, making them linear data structures. Therefore, the correct answer is "None of above" as there is no data structure mentioned in the options that is not a linear data structure.
Rate this question:
7.
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 the size of the structure and the data in the structure are constantly changing because linked lists allow for efficient insertion and deletion of elements at any position in the list. This is because each element in a linked list contains a reference to the next element, allowing for easy rearrangement of the list. Moreover, linked lists do not require contiguous memory allocation, making them flexible for dynamically changing data sizes. Therefore, linked lists are an ideal choice when the size of the structure and the data within it are frequently modified.
Rate this question:
8.
The Worst case occur in linear search algorithm when
A.
Item is somewhere in the middle of the array
B.
Item is not in the array at all
C.
Item is the last element in the array
D.
Item is the last element in the array or is not there at all
Correct Answer
D. Item is the last element in the array or is not there at all
Explanation In the worst case scenario for a linear search algorithm, the item being searched for is either the last element in the array or it is not present in the array at all. This is because in a linear search, each element of the array is checked one by one until the desired item is found or the end of the array is reached. If the item is the last element, it will take the maximum number of comparisons to find it. Similarly, if the item is not present in the array, the search will have to go through all the elements before determining its absence.
Rate this question:
9.
The complexity of Bubble sort algorithm is
A.
O(n)
B.
O(log n)
C.
O(n2)
D.
O(n log n)
Correct Answer
C. O(n2)
Explanation Bubble sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. The time complexity of bubble sort is O(n^2) because in the worst case scenario, where the list is in reverse order, it requires n-1 passes to sort n elements. In each pass, bubble sort compares and swaps adjacent elements, resulting in a total of (n-1) + (n-2) + ... + 1 comparisons, which is approximately n^2/2. Therefore, the time complexity of bubble sort is O(n^2).
Rate this question:
10.
The time factor when determining the efficiency of algorithm is measured by
A.
Counting microseconds
B.
Counting the number of key operations
C.
Counting the number of statements
D.
Counting the kilobytes of algorithm
Correct Answer
B. Counting the number of key operations
Explanation The efficiency of an algorithm is determined by measuring the time factor, which is done by counting the number of key operations. Key operations refer to the fundamental operations or steps that the algorithm performs, such as comparisons, assignments, and arithmetic operations. By counting the number of key operations, we can get an idea of how efficient the algorithm is in terms of time complexity. This allows us to compare and analyze different algorithms to choose the most efficient one for a given problem.
Rate this question:
11.
The Average case occur in linear search algorithm
A.
When Item is somewhere in the middle of the array
B.
When Item is not in the array at all
B. When Item is not in the array at allB. When Item is not in the array at all
B. When Item is not in the array at all
C.
When Item is the last element in the array
D.
When Item is the last element in the array or is not there at all
Correct Answer
A. When Item is somewhere in the middle of the array
Explanation The average case for a linear search algorithm occurs when the item being searched for is somewhere in the middle of the array. In this case, the algorithm would need to iterate through approximately half of the array before finding the item. This is because the linear search algorithm checks each element in the array one by one until it finds a match. Therefore, if the item is located in the middle of the array, it would take an average amount of iterations to find it.
Rate this question:
12.
Two main measures for the efficiency of an algorithm are
A.
Processor and memory
B.
Complexity and capacity
C.
Time and space
D.
Data and space
Correct Answer
C. Time and space
Explanation The two main measures for the efficiency of an algorithm are time and space. Time complexity refers to the amount of time taken by an algorithm to run, while space complexity refers to the amount of memory space required by the algorithm to execute. These measures help in evaluating the performance of an algorithm and determining how efficiently it utilizes both time and memory resources.
Rate this question:
13.
The complexity of linear search algorithm is
A.
O(n)
B.
O(log n)
C.
O(n2)
D.
O(n log n)
Correct Answer
A. O(n)
Explanation The complexity of a linear search algorithm is O(n) because it iterates through each element in the input list or array until it finds the desired element or reaches the end. As the size of the input increases, the time taken to search also increases linearly. Therefore, the time complexity is directly proportional to the size of the input, resulting in O(n) complexity.
Rate this question:
14.
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 The complexity of merge sort algorithm is O(n log n) because it divides the input array into two halves, recursively sorts them, and then merges the sorted halves. The divide and conquer approach ensures that the algorithm has a time complexity of O(n log n), where n is the number of elements in the array. This is because the array is continuously divided into halves until individual elements are obtained, and then the merge operation combines the sorted halves in a linear time complexity. Therefore, the overall time complexity of merge sort is O(n log n).
Rate this question:
15.
Inserting an item into the stack when stack is not full is called …………. Operation and deletion of item form the stack, when stack is not empty is called ………..operation.
A.
Push, pop
B.
Pop, push
C.
Insert, delete
D.
Delete, insert
Correct Answer
A. Push, pop
Explanation When an item is inserted into the stack when it is not full, it is called a "push" operation. This is because the item is being pushed onto the top of the stack. On the other hand, when an item is deleted from the stack when it is not empty, it is called a "pop" operation. This is because the item at the top of the stack is being popped off and removed.
Rate this question:
16.
……………. Is a pile in which items are added at one end and removed from the other.
A.
Stack
B.
Queue
C.
List
D.
None of the above
Correct Answer
B. Queue
Explanation A queue is a data structure in which items are added at one end (rear) and removed from the other end (front). This follows the principle of First-In-First-Out (FIFO), where the item that is added first will be the first one to be removed. In a queue, new items are always added to the rear end, while removal happens from the front end. Therefore, the correct answer is Queue.
Rate this question:
17.
. ………… is very useful in situation when data have to stored and then retrieved in reverse order.
A.
Stack
B.
Queue
C.
List
D.
Link list
Correct Answer
A. Stack
Explanation A stack is very useful in situations when data have to be stored and then retrieved in reverse order. In a stack, the last item that is added will be the first one to be removed, making it ideal for reversing the order of data. This is because a stack follows the Last-In-First-Out (LIFO) principle, where the most recently added item is always at the top and is the first one to be accessed. So, when data needs to be retrieved in reverse order, a stack is the appropriate data structure to use.
Rate this question:
18.
Linked list are not suitable data structure of which one of the following problems ?
A.
Insertion sort
B.
Binary search
C.
Radix sort
D.
Polynomial manipulation
Correct Answer
B. Binary search
Explanation Linked lists are not suitable for binary search because binary search requires random access to elements, which is not efficiently supported by linked lists. In binary search, we need to access the middle element of the sorted list repeatedly, and this operation takes O(n) time in a linked list as we have to traverse the list from the beginning each time. On the other hand, arrays or other data structures that support random access are more suitable for binary search as they allow direct access to any element in O(1) time.
Rate this question:
19.
Which of the following algorithm design technique is used in the quick sort algorithm?
A.
Dynamic programming
B.
Backtracking
C.
Divide and conquer
D.
Greedy method
Correct Answer
C. Divide and conquer
Explanation The quicksort algorithm uses the divide and conquer technique. This technique involves breaking down the problem into smaller subproblems, solving them independently, and then combining the solutions to obtain the final result. In the case of quicksort, the algorithm partitions the array into two subarrays based on a pivot element, recursively sorts the subarrays, and then combines them to obtain the sorted array. This divide and conquer approach allows quicksort to efficiently sort large arrays by dividing the sorting process into smaller, manageable parts.
Rate this question:
20.
The following sequence of operation is performed on stack : push(1),push(2),pop,push(1),push(2),pop,pop,pop,push(2),pop. The sequence of popped out values are ?
A.
2,2,1,1,2
B.
2,2,1,2,2
C.
2,1,2,2,1
D.
2,1,2,2,2
Correct Answer
A. 2,2,1,1,2
Explanation The given sequence of operations on the stack can be represented as follows:
1. Push 1 onto the stack.
2. Push 2 onto the stack.
3. Pop the top element from the stack, which is 2.
4. Push 1 onto the stack.
5. Push 2 onto the stack.
6. Pop the top element from the stack, which is 2.
7. Pop the top element from the stack, which is 1.
8. Pop the top element from the stack, which is 1.
9. Push 2 onto the stack.
10. Pop the top element from the stack, which is 2.
Therefore, the sequence of popped out values is 2, 2, 1, 1, 2.
Rate this question:
21.
Consider the following graphWhich one of the following is NOT the sequences of edges added to the minimum spanning tree using Kruskal algorithm?
A.
(b,e) (e,f) (a,c) (b,c) (f,g) (c,d)
B.
(b,e) (e,f) (a,c) (f,g) (b,c) (c.d)
C.
(b,e) (a,c) (e,f) (b,c) (f,g) (c,d)
D.
(b,e) (e,f) (b,c) (a,c) (f,g) (c,d)
Correct Answer
D. (b,e) (e,f) (b,c) (a,c) (f,g) (c,d)
22.
Which of the following is useful in traversing a given graph by breadth first search?
A.
[Stack
B.
Set
C.
List
D.
Queue
Correct Answer
D. Queue
Explanation In breadth-first search, we explore all the vertices of a graph at the same level before moving to the next level. This requires visiting the vertices in the order they were discovered. A queue follows the First-In-First-Out (FIFO) principle, making it suitable for implementing breadth-first search. We can enqueue the starting vertex and then enqueue its adjacent vertices one by one. This ensures that the vertices are visited in the order they were discovered, allowing us to traverse the graph in a breadth-first manner.
Rate this question:
23.
Which of the following is useful in implementing quick sort?
A.
Stack
B.
Set
C.
List
D.
Queue
Correct Answer
A. Stack
Explanation Stack is useful in implementing quick sort because quick sort uses a divide and conquer approach, where it repeatedly divides the array into smaller subarrays. The stack data structure helps in keeping track of the subarrays that need to be sorted, allowing for efficient recursion and backtracking. As the algorithm progresses, the stack stores the indices of the subarrays that still need to be partitioned, ensuring that the sorting process is done correctly.
Rate this question:
24.
What is the result of the following operation Top (Push (S, X))
A.
X
B.
Null
C.
S
D.
None of these
Correct Answer
A. X
Explanation The result of the operation Top (Push (S, X)) is X. This is because the Push operation adds the element X to the top of the stack S, and the Top operation retrieves the element at the top of the stack, which in this case is X.
Rate this question:
25.
Which one of the following array represents a binary max-heap?
A.
{25, 12, 16, 13, 10, 8, 14}
B.
{25, 14, 13, 16, 10, 8, 12}
C.
{25, 14, 16, 13, 10, 8, 12}
D.
{25, 14, 12, 13, 10, 8, 16}
Correct Answer
C. {25, 14, 16, 13, 10, 8, 12}
26.
The postfix expression for * + a b - c d is?
A.
Ab + cd - *
B.
Ab cd + - *
C.
Ab + cd * -
D.
Ab + - cd *
Correct Answer
A. Ab + cd - *
Explanation The given postfix expression is obtained by converting the given infix expression to postfix notation. In postfix notation, the operators are placed after their operands. The expression "ab + cd - *" can be evaluated as follows: first, the operands "a" and "b" are added, then the operands "c" and "d" are subtracted, and finally, the result of the addition and subtraction are multiplied. Therefore, the correct postfix expression for * + a b - c d is "ab + cd - *".
Rate this question:
27.
Term Data Structure refers to _________ and interrelationship between them.
A.
Coding Standards
B.
Programming Language Statement
C.
Organization of data element
D.
None of these
Correct Answer
C. Organization of data element
Explanation The term "Data Structure" refers to the organization of data elements and their interrelationship. It involves how data is stored, accessed, and manipulated in a computer system. This includes the arrangement of data elements in memory, the relationships between different data elements, and the operations that can be performed on them. Coding standards and programming language statements are not directly related to data structures, although they may be influenced by them. Therefore, the correct answer is "Organization of data element".
Rate this question:
28.
Which one of the following sequences denotes the post-order traversal for the following tree:
A.
F e g c d b a
B.
G c b d a f e
C.
G c d b f e a
D.
F e d g c b a
Correct Answer
C. G c d b f e a
Explanation The post-order traversal of a tree visits the left subtree, then the right subtree, and finally the root node. In the given options, the sequence "g c d b f e a" follows this order. It starts with the left subtree, visiting nodes "g c d b", then moves to the right subtree, visiting nodes "f e", and finally visits the root node "a". Therefore, "g c d b f e a" is the correct post-order traversal for the given tree.
Rate this question:
29.
A binary search tree contains the values 1, 2, 3, 4, 5, 6, 7, 8. The tree is traversed in pre-order and the values are printed out. Which of the following sequences is valid output?
A.
5 3 1 2 4 7 8 6
B.
5 3 1 2 6 4 8 7
C.
5 3 2 4 1 6 7 8
D.
5 3 1 2 4 7 6 8
Correct Answer
D. 5 3 1 2 4 7 6 8
Explanation In a binary search tree, the pre-order traversal visits the root node first, then the left subtree, and finally the right subtree. Looking at the given sequences, we can see that the sequence "5 3 1 2 4 7 6 8" is a valid output because it follows the pre-order traversal pattern. The root node is 5, the left subtree contains the nodes 3, 1, and 2, and the right subtree contains the nodes 4, 7, 6, and 8. Therefore, the given sequence is a valid pre-order traversal of the binary search tree.
Rate this question:
30.
The following numbers are inserted into an empty binary search tree in the given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree (the height is the maximum distance of a leaf node from the root)?
A.
2
B.
3
C.
4
D.
6
Correct Answer
B. 3
Explanation The height of a binary search tree is defined as the maximum distance from the root to a leaf node. In this case, the numbers are inserted in the following order: 10, 1, 3, 5, 15, 12, 16. This results in the following binary search tree:
10
/ \
1 15
\ / \
3 12 16
\
5
The longest path from the root to a leaf node is 10 -> 15 -> 16, which has a distance of 3. Therefore, the height of the binary search tree is 3.
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.