NEW
Font size
WorksheetsUnderstanding Data Structures
Total questions: 10
Worksheet time: 5mins
What is a stack and how does it operate?
A stack is a data structure that only allows insertion of elements without removal.
A stack is a FIFO data structure that allows enqueue and dequeue operations.
A stack is a LIFO data structure that allows push and pop operations.
A stack is a type of queue that operates on a first-in, first-out basis.
Explain the difference between a stack and a queue.
Both stack and queue use LIFO.
A stack uses FIFO, while a queue uses LIFO.
A stack allows random access, while a queue does not.
A stack uses LIFO, while a queue uses FIFO.
What is a common use case for a stack in programming?
Sorting elements in an array
Storing data in a queue
Performing arithmetic calculations
Managing function calls and recursion.
Describe how a queue works and its main operations.
A queue works on the FIFO principle, with main operations being enqueue, dequeue, peek, and isEmpty.
A queue is primarily used for sorting data and its main operations are sort and merge.
A queue is a data structure that allows random access to elements.
A queue operates on the LIFO principle with operations like push and pop.
What is a binary tree and how is it structured?
A binary tree is a flat data structure with no hierarchical relationships.
A binary tree is a linear data structure with nodes arranged in a single line.
A binary tree is a hierarchical data structure where each node has at most two children.
A binary tree can have any number of children for each node.
How do you traverse a binary tree?
Breadth-first traversal
Depth-first traversal
In-order, Pre-order, Post-order traversal methods.
Level-order traversal
What is the difference between a tree and a graph?
A tree is a connected acyclic graph, while a graph can have cycles and may not be connected.
All graphs are trees, but not all trees are graphs.
A tree can have cycles, while a graph cannot.
A tree is a disconnected graph with multiple components.
Explain what a directed graph is.
A directed graph is a graph with no edges between vertices.
A directed graph is a graph where edges have a direction, indicating a one-way relationship between vertices.
A directed graph is a graph where all edges are bidirectional.
A directed graph is a type of tree structure with multiple roots.
What is a leaf node in a tree?
A leaf node is the root of the tree.
A leaf node is a node with one child.
A leaf node is a node with no children.
A leaf node is a node that has multiple parents.
How can graphs be represented in computer memory?
Graphs can be represented using adjacency lists or adjacency matrices.
Graphs cannot be represented in computer memory.
Graphs are best represented using linked lists exclusively.
Graphs can only be represented as binary trees.
