Algorithms & Data Structures Flashcards
6 cards from real B.S.W.E. Bachelor of Software Engineering practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 Algorithms & Data Structures flashcards as text
What is the time complexity of binary search?
Answer: O(log n)
Binary search has O(log n) time complexity because it eliminates half the remaining search space with each comparison.
What data structure uses LIFO (Last In, First Out) ordering?
Answer: Stack
A stack uses LIFO ordering where the last element pushed is the first one popped, like a stack of plates.
What is the time complexity of inserting an element at the beginning of an array?
Answer: O(n)
Inserting at the beginning of an array requires shifting all n existing elements one position to the right, resulting in O(n) time.
What is a hash table?
Answer: A data structure using a hash function to map keys to array indices for fast lookup
A hash table uses a hash function to compute an index into an array of buckets, providing average O(1) time for insertions and lookups.
What is the fundamental difference between a stack and a queue?
Answer: Stacks use LIFO ordering; queues use FIFO ordering for element removal
Stacks use Last In First Out (LIFO) while queues use First In First Out (FIFO) — the difference is which end elements are removed from.
What is the worst-case time complexity of quicksort?
Answer: O(n²)
Quicksort degrades to O(n²) in the worst case when the pivot consistently produces maximally unbalanced partitions, such as on already-sorted input.