OCR A-Level Computer Science - Data Structures Flashcards
Q: What is a stack?
A: A LIFO data structure where elements are added/removed from the top. Operations: push, pop,
peek.
Q: What is a queue?
A: A FIFO data structure where elements are added at the rear and removed from the front.
Operations: enqueue, dequeue.
Q: What is a linked list?
A: A dynamic data structure made of nodes with data and a pointer to the next node.
Q: What is a binary search tree (BST)?
A: A binary tree where the left child < parent < right child. Supports efficient searching.
Q: Name the 3 tree traversals.
A: In-order, Pre-order, Post-order.
Q: What is a hash table?
A: Data structure mapping keys to values using a hash function. Handles collisions via chaining or
open addressing.
Q: What are data abstraction and ADT?
A: Hiding implementation details, showing only interface. ADT examples: stack, queue.
Q: How does linear search work?
A: Checks each element in sequence until the target is found or end is reached.
Q: How does binary search work?
A: Efficient search on sorted data by repeatedly dividing the search interval in half.
OCR A-Level Computer Science - Data Structures Flashcards
Q: List 3 sorting algorithms you should know.
A: Bubble Sort, Merge Sort, Quick Sort.
Q: Explain BFS and DFS.
A: BFS explores level by level. DFS explores as far as possible down each branch before
backtracking.
Q: What is an adjacency list?
A: A graph representation where each node stores a list of its adjacent nodes.
Q: What is an adjacency matrix?
A: A 2D array where each cell (i,j) indicates presence or weight of an edge from node i to node j.
Q: What is a tuple?
A: Immutable, ordered collection of elements.
Q: What is a record?
A: Composite data type with named fields (like a struct).
Q: What is the main advantage of using a stack?
A: Allows easy management of recursive calls and undo operations.
Q: What is the main use of a queue?
A: Task scheduling, where the first task added is the first to be processed.
Q: Explain circular queue.
A: Queue where the end connects to the front, efficiently using storage.
Q: How is a doubly linked list different from a singly linked list?
OCR A-Level Computer Science - Data Structures Flashcards
A: Doubly linked list has pointers to both next and previous nodes.
Q: What is tree traversal used for?
A: Accessing each node in a tree systematically for searching or printing data.
Q: What is the difference between pre-order and post-order traversal?
A: Pre-order visits node before children; post-order visits children before node.
Q: What is hashing?
A: Converting a key into an index using a hash function.
Q: What is a collision in a hash table?
A: When two keys hash to the same index.
Q: Describe chaining in hash tables.
A: Each slot contains a list of entries to handle collisions.
Q: Describe open addressing.
A: Finds alternative empty slots within the array for collisions.
Q: What is an Abstract Data Type (ADT)?
A: Logical description of how data is organized and what operations are allowed, not how it's
implemented.
Q: What is the difference between an array and a list?
A: Arrays have fixed size and same data type; lists are dynamic and can hold multiple data types.
Q: What is linear search best used for?
A: Unsorted data where the only option is to check each element.
OCR A-Level Computer Science - Data Structures Flashcards
Q: Why is merge sort more efficient than bubble sort?
A: Merge sort is O(n log n), while bubble sort is O(n^2).
Q: What is the main drawback of quick sort?
A: Worst case is O(n^2) if poor pivot selection occurs.
Q: What is BFS commonly used for?
A: Finding the shortest path in an unweighted graph.
Q: What is DFS commonly used for?
A: Exploring paths to their depths, checking connectivity, cycle detection.
Q: Difference between weighted and unweighted graph?
A: Weighted graph has edges with costs; unweighted does not.
Q: What is Big O notation?
A: Describes the worst-case time or space complexity of an algorithm.
Q: What is a pointer?
A: A variable that holds the address of another variable.
Q: What is dynamic memory allocation?
A: Allocating memory at runtime as needed, using pointers.
Q: When would you use a linked list over an array?
A: When frequent insertions/deletions are required without shifting elements.
Q: When is an array preferred over a linked list?
A: When fast, indexed access to elements is needed.
OCR A-Level Computer Science - Data Structures Flashcards
Q: What is a record commonly used for?
A: Storing related data fields, e.g., name, age, and grade in a student record.
Q: What is the key difference between tuple and list?
A: Tuples are immutable, while lists are mutable.
Q: Explain why recursion is useful for tree traversal.
A: It simplifies the code by naturally following the tree's recursive structure.
Q: Explain what depth means in a tree.
A: Number of edges from the root to the node.
Q: What is a leaf node?
A: A node with no children.
Q: What is the root node?
A: The top node of the tree with no parent.
Q: Describe in-order traversal output in a BST.
A: Results in sorted order of elements.