System Design and Architecture Flashcards
5 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 5 System Design and Architecture flashcards as text
You are given an array [2, 7, 11, 15] and a target 9. Which pair of indices will sum up to the target?
Answer: [0, 1]
To find the pair of indices that sum to the target, we examine the elements of the array [2, 7, 11, 15]. The element at index 0 is 2, and the element at index 1 is 7. Adding these two values (2 + 7) equals 9, which matches the target. Therefore, the indices [0, 1] correspond to the elements that sum to the target.
Which of the following sorting algorithms has the best average-case time complexity?
Answer: Merge Sort
While Quick Sort often performs very well in practice with an average-case time complexity of O(n log n), its worst-case complexity is O(n^2). Merge Sort, on the other hand, consistently maintains an O(n log n) time complexity in its best, average, and worst-case scenarios. This makes Merge Sort a more reliably efficient choice for its average-case performance compared to the other options listed.
Which type of SQL join returns all records from the left table and matching records from the right table?
Answer: LEFT JOIN
A `LEFT JOIN` (also known as `LEFT OUTER JOIN`) returns all rows from the "left" table (the first table mentioned in the `FROM` clause) and the matching rows from the "right" table. If there is no match in the right table, `NULL` values are returned for the columns from the right table. This ensures that no data from the left table is lost.
What is the time complexity of traversing a singly linked list with n elements?
Answer: O(n)
To traverse a singly linked list, you must visit each node sequentially from the head to the tail. In a list with 'n' elements, this requires 'n' steps, as you can only move forward one node at a time. Therefore, the time complexity for traversing the entire list is directly proportional to the number of elements, which is O(n).
Consider the following Python function: def add_numbers(a, b): return a + b print(add_numbers(2))
Answer: TypeError
The `add_numbers` function is defined to accept two arguments, `a` and `b`. However, when `print(add_numbers(2))` is called, only one argument is provided. Python will raise a `TypeError` because the function call is missing the required second positional argument `b`.