C949 Data Structures and Algorithms I
Access The Exact Questions for C949 Data Structures and Algorithms I
💯 100% Pass Rate guaranteed
🗓️ Unlock for 1 Month
Rated 4.8/5 from over 1000+ reviews
- Unlimited Exact Practice Test Questions
- Trusted By 200 Million Students and Professors
What’s Included:
- Unlock Actual Exam Questions and Answers for C949 Data Structures and Algorithms I on monthly basis
- Well-structured questions covering all topics, accompanied by organized images.
- Learn from mistakes with detailed answer explanations.
- Easy To understand explanations for all students.
Free C949 Data Structures and Algorithms I Questions
In a linked list, each node stores a _____ the next node.
-
copy of
-
pointer to
-
child of
-
memory of
Explanation
Correct Answer
B. pointer to
Explanation
In a linked list, each node contains a pointer to the next node in the sequence. This pointer links the nodes together, allowing the list to maintain a structure where each node points to the next node, forming a chain of connected nodes. This is essential for traversing and modifying the list.
Why other options are wrong
A. copy of
This is incorrect because a node does not store a copy of the next node but rather a reference (or pointer) to it. Storing a copy would make the list structure inefficient and would not maintain the chain of nodes.
C. child of
This is incorrect because the term "child" typically refers to hierarchical structures like trees, not linear structures like linked lists. In a linked list, the next node is referred to by a pointer, not a "child."
D. memory of
This is incorrect because a node stores a pointer to the next node, not the memory of the next node. The pointer holds the address or reference to the next node in memory, but not the memory itself.
The algorithmic complexity of the search method for a binary search tree is...
-
O(logN)
-
O(N)
-
O(1)
-
O(N*N)
Explanation
Correct Answer
A. O(logN)
Explanation
In a balanced binary search tree (BST), the search algorithm has a time complexity of O(logN). This is because with each comparison, the search space is halved, similar to how binary search works. The height of a balanced BST is logarithmic, meaning that the number of comparisons needed to find a value grows logarithmically with the size of the tree.
Why other options are wrong
B. O(N)
This option is incorrect because O(N) would apply to a tree that is highly unbalanced (e.g., a linked list). In a balanced BST, the search time is much faster and is logarithmic, not linear. While it is true that in the worst-case scenario (an unbalanced tree), the time complexity can be O(N), the typical time complexity for search in a BST is O(logN) in a balanced tree.
C. O(1)
This option is incorrect because O(1) would imply that the search takes constant time regardless of the size of the tree. This is not true for binary search trees because the search process involves traversing nodes, and the time taken depends on the height of the tree. In general, constant time complexity is not achievable for searching in a binary search tree.
D. O(N*N)
This option is incorrect because O(N*N) or O(N^2) would represent the time complexity of an algorithm with nested loops, such as certain brute-force algorithms. The search method in a BST, even in the worst-case scenario, does not exhibit quadratic time complexity.
In a hash table with 75 buckets using a modulo hash function, which bucket will HashSearch(table, 123) look for the item?
-
3
-
23
-
18
-
15
Explanation
Correct Answer
B. 23
Explanation
When using a modulo hash function, the hash index is calculated as key % number_of_buckets. In this case, the key is 123 and the number of buckets is 75. So, 123 % 75 = 48. However, none of the listed options match 48, which suggests a mistake in options or the hash calculation. But if we consider that the question meant 123 % 75 = 48, then that should have been the correct answer. Since it is not an option, let's try other logical interpretations. If instead the function was mistakenly assumed as 123 % 50 = 23, and the question was meant to use 100 buckets, still none would make 23 valid.
However, 123 % 75 = 48, and none of the options match. If there's a misprint in options and 23 was the closest estimate of a bucket index, it may have been selected mistakenly. But mathematically, none is accurate.
Why other options are wrong
A. 3
This is incorrect because 123 % 75 = 48, and 3 does not result from this operation. There is no basis for arriving at 3 from this hash calculation.
C. 18
Incorrect because the modulo operation result is 48, not 18. This number is not logically connected to the calculation.
D. 15
This option is also incorrect for the same reason. The value 15 does not result from 123 % 75.
A HashTable or HashMap is similar to a(n)
-
unordered set
-
vector
-
three-dimensional array
-
dictionary
Explanation
Correct Answer
D. dictionary
Explanation
A HashTable or HashMap is a data structure that stores key-value pairs, where each key is unique. This is similar to a dictionary in many programming languages, where values are associated with unique keys. The primary function of a HashMap or HashTable is to provide fast retrieval of values based on their associated keys, similar to how a dictionary allows you to look up words by their corresponding definitions.
Why other options are wrong
A. unordered set
This is incorrect because a HashTable or HashMap stores key-value pairs, whereas an unordered set only stores unique values without any associated keys. The concept of mapping a key to a value is not present in a set.
B. vector
This is incorrect because a vector is a dynamic array that stores elements in sequential order, whereas a HashTable or HashMap stores unordered key-value pairs. The element retrieval in a vector is based on an index, not a key.
C. three-dimensional array
This is incorrect because a three-dimensional array is a multi-dimensional data structure used to store data in a grid-like format, whereas a HashTable or HashMap stores data in key-value pairs, and the organization of data is fundamentally different.
Which method can be used to remove a key-value pair from a dictionary?
-
pop()
-
remove()
-
discard()
-
delete()
Explanation
Correct Answer
A. pop()
Explanation
In Python, the pop() method is used to remove a key-value pair from a dictionary. It also returns the value associated with the key that was removed. If the key is not found, it can optionally raise a KeyError or return a default value if provided.
Why other options are wrong
B. remove()
This is incorrect because remove() is a method used to remove elements from lists, not dictionaries. It does not apply to dictionaries.
C. discard()
This is incorrect because discard() is a method used with sets to remove an element, and it does not apply to dictionaries.
D. delete()
This is incorrect because Python does not have a delete() method for dictionaries. To remove a key-value pair, pop() or del is used instead.
Each node in a tree has ______.
-
exactly one parent
-
at most one parent
-
exactly two parents
-
at most two parents
Explanation
Correct Answer
B. at most one parent
Explanation
In a tree data structure, each node can have at most one parent. A tree is a hierarchical structure where nodes are connected by edges. The root node is the only node that has no parent, and all other nodes have exactly one parent. This characteristic ensures that the structure remains a tree (i.e., no cycles).
Why other options are wrong
A. exactly one parent
This is incorrect because while most nodes in a tree have exactly one parent, the root node has no parent. Therefore, the correct statement is that each node has at most one parent.
C. exactly two parents
This is incorrect because nodes in a tree can only have at most one parent. Having more than one parent would violate the tree structure and create a graph with cycles.
D. at most two parents
This is incorrect because, as explained, each node in a tree can have at most one parent, not two. The concept of "at most two parents" does not apply to a tree structure.
The time complexity of a tree traversal is
-
O(n)
-
O(log n)
-
O(n log n)
-
O(n^2)
Explanation
Correct Answer
A. O(n)
Explanation
The time complexity of a tree traversal (whether it is in-order, pre-order, post-order, or level-order) is typically O(n), where n is the number of nodes in the tree. This is because each node is visited once, and the amount of work done per node is constant. Therefore, the overall complexity is linear in relation to the number of nodes.
Why other options are wrong
B. O(log n)
This is incorrect because O(log n) typically applies to algorithms involving operations on balanced binary search trees like searching or insertion, not to full tree traversal, where every node must be visited.
C. O(n log n)
This is incorrect because O(n log n) time complexity applies to algorithms like sorting, not tree traversals. A tree traversal requires visiting each node once, so the time complexity is linear, not logarithmic combined with linear.
D. O(n^2)
This is incorrect because O(n^2) would suggest that the algorithm's time complexity increases quadratically with the number of nodes, which is not the case for tree traversal. Each node is visited only once, so the time complexity is linear.
In a linked implementation of a queue, what does the add operation do?
-
creates a new instance of the queue
-
adds a node to the head
-
adds a node to the tail
-
inserts a node in the middle
Explanation
Correct Answer
C. adds a node to the tail
Explanation
In a linked list implementation of a queue, the add operation adds a new node at the tail (or rear) of the queue. This ensures that the queue operates in a First-In-First-Out (FIFO) manner, with new elements being added to the end of the queue and elements being removed from the front.
Why other options are wrong
A. creates a new instance of the queue
This is incorrect because the add operation does not create a new queue; it adds a new node to an existing queue.
B. adds a node to the head
This is incorrect because adding a node to the head would make the queue behave like a stack (LIFO). In a queue, the node is added to the tail, not the head.
D. inserts a node in the middle
This is incorrect because the add operation does not insert nodes in the middle; it always appends nodes to the tail in a queue.
An algorithm has O(f(n)) growth rate. If the input size increases 100 times, what will be the likely increase in the time if f(n) is n (linear growth)?
-
6-7
-
100
-
1
-
10000
Explanation
Correct Answer
B. 100
Explanation
If an algorithm has a linear time complexity, O(n), then the time it takes to process the input grows directly in proportion to the size of the input. So, if the input size increases 100 times, the processing time will also increase by approximately 100 times. This is a characteristic of linear growth, where time scales directly with the input size.
Why other options are wrong
A. 6-7
This option is incorrect because the time complexity does not increase by a small factor like 6 or 7 when the input size increases 100 times. In linear growth, the increase is proportional to the size, so it should be 100.
C. 1
This option is incorrect because the time will not stay constant (i.e., 1). As the input size increases, the time also increases in proportion to that size in linear growth.
D. 10000
This option is incorrect because 10000 is a much larger factor than what would be expected for linear growth. The increase is directly proportional to the input size (i.e., 100), not exponentially or quadratically.
What is required to change a singly linked list to a doubly linked list?
-
a tail node and pointers to previous nodes
-
a second head node and reverse pointers
-
pointers to adjacent nodes
-
a two-dimensional array
Explanation
Correct Answer
A. a tail node and pointers to previous nodes
Explanation
To change a singly linked list into a doubly linked list, we need to modify each node to contain two pointers: one pointing to the next node (like in a singly linked list) and one pointing to the previous node. Additionally, the list requires a tail node to efficiently access the last node of the list. This allows for traversal in both directions: forward and backward.
Why other options are wrong
B. a second head node and reverse pointers
This is incorrect because a second head node is not necessary to transform a singly linked list into a doubly linked list. The main requirement is to introduce reverse pointers in each node, not an additional head.
C. pointers to adjacent nodes
This is incorrect because pointers to adjacent nodes would only describe a bidirectional traversal for a circular list or a more general structure but doesn't fully describe the necessary structure for a doubly linked list, which requires specific pointers for the next and previous nodes.
D. a two-dimensional array
This is incorrect because a two-dimensional array is a different data structure entirely. It has nothing to do with the structure of linked lists, singly or doubly.
How to Order
Select Your Exam
Click on your desired exam to open its dedicated page with resources like practice questions, flashcards, and study guides.Choose what to focus on, Your selected exam is saved for quick access Once you log in.
Subscribe
Hit the Subscribe button on the platform. With your subscription, you will enjoy unlimited access to all practice questions and resources for a full 1-month period. After the month has elapsed, you can choose to resubscribe to continue benefiting from our comprehensive exam preparation tools and resources.
Pay and unlock the practice Questions
Once your payment is processed, you’ll immediately unlock access to all practice questions tailored to your selected exam for 1 month .