WorksheetsData Structures Lec
Total questions: 124
Worksheet time: 1hrs 2mins
What is a data structure?
A way to store data
A type of algorithm
A programming language
None of the above
What is the difference between linear and non-linear data structures?
Non-linear structures are faster.
Linear structures can only hold integers.
Linear structures store data in a sequential manner, while non-linear structures do not.
There is no difference.
Which operation adds new data elements to a data structure?
Insertion
Deletion
Updating
Searching
Which of the following is an example of a non-primitive data structure?
Integer
Float
Array
Boolean
What is the main advantage of using a linked list over an array?
Linked lists use less memory.
Linked lists allow for dynamic memory allocation.
Linked lists are faster.
Arrays are easier to implement.
When tasked to store a dynamic leaderboard, which structure offers optimal performance for frequent insertions and deletions?
Array
Linked List
Stack
Hash Table
Which operation is LEAST efficient in a large unsorted array?
Traversal
Insertion at end
Searching for a value
Updating an element
If a stack is used for browser “back” navigation, what algorithmic property does this application rely on?
FIFO
Hierarchical traversal
LIFO
Key-value lookup
In a queue implementation for printer jobs, what happens if dequeue is performed when the structure is empty?
An error/underflow condition occurs
The oldest job is removed
The newest job is removed
The structure is reset
Which scenario best demonstrates the application of a graph structure?
Student ID lookup
Modeling city road networks
Storing book titles alphabetically
Maintaining a To-Do list
In which scenario would you use a stack?
When you need to access elements in a specific order.
When you need to manage function calls.
When you need to store data that can grow dynamically.
When you need to store a fixed set of data.
What does the term “complex data structure” refer to?
A structure that is difficult to understand.
A structure composed of multiple primitive data types.
A structure that has more than one dimension.
A structure that is always larger than primitive types.
Which of the following is true about arrays?
They can only store integers.
They have a fixed size.
They can grow dynamically.
They are always faster than linked lists.
Explain the difference between a stack and a queue in terms of data access.
Stacks allow access to the last element added, while queues allow access to the first element added.
Stacks allow access to the first element added, while queues allow access to the last element added.
Both allow access to all elements.
There is no difference.
How does a binary search tree differ from a regular binary tree?
A binary search tree allows duplicate values.
A binary search tree maintains order for efficient searching.
A binary search tree is always balanced.
There is no difference.
When designing a search for all students living in a city, what is the most efficient operation if addresses are indexed in a hash table?
Deletion
Sorting
Searching by key
Traversal
If a linked list’s tail is disconnected, which operation is threatened?
Push
Pop
Traversal to last element
Insertion at head
Two departments implement separate student arrays. Which operation joins them for a whole-college CGPA report?
Traversal
Merging
Sorting
Destruction
In a dynamic family income tracking system, which structure adapts best if data varies monthly?
Linked list
Static array
Stack
Graph
Application: Which structure is optimal to quickly analyze millions of tweets?
Stack
Array
Tree
Hash Table
What property makes algorithm logic portable across languages?
Language independence
Effectiveness
Finiteness
Well-defined outputs
Describe the concept of dynamic programming in relation to data structures.
It is a method of storing data.
It is a way to sort data.
It is a technique for solving problems by breaking them down into simpler subproblems.
It is a type of data structure.
What is a key advantage of using linked lists over arrays?
Linked lists have a fixed size.
Linked lists can grow dynamically.
Linked lists are always faster.
Arrays are easier to implement.
What is the difference between a stack and a queue?
Stacks are FIFO, queues are LIFO.
Stacks are LIFO, queues are FIFO.
Both are the same.
Stacks can grow dynamically, queues cannot.
Explain the difference between a stack and a queue in terms of data access.
Stacks allow access to the last element added, while queues allow access to the first element added.
Stacks allow access to the first element added, while queues allow access to the last element added.
Both allow access to all elements.
There is no difference.
What algorithm property guarantees clarity in each instruction?
Well-defined outputs
Finiteness
Unambiguity
Effectiveness
To combine student records from two years, what operation is performed?
Destruction
Merging
Traversal
Sorting
To combine student records from two years, what operation is performed?
Destruction
Merging
Traversal
Sorting
Which structure is best for arranging students by last name alphabetically?
Array (with sorting)
Hash Table
Linked List
Queue
What outcome results from deleting the head of a singly-linked list?
List remains unchanged
List is destroyed
All elements become orphaned
Head advances to next node
Which property guards against vague or multi-meaning instructions in algorithms?
Unambiguity
Language independence
Finiteness
Effectiveness
What analytical advantage does a tree have over a stack in representing mentor-student relationships?
Supports hierarchical data
Faster retrieval of last added
Simpler linear traversal
No advantage
What function is used to add an element to the end of an array in Python?
add()
append()
insert()
extend()
Which of the following is an example of a one-dimensional array?
Matrix
Tic-tac-toe board
List of student grades
Rubik's cube
Which Python module is commonly used for numerical arrays?
array
numpy
math
all of the above
What is the first index of an array?
0
1
-1
2
What does the index of an array represent?
The value stored in the array
The location of the array in memory
The unique address of an element in the array
The size of the array
Which of the following is a characteristic of an array?
Dynamic size
Contiguous memory allocation
Elements stored at random locations
Elements of different types
What is an array?
A data structure that stores a fixed-size collection of elements of the same type
A function that performs operations on data
A data type that stores any type of element
A variable that holds different types of data
What function is used to remove an element at a specific index in an array?
delete()
remove()
pop()
discard()
Which of the following is a valid two-dimensional array?
[[1, 2], [3, 4]]
[[1], [2, 3]]
[1, 2, 3]
{"a": 1, "b": 2}
How are arrays stored in memory?
Non-contiguously
Contiguously
Randomly
Sequentially but with gaps
How do you access the third element in an array arr = [10, 20, 30, 40, 50]?
arr[1]
arr[2]
arr[3]
arr[0]
Which method is used to insert an element at a specific position in an array?
insert()
append()
extend()
push()
What happens if you try to access an index beyond the size of the array in Python?
Returns None
Raises an IndexError
Returns the last element
Returns False
What is the output of the following code? arr = [1, 2, 3, 4] arr.insert(2, 10) print(arr)
[1, 2, 10, 3, 4]
[1, 10, 2, 3, 4]
[1, 2, 3, 4, 10]
[1, 2, 3, 10, 4]
Which of the following operations is most efficient in an array?
Searching
Insertion at the end
Deletion at the beginning
Insertion at the beginning
Which Python library is commonly used for multidimensional arrays and matrices?
pandas
math
numpy
array
How can you reverse an array in Python?
arr.reverse()
arr[::-1]
arr.reverse() or arr[::-1]
reversed(arr)
What is the difference between an array and a list in Python?
Arrays can hold elements of different types, while lists cannot
Arrays are fixed size, lists are dynamic
Lists are faster than arrays
Arrays allow duplicate elements, while lists do not
What is a multidimensional array?
An array with a single index
An array with two or more indices
An array with no elements
A list of arrays
Which of the following best describes stack?
A linear data collection of data elements where elements are inserted in the container.
A linear data structure that holds FIFO protocol.
A linear data structure that takes out first the last element.
A linear structure that uses push and pop.
The one that tells that stack is empty.
top = -1
top = 0
top = 1
no answer
It is the condition where stack is full and push operation keeps trying to insert elements.
overflow
underflow
peek
no answer
A condition where stack is trying to pop elements in the stack while it is empty.
overflow
underflow
peek
no answer
The initial value of the TOP pointer when the stack is empty is usually:
0
1
-1
Null
Which data structure works on the principle of LIFO?
queue
stack
tree
graph
The operation that adds an element to the top of the stack is called:
push
pop
enqueue
deque
The process of reversing a string using stack operations can be achieved by:
pushing all characters and popping them in sequence
removing all middle characters first
using two stacks
using random access
The process of reversing a string …
pushing all characters and popping them in sequence
removing all middle characters first
using two stacks
using random access
When evaluating a postfix expression, what happens when an operator is encountered?
push operator
skip it
pop operator and push result
pop required operands and push result
If a function is called recursively five times before base case… how many activation records stored?
3
4
5
6
Equivalent postfix notation of (1+2)+(3+6+7)/2
12+367++2/+
12+367+2/+
12+3672/++
123672+6++/+
In the given infix notation (1+2)+(3+6+7)/2 — which operation comes first?
temp holder created
2 was pushed
two pointer created
a new holder created
In the infix (1+2)+(3+6+7)/2 when (3+6+7) will be evaluated?
when 2 & / already pushed
when 2 and 7 pushed
when 2 / already in stack
when 2,7,6 was already pushed
In (1+2)+(3+6+7)/2 Operator / ) and var 2,16 will appear in after _____ push execution
10th
9th
11th
8th
How many operations will it take to evaluate the notation (1+2)+(3+6+7)/2
16
18
17
19
Prefix of (1+2)+(3+6+7)/2
+++/276321
/+++-123672
/+++/+12345678
+++/123672
If p=4,q=3,r=5,s=7,t=6,u=2 — corresponding infix of p q r * s + t u / - * ?
4 * ((3*5)+7) - (6/2)
4357*62/-*
4*(3*5)+7-(6/2)
no answer
Evaluate postfix p q r * s + t u / - ?
64
80
90
no answer
Prefix of X/((3+4)/Y)−Z∗
-/+*X34YZ
*X/-+34YZ
*X/+34Y-Z
no answer
Program recursion stack overflow — what prevents it?
Add base condition
Use global variables
Increase loop iterations
Use queue-based recursion
What should be done when encountering a lower precedence operator than the operator at the top of the stack?
push it immediately
pop and evaluate top operator
swap operators
ignore it
Reverse Polish calculator stopped working after modifying stack size. Most likely flaw?
Incorrect precedence
Overflow check logic failure
Infinite recursion
Incorrect parsing
Prevent stack corruption in multi-threaded program?
Share one global stack
Disable recursion
Allocate separate stack for each thread
Push all thread IDs into one stack
Which is true about QUEUE?
a. FIFO
b. rear is front, front is rear
c. uses push and pop
d. uses enqueue and dequeue
a & d
b & d
c only
no answer
Queue [A,B,C,D], after 2 dequeues?
a. C is front
b. D is rear
c. queue is empty
d. B is first
c only
b and d
a and b
no answer
Which describes linear queue properties?
a. front is first
b. rear is last
c. both increase when inserting
d. underflow if full
b and d is correct
a and b is correct
c and d
no answer
Which statements about enqueue are correct?
adds item at rear
modifies front
increments rear
overflow if full
Empty queue scenario?
front = rear = -1
dequeue returns error
enqueue not possible
rear > front
After Enqueue(Pikachu, Charmander, Bulbasaur), Dequeue(), Enqueue(Squirtle) Remaining:
Pikachu, Charmander, Bulbasaur
Charmander, Bulbasaur, Squirtle
Bulbasaur, Charmander, Squirtle
Pikachu, Squirtle
Healing queue receives Eevee, Onix, Scyther, Psyduck. After two healed, which remain?
Scyther, Psyduck
Onix, Scyther, Psyduck
Eevee, Onix, Scyther
queue empty
Circular queue (size 5) enqueue 5 pokemon … After Dequeue() + two Enqueue(Mewtwo, Squirtle)
[Snorlax, Eevee, Onix, Bulbasaur, Mewtwo]
[Pikachu, Eevee, Squirtle, Snorlax, Onix]
Overflow
[Eevee, Onix, Bulbasaur, Mewtwo, Squirtle]
Ash’s Battling Queue = [Charmander, Squirtle, Bulbasaur]. After Dequeue + Enqueue(Pidgeotto) Remaining:
[Squirtle, Bulbasaur, Pidgeotto]
[Bulbasaur, Squirtle, Pidgeotto]
[Charmander, Bulbasaur, Squirtle]
[Pidgeotto, Squirtle, Charmander]
Nurse Joy’s queue = [Lapras, Onix, Gengar]. After 2 Dequeues + Enqueue(Machamp)
[Gengar, Machamp]
[Lapras, Machamp]
[Onix, Gengar]
[Machamp]
Circular queue size 6, front=4, rear=1. How many Pokémon in queue?
2
3
4
5
Ash wants queue reversed. Which operation?
Stack conversion
Concurrent queue access
Double-ended queue
Heap-based priority queue
Digital queue displays wrong order due to concurrency. Fix?
Implement mutex locks
Allow non-FIFO
Increase size
Reinitialize pointer
Ash creates a queue simulation where defeated pokemon leaves when new pokemon comes… Ensure FIFO when max size reached?
utilize circular queue
stop enqueue
reset all elements
store backup as stack
Queue storage not wrapping when rear exceeds MAX demonstrates…
true overflow
false overflow
dynamic shrinkage
stack mismatch
Brock’s schedule queue has lag due to array cycles. Efficient redesign?
recursion
add priority queue
apply linked-list queue
use two stacks
Tournament model requires front & rear insertion flexibility. Best structure?
Stack
Tree
Priority queue
Deque
Each node in singly linked list contains:
value + pointer
only value
two pointers
only address
Easiest operation in linked list vs array
searching
random access
insertion
sorting
What makes linked lists dynamic?
fixed size
always sorted
cannot be modified
can grow or shrink during execution
Disadvantage of linked list
searching is slow & time-consuming
takes less memory
elements cannot be deleted
efficient random access
It is known as the immediate predecessor of a node.
root
siblings
child node
parent node
A node with at least one child.
height of nodes
levels of node
internal nodes
external nodes
It is also called as strictly binary tree.
complete binary tree
extended binary tree
full binary tree
skewed binary tree
Which of the following is true about binary tree?
A root node may have one or two child nodes. Each node forms a binary tree itself.
The number of child nodes cannot be more than two.
It has a unique path from the root to every other node.
A binary tree has a root node. It may not have any child nodes (0 child nodes, NULL tree).
It represents the number of connections between the node and the root.
height of nodes
external nodes
internal nodes
levels of node
It represents the nodes connected by edges.
Full Binary Tree
Binary Search Tree
Binary Tree
Tree
It is a non-linear data structure compared to arrays, linked list, stack and queue.
Full Binary Tree
Binary Search Tree
Binary Tree
Tree
All nodes in this tree have only one child node.
skewed binary tree
full binary tree
extended binary tree
complete binary tree
It represents the height of its root node.
height of node
edge
degree of node
depth of node
height of tree
It is used to represent mathematical expressions.
extended binary tree
full binary tree
skewed binary tree
complete binary tree
It is also called Perfect Binary Tree.
complete binary tree
skewed binary tree
extended binary tree
full binary tree
It represents the generation of a node.
internal nodes
levels of node
height of nodes
external nodes
A tree which is dominated by left child node or right child node.
full binary tree
extended binary tree
skewed binary tree
complete binary tree
It is a hierarchical data structure which stores the information naturally in the form of hierarchy style.
Full Binary Tree
Binary Tree
Binary Search Tree
Tree
Which one is an advantage of tree?
It provides an efficient insertion and searching operations.
Tree reflects structural relationships in the data.
It allows to move subtrees around with minimum effort.
It is used to represent hierarchies.
Trees are flexible.
A number of edges on the longest path between that node and a leaf.
internal nodes
height of node
levels of node
external nodes
Type of tree where each node of binary tree has either two children or no children at all.
complete binary tree
extended binary tree
full binary tree
skewed binary tree
It represents a number of children of a node.
edge
height of tree
height of node
degree of node
depth of node
If all levels of a tree are completely filled except the last level and the last level has all keys as far as possible is called ________.
skewed binary tree
full binary tree
extended binary tree
complete binary tree
Every internal node has exactly two children and all leaf nodes are at same level.
extended binary tree
skewed binary tree
complete binary tree
full binary tree
A node without a child.
height of nodes
levels of node
external nodes
internal nodes
Every node in the tree has either 0 or 2 children.
full binary tree
extended binary tree
skewed binary tree
complete binary tree
Most of its node have the left child without corresponding right child.
full binary tree
extended binary tree
skewed binary tree
complete binary tree
It consists of replacing every null subtree of the original tree with special nodes.
complete binary tree
extended binary tree
skewed binary tree
full binary tree
A node with the same parent.
root
siblings
child node
parent node
It is known as the connection between one node to another.
height of node
degree of node
height of tree
depth of node
edge
It represents the number of edges from the tree's root node to the node.
depth of node
edge
height of node
degree of node
height of tree
The immediate successors of a node.
child node
root
siblings
parent node
