Coding Fundamentals Flashcards
7 cards from real CodeSignal Technical Assessment practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Coding Fundamentals flashcards as text
What is the time complexity of accessing an element by index in a dynamic array (like Python's list)?
Answer: O(1)
Dynamic arrays store elements in contiguous memory, so index-based access is O(1) constant time.
Which of the following correctly describes a stack data structure?
Answer: Last-In, First-Out (LIFO)
A stack follows LIFO: the last element pushed onto the stack is the first one popped off.
Given the code snippet `x = [1, 2, 3]; y = x; y.append(4)`, what is the value of `x`?
Answer: [1, 2, 3, 4]
In Python, `y = x` creates a reference to the same list object, so mutating `y` also mutates `x`.
What does a hash function guarantee when used in a hash table?
Answer: O(1) average-case lookup
Hash tables use a hash function to map keys to indices, providing O(1) average-case lookup time.
In Python, what is the result of `bool([])` and `bool([0])`?
Answer: False, True
An empty list is falsy in Python, but a list containing any element (even 0) is truthy.
Which sorting algorithm has the best worst-case time complexity?
Answer: Merge Sort
Merge Sort guarantees O(n log n) in all cases, whereas Quick Sort degrades to O(n²) in the worst case.
What is the output of `print(3 // 2)` in Python 3?
Answer: 1
The `//` operator performs floor division, rounding down to the nearest integer, so 3 // 2 equals 1.