Question 1 of 50
Which type of linked list allows navigation in both forward and backward directions?
Correct answer:
B) Doubly Linked List
Explanation: A doubly linked list includes pointers to both the previous and next nodes, allowing traversal in both directions.
Question 2 of 50
In a binary tree, what are nodes called that have no children?
Correct answer:
C) Leaf nodes
Explanation: Leaf nodes are the terminal nodes in a binary tree, having no child nodes.
Question 3 of 50
What is the time complexity of accessing the last element in an array?
Correct answer:
A) O(1)
Explanation: Accessing any element in an array by index, including the last element, is constant time, O(1).
Question 4 of 50
Which data structure is primarily used to manage elements in Last-In-First-Out (LIFO) order?
Correct answer:
B) Stack
Explanation: A stack follows LIFO order, where the last element added is the first to be removed.
Question 5 of 50
In a queue, where are elements removed?
Correct answer:
A) From the front
Explanation: A queue is a FIFO data structure where elements are removed from the front.
Question 6 of 50
What method would retrieve and remove the highest-priority element in a priority queue?
Correct answer:
C) extractMax()
Explanation: In a max-priority queue, extractMax() retrieves and removes the highest-priority element, often the maximum value.
Question 7 of 50
Which ADT operation for stacks returns, but does not remove, the top item?
Correct answer:
B) Peek
Explanation: Peek allows viewing the top item without modifying the stack.
Question 8 of 50
What traversal order is generally used to delete all nodes in a tree?
Correct answer:
C) Post-order
Explanation: Post-order traversal visits each child node before the parent, making it suitable for deleting nodes.
Question 9 of 50
Which sorting algorithm starts with the farthest elements and reduces the gap between compared elements gradually?
Correct answer:
B) Shell Sort
Explanation: Shell sort begins by comparing far-apart elements and gradually reduces the gap for more localized sorting.
Question 10 of 50
Which data structure does not allow duplicate elements and stores data unordered?
Correct answer:
C) Set
Explanation: Sets are unordered collections that do not allow duplicate elements, ensuring each item is unique.
Question 11 of 50
What data structure would be best suited for managing undo operations in software?
Correct answer:
B) Stack
Explanation: Stacks support Last-In-First-Out (LIFO), which is useful for managing undo actions, where the most recent action is undone first.
Question 12 of 50
What does the expression my_list[:3] return in Python if my_list = [5, 10, 15, 20, 25]?
Correct answer:
A) [5, 10, 15]
Explanation: Slicing with [:3] retrieves elements from the start of the list up to, but not including, index 3.
Question 13 of 50
In Python, which function finds the index of the first element in a list that matches a specific value?
Correct answer:
C) list.index()
Explanation: list.index() returns the index of the first occurrence of a specified value in the list.
Question 14 of 50
Which algorithm is designed to find the kth smallest element in an unsorted list?
Correct answer:
C) Quickselect
Explanation: Quickselect is an algorithm optimized to find the kth smallest element without fully sorting the list.
Question 15 of 50
What is the primary function of append() in a linked list?
Correct answer:
C) To add an element at the end
Explanation: append() adds a new element at the end of a list or linked list.
Question 16 of 50
What ADT supports only First-In-First-Out (FIFO) operations?
Correct answer:
C) Queue
Explanation: A queue follows FIFO order, meaning the first element added is the first to be removed.
Question 17 of 50
What is the purpose of the __init__ method in Python classes?
Correct answer:
B) To initialize an object's properties
Explanation: __init__ is the constructor in Python, used to initialize the attributes of an instance.
Question 18 of 50
In a binary tree, which traversal visits the root, followed by the left subtree, then the right subtree?
Correct answer:
C) Pre-order
Explanation: Pre-order traversal visits the root node first, followed by the left and right subtrees.
Question 19 of 50
Which data structure is particularly efficient for finding the minimum or maximum value in a collection?
Correct answer:
C) Priority Queue
Explanation: Priority queues allow efficient access to the smallest or largest element based on priority.
Question 20 of 50
What is the time complexity of searching in a balanced binary search tree?
Correct answer:
B) O(log n)
Explanation: Balanced binary search trees allow efficient search, insertion, and deletion with a time complexity of O(logn).
Question 21 of 50
Which sorting algorithm splits the array into smaller arrays, sorts them, and merges them back together?
Correct answer:
B) Merge Sort
Explanation: Merge Sort is a divide-and-conquer algorithm that recursively splits, sorts, and merges arrays.
Question 22 of 50
In Python, what does the any() function return if all elements in a list are False?
Correct answer:
B) False
Explanation: The any() function returns True if at least one element in the list is True; otherwise, it returns False.
Question 23 of 50
Which operation in a binary search tree has an average complexity of O(log n)?
Correct answer:
D) All of the above
Explanation: Insert, delete, and search operations in a balanced binary search tree all have an average complexity of O(logn).
Question 24 of 50
What is a unique attribute of a singly linked list?
Correct answer:
C) Each node points only to the next node
Explanation: In a singly linked list, each node has a pointer only to the next node in the sequence.
Question 25 of 50
In a stack, which operation would you use to add an element to the top?
Correct answer:
D) Push
Explanation: Push adds an element to the top of a stack, following the LIFO order.
Question 26 of 50
Which data structure uses hashing to map keys to values, allowing quick lookups?
Correct answer:
C) Dictionary
Explanation: Dictionaries (or hash tables) use a hashing function to map keys to values, facilitating fast lookups.
Question 27 of 50
What does range(5, -6, -1) produce in Python?
Correct answer:
C) A decreasing sequence from 5 down to -5
Explanation: range(5, -6, -1) creates a sequence starting at 5 and decrements by 1, stopping before reaching -6.
Question 28 of 50
Which sorting algorithm has the best time complexity of O(n log n) on average?
Correct answer:
B) Merge Sort
Explanation: Merge Sort operates at O(n log n) on average and is efficient for larger data sets.
Question 29 of 50
In a circular linked list, where does the last node point?
Correct answer:
C) First node
Explanation: The last node in a circular linked list points back to the first node, forming a closed loop.
Question 30 of 50
What is the Big-O notation for the worst-case time complexity of binary search?
Correct answer:
B) O(log n)
Explanation: Binary search has a worst-case complexity of O(logn) because it halves the search space each step.
Question 31 of 50
Which algorithm repeatedly finds the minimum element and places it at the beginning of the array?
Correct answer:
C) Selection Sort
Explanation: Selection Sort selects the minimum unsorted element and places it at the start, repeating until sorted.
Question 32 of 50
In a binary tree, which traversal visits nodes from the lowest level up to the root?
Correct answer:
A) Level-order
Explanation: Level-order traversal, or breadth-first traversal, visits nodes level by level from top to bottom.
Question 33 of 50
What is the output of all([0, 1, 2]) in Python?
Correct answer:
B) False
Explanation: all() returns False if any element is zero or False; here, 0 makes the list evaluate as False.
Question 34 of 50
What is a primary advantage of hash tables?
Correct answer:
B) They provide O(1) time complexity for search
Explanation: Hash tables use hash functions to provide average O(1) time complexity for search operations.
Question 35 of 50
What type of data does a max-heap maintain at the root?
Correct answer:
C) Maximum value
Explanation: In a max-heap, the root node contains the maximum value, with child nodes having lesser values.
Question 36 of 50
What type of node is the root in a tree?
Correct answer:
A) The top-most node
Explanation: The root is the top-most node in a tree structure, with no parent node.
Question 37 of 50
What is an associative array commonly known as in Python?
Correct answer:
B) Dictionary
Explanation: In Python, dictionaries are associative arrays that map keys to values.
Question 38 of 50
Which function removes the last item from a list in Python?
Correct answer:
A) pop()
Explanation: pop() without an index argument removes and returns the last item in a list.
Question 39 of 50
What is the main feature of a binary search algorithm?
Correct answer:
C) It divides the search space in half each step
Explanation: Binary search reduces the search space by half with each comparison, making it efficient for sorted data.
Question 40 of 50
Which data structure would be best suited for a breadth-first search?
Correct answer:
C) Queue
Explanation: A queue is used in breadth-first search (BFS) as it processes nodes level by level in FIFO order.
Question 41 of 50
In a min-heap, where would you typically find the smallest value?
Correct answer:
A) At the root
Explanation: In a min-heap, the smallest element is always located at the root.
Question 42 of 50
What method would you use to access all values in a dictionary?
Correct answer:
C) values()
Explanation: values() returns a view object containing all values in a dictionary.
Question 43 of 50
What traversal would result in visiting nodes in ascending order in a binary search tree?
Correct answer:
B) In-order
Explanation: In-order traversal of a binary search tree yields nodes in ascending order.
Question 44 of 50
What operation is used to add a new node in a max heap?
Correct answer:
A) Insert
Explanation: Insert adds a new element to a max heap, typically followed by re-heapification to maintain the max-heap property.
Question 45 of 50
In a binary tree, what is a node that has one or more children called?
Correct answer:
B) Internal node
Explanation: Internal nodes in a binary tree are those with one or more children.
Question 46 of 50
Which data structure supports insertion and deletion at both ends?
Correct answer:
C) Deque
Explanation: A deque (double-ended queue) allows insertion and deletion from both ends.
Question 47 of 50
In a graph, what is the term for a direct connection between two vertices?
Correct answer:
B) Edge
Explanation: An edge represents a direct connection between two vertices in a graph.
Question 48 of 50
Which of these has a complexity of O(n^3)?
Correct answer:
B) Matrix Multiplication
Explanation: Matrix multiplication often has a time complexity of O(n3), especially for square matrices.
Question 49 of 50
In Python, which function returns the data type of an object?
Correct answer:
B) type()
Explanation: type() returns the data type of the specified object in Python.
Question 50 of 50
In a binary tree, which traversal visits nodes starting from the root, then moves level by level?
Correct answer:
C) Level-order
Explanation: Level-order traversal visits each level of the tree from top to bottom, starting from the root.
Set 4 completeYou scored 0%
0 correct out of 0 answered (50 questions in this set).