What is the complexity of inserting an element at the beginning of a linked list?
Correct answer:
C) O(1)
Explanation: Insertion at the beginning of a linked list is O(1) since no shifting of elements is required, unlike arrays.
What is the complexity of inserting an element at the beginning of a linked list?
Correct answer:
C) O(1)
Explanation: Insertion at the beginning of a linked list is O(1) since no shifting of elements is required, unlike arrays.
Which data structure organizes elements based on their key-value association?
Correct answer:
C) Dictionary
Explanation: A dictionary (or hash table) uses key-value pairs to organize and retrieve elements efficiently.
Which sorting algorithm has a time complexity of O(n^2) in the worst case but is efficient for nearly sorted data?
Correct answer:
C) Insertion Sort
Explanation: Insertion Sort has O(n2) complexity in the worst case, but it performs well with nearly sorted data.
What is the return type of the Python function type()?
Correct answer:
C) Data type of the object
Explanation: type() in Python returns the data type of the specified object.
Which operation in a priority queue always retrieves the highest priority item?
Correct answer:
B) Pop
Explanation: Pop in a priority queue retrieves the item with the highest priority, often the largest or smallest based on configuration.
What is a tree structure with each node having at most two children?
Correct answer:
B) Binary Tree
Explanation: A binary tree has a hierarchical structure with each node limited to a maximum of two children.
In Python, which function can be used to return a sequence of numbers from 10 to 20 in steps of 2?
Correct answer:
A) range(10, 20, 2)
Explanation: range(10, 20, 2) generates numbers from 10 to 18, with a step of 2.
Which sorting algorithm divides the data into smaller sections around a pivot and recursively sorts them?
Correct answer:
C) Quick Sort
Explanation: Quick Sort uses a pivot to partition data into smaller segments and recursively sorts each segment.
What is the expected time complexity for searching an item in an unbalanced binary search tree?
Correct answer:
C) O(n)
Explanation: An unbalanced binary search tree can degrade to a linked list, resulting in O(n) search complexity.
In a stack, what does the pop operation do?
Correct answer:
C) Removes and returns the top item
Explanation: pop removes and returns the top item in a stack, following the Last-In-First-Out (LIFO) principle.
What data structure is ideal for a collection where each item has a unique identifier and can be quickly accessed by its key?
Correct answer:
D) Hash Table
Explanation: A hash table organizes data by unique keys, allowing efficient access to values via hash functions.
What data structure is well-suited for implementing a collection of tasks prioritized by their importance?
Correct answer:
D) Priority Queue
Explanation: Priority queues manage elements by priority, retrieving higher-priority tasks first.
Which traversal of a binary tree visits the root node before its children?
Correct answer:
C) Pre-order
Explanation: Pre-order traversal visits the root first, followed by the left and right subtrees.
What is the purpose of remove() in a Python list?
Correct answer:
C) Deletes the first instance of a specified element
Explanation: remove() deletes the first occurrence of a specified value in a list.
What is a node with two pointers, one to the next and one to the previous node, called in a linked list?
Correct answer:
C) Doubly linked node
Explanation: Doubly linked nodes contain pointers to both the previous and next nodes, enabling bidirectional traversal.
What type of list uses both head and tail pointers for efficient front and back operations?
Correct answer:
B) Doubly linked list
Explanation: Doubly linked lists use head and tail pointers to allow efficient operations at both ends.
In a queue, where is the newest element added?
Correct answer:
C) Rear
Explanation: Queues add new elements at the rear, following FIFO (First-In-First-Out) ordering.
What is the complexity of finding the smallest element in an unsorted list?
Correct answer:
B) O(n)
Explanation: Finding the smallest element requires a linear scan of the list, giving a time complexity of O(n).
Which function in Python returns a list with every nth element from start to end?
Correct answer:
D) slice()
Explanation: The slicing syntax [start:end:stride] returns every nth element in a specified range of a list.
What traversal method in a binary tree is used to display nodes in sorted order?
Correct answer:
B) In-order
Explanation: In-order traversal in a binary search tree yields nodes in ascending order.
Which data structure is characterized by First-In-First-Out (FIFO) access?
Correct answer:
B) Queue
Explanation: Queues retrieve elements in the order they were added, following FIFO.
What is the average case time complexity for insertion sort?
Correct answer:
D) O(n^2)
Explanation: Insertion sort has an average complexity of O(n2) due to its repeated shifts during insertion.
In a circular queue, where does the last element connect?
Correct answer:
A) Front
Explanation: In a circular queue, the last element connects back to the front, forming a closed loop.
What method in Python dictionaries removes and returns a specified key-value pair?
Correct answer:
C) popitem()
Explanation: popitem() removes and returns the last inserted key-value pair from a dictionary.
In a binary search tree, which traversal method visits nodes in descending order?
Correct answer:
B) Reverse In-order
Explanation: Reverse In-order traversal (right, root, left) visits nodes in descending order.
What complexity does a linear search exhibit?
Correct answer:
C) O(n)
Explanation: Linear search has O(n) complexity, as it examines each element sequentially until a match is found.
Which algorithm repeatedly merges sorted halves?
Correct answer:
C) Merge Sort
Explanation: Merge Sort recursively splits and merges halves, resulting in an overall O(nlogn)O(n \log n)O(nlogn) time complexity.
What is the worst-case time complexity of deleting an element in a balanced binary search tree?
Correct answer:
A) O(log n)
Explanation: Deletion in a balanced binary search tree has a worst-case complexity of O(logn).
Which data structure is optimized for storing elements in key-value pairs and supports fast retrieval?
Correct answer:
D) Hash Table
Explanation: Hash tables store elements in key-value pairs and allow quick retrieval using hash functions.
What is the time complexity of inserting an element in an unsorted array?
Correct answer:
A) O(1)
Explanation: Inserting at the end of an unsorted array has constant time complexity, O(1), as it requires no shifts.
Which function removes all elements from a Python list?
Correct answer:
A) clear()
Explanation: clear() removes all items from a list, making it empty.
What type of traversal in a binary tree is used to process nodes level by level?
Correct answer:
D) Level-order
Explanation: Level-order traversal, or breadth-first traversal, processes each level of nodes from top to bottom.
What type of data structure is ideal for implementing a collection where duplicates are allowed and order does not matter?
Correct answer:
B) Bag
Explanation: Bags allow duplicate elements without enforcing any specific order.
In a binary search, which condition is crucial for the algorithm to work correctly?
Correct answer:
A) The array must be sorted
Explanation: Binary search requires a sorted array to function correctly, as it divides the search space based on ordering.
What type of node is removed when deleting a leaf node from a binary tree?
Correct answer:
D) Node with no children
Explanation: Leaf nodes have no children, making them easy to remove by unlinking.
What complexity is associated with finding the middle element in an unsorted linked list?
Correct answer:
C) O(n)
Explanation: Finding the middle element in a linked list requires traversing half the list, resulting in O(n) complexity.
In Python, what does dict.keys() return?
Correct answer:
A) A list of keys
Explanation: dict.keys() returns a view object containing all the keys in a dictionary.
What is a major drawback of linear search?
Correct answer:
C) Time complexity of O(n)
Explanation: Linear search has a time complexity of O(n), making it inefficient for large lists.
Which data structure is ideal for implementing a collection that needs fast membership testing?
Correct answer:
C) Set
Explanation: Sets support fast membership testing due to hash-based storage, allowing O(1) lookup time.
What is the space complexity of a hash table storing n elements?
Correct answer:
C) O(n)
Explanation: Hash tables require O(n) space, as each entry typically stores one key-value pair.
Which function in Python removes the first occurrence of a specific value in a list?
Correct answer:
D) remove()
Explanation: remove() deletes the first occurrence of a specified value from the list.
What type of algorithm is typically used for pathfinding in a graph?
Correct answer:
C) Dijkstras Algorithm
Explanation: Dijkstras algorithm is commonly used for finding the shortest path between nodes in a graph.
Which complexity does a binary search exhibit on a sorted array?
Correct answer:
C) O(log n)
Explanation: Binary search has O(logn) complexity, as it reduces the search space by half with each comparison.
In a min-heap, where is the minimum element located?
Correct answer:
C) Root
Explanation: In a min-heap, the root node contains the minimum value.
What data structure is used to store unique elements in no particular order in Python?
Correct answer:
B) Set
Explanation: Sets store unique, unordered elements, ensuring no duplicates.
Which algorithm is most efficient for sorting large data sets?
Correct answer:
C) Merge Sort
Explanation: Merge Sort is efficient for large data sets with a time complexity of O(nlogn).
What operation is used to add a key-value pair to a dictionary in Python?
Correct answer:
D) assignment operator (=)
Explanation: In Python, key-value pairs are added to dictionaries using the assignment operator.
What is the complexity of removing an element from a priority queue?
Correct answer:
B) O(log n)
Explanation: Removing an element from a priority queue, implemented as a heap, has a complexity of O(logn).
Which data structure uses the LIFO principle?
Correct answer:
B) Stack
Explanation: Stacks operate on a Last-In-First-Out (LIFO) basis, where the last element added is the first to be removed.
What traversal of a binary tree first visits the left subtree, then the root, and then the right subtree?
Correct answer:
B) In-order
Explanation: In-order traversal follows the left, root, right pattern, often used to retrieve nodes in sorted order in BSTs.
If this exam is giving you a hard time, let us be your helping hand. Contact us, and we'll provide the assistance you need to pass and move forward.