Data Structures and Algorithms Flashcards
6 cards from real Online Coding Lessons practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 Data Structures and Algorithms flashcards as text
What is a linked list?
Answer: A data structure where each node points to the next node
A linked list is a data structure where each element (node) contains data and a pointer/reference to the next node in the sequence.
What is the main advantage of binary search over linear search?
Answer: It is faster, with O(log n) complexity on sorted arrays
Binary search has O(log n) time complexity on sorted arrays, making it much faster than linear search's O(n) for large datasets.
What is a tree data structure?
Answer: A hierarchical structure with a root node and child nodes
A tree is a non-linear hierarchical data structure with a root node at the top and child nodes branching below it.
What does 'O(1)' mean in Big O notation?
Answer: The algorithm has constant time complexity regardless of input size
O(1) means constant time complexity — the algorithm takes the same amount of time regardless of how large the input is.
Which data structure is best suited for implementing a 'back' button in a browser?
Answer: Stack
A stack is ideal for a browser's back button because visited pages are added to the top, and clicking 'back' pops the most recent page off the stack (LIFO).
What is recursion in programming?
Answer: A function that calls itself to solve a smaller version of the same problem
Recursion is a programming technique where a function calls itself with a modified input to solve a problem by breaking it into smaller subproblems.