Unlock hundreds more features
Save your Quiz to the Dashboard
View and Export Results
Use AI to Create Quizzes and Analyse Results

Sign inSign in with Facebook
Sign inSign in with Google

Basic Data Structures Quiz: Test Your Skills!

Ready for the basic data structures test? Dive in and challenge yourself!

Difficulty: Moderate
2-5mins
Learning OutcomesCheat Sheet
Paper art layers depict stacks queues trees and code symbols on dark blue background inviting data structures quiz challenge

This basic data structures quiz helps you practice stacks, queues, trees, and more so you can check gaps before an exam or interview. Questions mix quick concepts and small scenarios to build speed and confidence. After you finish, keep learning with a computer science quiz or try an algorithm quiz .

What is the primary characteristic of a stack data structure?
Last In, First Out (LIFO)
Ordered by priority
First In, First Out (FIFO)
Random Access
A stack is a linear data structure that follows Last In, First Out (LIFO) order, meaning the last element added is the first one removed. This property makes it ideal for tasks like function call management in programming languages. .
Which data structure uses First In, First Out order for element removal?
Stack
Tree
Hash table
Queue
A queue is a linear data structure that follows First In, First Out (FIFO) order so that the first element inserted is the first to be removed. This behavior models real-world queues like waiting lines. .
What is the time complexity to access an element by index in a standard array?
O(n log n)
O(n)
O(log n)
O(1)
In an array, elements are stored in contiguous memory locations, so accessing any element by its index takes constant time, O(1). This direct access is one of the main advantages of arrays. .
Which of the following best describes a linked list node?
Stores only data in contiguous memory
Contains data and a pointer to the next node
Holds key-value pairs for hashing
Maintains a count array for frequencies
A linked list node typically contains the data and a pointer (or reference) to the next node in the sequence. This allows dynamic memory allocation and easy insertion or deletion. .
Which stack operation removes the top element from the stack?
Enqueue
Peek
Pop
Push
The pop operation removes the element at the top of the stack, reducing its size by one. By contrast, push adds an element, and peek only reads the top without removing it. .
In a singly linked list, what does each node contain?
Data only
Key-value pair
Pointer to previous and next nodes
Data and pointer to the next node
A node in a singly linked list contains the data and a reference (pointer) to the next node in the list. This makes operations like insertion and deletion easier. .
Which data structure is used to implement function call management in most programming languages?
Hash table
Queue
Graph
Stack
Function calls are managed by the call stack, which pushes a frame on call and pops it on return, following LIFO behavior. This ensures proper return order. .
What is the time complexity to insert a new node at the beginning of a linked list?
O(1)
O(n)
O(log n)
O(n log n)
Inserting at the head of a linked list only involves relinking a few pointers, which takes constant time, O(1). No traversal is needed. .
Which tree traversal order visits the root, then the left subtree, then the right subtree?
Level-order
Pre-order
In-order
Post-order
Pre-order traversal processes the root node first, then recursively traverses the left subtree, followed by the right subtree. It's useful for copying trees. .
Which of the following is a self-balancing binary search tree?
Trie
B-tree
AVL Tree
Binary Heap
An AVL tree is a self-balancing BST that maintains the height difference between left and right subtrees at most one, ensuring O(log n) operations. .
Which data structure removes elements based on priority rather than insertion order?
Queue
Deque
Priority Queue
Stack
A priority queue removes elements based on their priority values; highest (or lowest) priority items are dequeued first. It's often implemented with a heap. .
Which collision resolution technique uses linked lists at each bucket in a hash table?
Separate chaining
Quadratic probing
Double hashing
Open addressing
Separate chaining resolves collisions by storing colliding elements in a linked list at each hash bucket. This approach handles load factors gracefully. .
What is the worst-case time complexity for searching in an unbalanced binary search tree?
O(n log n)
O(n)
O(log n)
O(1)
In the worst case, an unbalanced BST can degenerate into a linked list, leading to O(n) search time. Balanced trees avoid this degradation. .
In a circular queue implemented with an array, when is the queue considered full?
front = 0
front = rear
rear = capacity - 1
(rear + 1) % capacity == front
In an array-based circular queue, it is full when incrementing rear modulo capacity would make it equal to front: (rear + 1) % capacity == front. This condition prevents overwriting existing elements. .
Which graph traversal algorithm uses a queue to visit nodes level by level?
Kruskal's Algorithm
Depth-First Search (DFS)
Breadth-First Search (BFS)
Dijkstra's Algorithm
Breadth-First Search (BFS) uses a queue to traverse the graph layer by layer, starting from a source node. It guarantees the shortest path in unweighted graphs. .
What is the height of a complete binary tree with n nodes?
?log? n?
n - 1
?n/2?
O(n)
A complete binary tree with n nodes has height ?log? n? because levels are fully filled except possibly the last, making its height proportional to the log base 2 of n. .
Which traversal of a binary search tree yields elements in ascending order?
Post-order
Pre-order
Level-order
In-order
In-order traversal visits the left subtree, root, and then right subtree. In a BST, this produces sorted (ascending) order of the elements. .
What is the amortized time complexity for appending an element to a dynamic array that doubles in size upon resizing?
O(n log n)
O(log n)
O(1)
O(n)
When a dynamic array doubles its capacity on resize, most insertions are O(1), and occasional resizes cost O(n), resulting in an amortized O(1) append time. .
What is the maximum number of nodes in a binary tree of height h (root at height 0)?
h!
2^h - 1
2^(h+1) - 1
h^2
A full binary tree of height h has 2^(h+1) - 1 nodes because each level i has 2^i nodes from 0 to h. This is the maximum count. .
What is the average-case time complexity for searching an element in a hash table?
O(log n)
O(1)
O(n)
O(n log n)
Under uniform hashing and a low load factor, searching in a hash table is O(1) on average because it computes a hash and directly accesses the bucket. .
What is the time complexity to delete a given node from a doubly linked list if you already have a pointer to that node?
O(n log n)
O(1)
O(log n)
O(n)
When you have direct access to a node in a doubly linked list, deletion involves updating the previous and next pointers, which takes constant time, O(1). No traversal is needed. .
Which data structure allows insertion and deletion of elements at both ends in constant time?
Deque (Double-Ended Queue)
Stack
Priority Queue
Queue
A deque supports insertion and deletion at both its front and rear in O(1) time, making it more flexible than a regular queue or stack. .
What is the expected height of a randomly built binary search tree with n distinct keys?
O(1)
O(n log n)
O(n)
O(log n)
The expected height of a randomly built BST is O(log n) because random insertions tend to balance the tree probabilistically, giving logarithmic height on average. .
In a Fibonacci heap, what is the amortized time complexity to decrease a key?
O(1)
O(log n)
O(n)
O(log² n)
Fibonacci heaps support a decrease-key operation in O(1) amortized time by cutting and cascading cuts in the heap structure. This is one of their main performance advantages. .
For a red-black tree with n internal nodes, what is the maximum height?
n
3 log? n
log? n
2 log?(n+1)
A red-black tree has height at most 2·log?(n+1) due to its balancing properties and black-height constraints, ensuring O(log n) operations. .
0
{"name":"What is the primary characteristic of a stack data structure?", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"What is the primary characteristic of a stack data structure?, Which data structure uses First In, First Out order for element removal?, What is the time complexity to access an element by index in a standard array?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}

Study Outcomes

  1. Understand Stack and Queue Operations -

    Explain how push/pop and enqueue/dequeue operations work and when to use each linear structure.

  2. Differentiation of Linear and Non-Linear Structures -

    Distinguish between arrays, linked lists, and trees, and identify their key characteristics in basic data structures.

  3. Apply Tree Traversal Techniques -

    Perform pre-order, in-order, and post-order traversals to navigate and process binary trees effectively.

  4. Analyze Core Linked List Manipulations -

    Implement insertion and deletion in singly and doubly linked lists to manage dynamic data efficiently.

  5. Evaluate Time and Space Complexity -

    Assess the efficiency of common operations across basic data structures to guide optimized algorithm design.

  6. Identify Optimal Structure for Problems -

    Select the most appropriate data structure to address specific programming challenges with confidence.

Cheat Sheet

  1. Stack Fundamentals -

    Stacks operate on the Last-In-First-Out (LIFO) principle, similar to a stack of plates where the last plate added is the first removed. Core operations push(x) and pop() execute in O(1) time, which underpins algorithms like expression evaluation and depth-first search (CLRS, Sec. 10.1). A handy mnemonic is "LIFO = Last In, First Out."

  2. Queue Mechanics -

    Queues follow the First-In-First-Out (FIFO) rule, much like people lining up - those who arrive first are served first, making queues essential for breadth-first search and task scheduling. Enqueue and dequeue operations run in O(1) time using circular buffers or linked lists (MIT OpenCourseWare, Lecture 4). Remember "FIFO: First In, First Out" to lock in the concept!

  3. Linked List Structures -

    Singly and doubly linked lists consist of nodes containing data and pointers, enabling O(1) insertion at the head or tail (Stanford CS Education Library). For example, inserting at the head requires newNode→next = head; head = newNode. Use the phrase "link and think" to recall the pointer updates.

  4. Binary Tree Traversals -

    Binary trees organize data hierarchically with left and right children, and traversals - preorder (NLR), inorder (LNR), and postorder (LRN) - visit nodes in specific sequences (GeeksforGeeks, Tree section). For instance, the inorder traversal of a tree with nodes 2 (root), 1 (left), and 3 (right) yields 1, 2, 3. A useful mnemonic is "Left, Node, Right" for inorder.

  5. Hash Table Essentials -

    Hash tables map keys to buckets via a hash function h(k) mod m, offering average O(1) lookup, insert, and delete - crucial for caching and symbol tables (Sedgewick & Wayne, Algorithms). Collision resolution uses chaining (linked lists per bucket) or open addressing (linear probing), and you can recall "m buckets, h maps" as a quick mnemonic. Mastering these topics is key to acing the basic data structures quiz.

Powered by: Quiz Maker