120 of this kit's 329 questions, laddered from warm-up to topper-level, each with its answer and the reasoning. The rest are in the app.
Warm-up
· 68 questions
Q1.
When is memory allocated for a static data structure?
Beginner
A
When the first element is accessed
B
At runtime
C
At compile time
D
When the program is loaded
Answers and explanations are in the Veda app.
Q2.
Which of the following is an example of a dynamic data structure?
Beginner
A
Static stack
B
Static queue
C
Array
D
Linked list
Answers and explanations are in the Veda app.
Q3.
What is the main advantage of static data structures?
Beginner
A
Can handle variable input sizes
B
Faster access due to contiguous memory
C
Flexible size
D
No memory wastage
Answers and explanations are in the Veda app.
Q4.
What does 'static' refer to in a static data structure?
Beginner
A
The values cannot be changed
B
The structure cannot be used in functions
C
The size is fixed
D
The memory is allocated at runtime
Answers and explanations are in the Veda app.
Q5.
Which of the following is a drawback of dynamic data structures?
Beginner
A
They waste memory if not fully used
B
They cannot grow in size
C
They are slower to access due to pointer traversal
D
They are simpler to implement
Answers and explanations are in the Veda app.
Q6.
In C, which function is used to deallocate dynamic memory?
Beginner
A
realloc()
B
calloc()
C
free()
D
malloc()
Answers and explanations are in the Veda app.
Q7.
Which scenario is best suited for a static data structure?
Beginner
A
Storing the 12 months of a year
B
Storing an unknown number of student records
C
Storing a list of all users in a social media app
D
Storing a dynamic feed of posts
Answers and explanations are in the Veda app.
Q8.
What is a memory leak?
Beginner
A
Memory that is allocated but never freed
B
Memory that is not contiguous
C
Memory that is freed too early
D
Memory that is allocated at compile time
Answers and explanations are in the Veda app.
Q9.
Which of the following is true about dynamic arrays (e.g., using realloc)?
Beginner
A
They cannot change size at runtime
B
They can be contiguous while still being dynamic in size
C
They are always non-contiguous
D
They are slower than linked lists for traversal
Answers and explanations are in the Veda app.
Q10.
Why do most real-world applications prefer dynamic structures?
Beginner
A
They are always faster
B
They can handle variable and large data sizes
C
They do not require memory management
D
They are simpler to implement
Answers and explanations are in the Veda app.
Q11.
Static data structures can have their values changed, but their size is fixed.
Beginner
Answers and explanations are in the Veda app.
Q12.
Dynamic data structures always use non-contiguous memory.
Beginner
Answers and explanations are in the Veda app.
Q13.
What is the fundamental difference between static and dynamic data structures?
Beginner
Answers and explanations are in the Veda app.
Q14.
Name two examples of static data structures.
Beginner
Answers and explanations are in the Veda app.
Q15.
Name two examples of dynamic data structures.
Beginner
Answers and explanations are in the Veda app.
Q16.
Why is access faster in static data structures?
Beginner
Answers and explanations are in the Veda app.
Q17.
What is a major drawback of dynamic data structures?
Beginner
Answers and explanations are in the Veda app.
Q18.
In C, which functions are used to allocate dynamic memory?
Beginner
Answers and explanations are in the Veda app.
Q19.
What is the real-life analogy for a static data structure?
Beginner
Answers and explanations are in the Veda app.
Q20.
How does a linked list store its elements?
Beginner
Answers and explanations are in the Veda app.
Q21.
Which of the following is a data item?
Beginner
A
42
B
Student record
C
A group of coordinates
D
A file of records
Answers and explanations are in the Veda app.
Q22.
What is a group item?
Beginner
A
A physical memory layout
B
A single raw value
C
A collection of related data items
D
A collection of records
Answers and explanations are in the Veda app.
Q23.
In a student record, 'Name' is an example of a:
Beginner
A
Data structure
B
Record
C
File
D
Field
Answers and explanations are in the Veda app.
Q24.
Which of the following best describes a data structure?
Beginner
A
The physical memory layout
B
A single data item
C
A collection of records
D
A logical model for organizing data
Answers and explanations are in the Veda app.
Q25.
What is the storage structure of an array?
Beginner
A
Scattered memory with pointers
B
Dynamic nodes
C
Contiguous memory
D
A logical model
Answers and explanations are in the Veda app.
Q26.
Which operation is NOT typically performed on a data structure?
Beginner
A
Search
B
Compile
C
Delete
D
Insert
Answers and explanations are in the Veda app.
Q27.
In the C code `struct Student { int roll; char name[20]; float marks; };`, what does `struct Student` represent?
Beginner
A
A file
B
A field
C
A record
D
A data item
Answers and explanations are in the Veda app.
Q28.
Which of the following is an example of a file?
Beginner
A
A roll number
B
A student's name
C
An array of student records
D
A single student record
Answers and explanations are in the Veda app.
Q29.
Why might a linked list be preferred over an array for frequent insertions?
Beginner
A
Linked lists have faster random access
B
Insertion only requires updating pointers
C
Linked lists use contiguous memory
D
Arrays cannot store records
Answers and explanations are in the Veda app.
Q30.
What is the relationship between a data structure and a storage structure?
Beginner
A
The data structure is abstract; the storage structure is concrete
B
They are the same thing
C
They are unrelated
D
The storage structure is abstract; the data structure is concrete
Answers and explanations are in the Veda app.
Q31.
Which of the following correctly orders the hierarchy from smallest to largest?
Beginner
A
Group item -> Data item -> Record -> File
B
Data item -> Group item -> Record -> File
C
File -> Record -> Group item -> Data item
D
Record -> File -> Data item -> Group item
Answers and explanations are in the Veda app.
Q32.
A data structure and its storage structure are always identical.
Beginner
Answers and explanations are in the Veda app.
Q33.
A record is a collection of fields, and a file is a collection of records.
Beginner
Answers and explanations are in the Veda app.
Q34.
Define 'data' and give an example.
Beginner
Answers and explanations are in the Veda app.
Q35.
What is a data item? Provide an example.
Beginner
Answers and explanations are in the Veda app.
Q36.
Explain the concept of a group item with an example.
Beginner
Answers and explanations are in the Veda app.
Q37.
What is a field? Give an example.
Beginner
Answers and explanations are in the Veda app.
Q38.
What is a record? Provide an example.
Beginner
Answers and explanations are in the Veda app.
Q39.
What is a file in the context of data structures?
Beginner
Answers and explanations are in the Veda app.
Q40.
Define data structure.
Beginner
Answers and explanations are in the Veda app.
Q41.
Define storage structure.
Beginner
Answers and explanations are in the Veda app.
Q42.
List four common operations on data structures.
Beginner
Answers and explanations are in the Veda app.
Q43.
Which of the following best defines a data structure?
Beginner
A
A programming language feature for loops
B
A hardware component for data storage
C
A type of algorithm for sorting numbers
D
A specialized format for organizing, storing, and managing data
Answers and explanations are in the Veda app.
Q44.
Which of the following is NOT a common operation on a data structure?
Beginner
A
Search
B
Delete
C
Insert
D
Compile
Answers and explanations are in the Veda app.
Q45.
How does an array store its elements in memory?
Beginner
A
In contiguous memory locations
B
In a hierarchical tree structure
C
In scattered memory locations with pointers
D
In a random order determined by the OS
Answers and explanations are in the Veda app.
Q46.
Which data structure uses pointers to link elements stored in scattered memory?
Beginner
A
Array
B
Linked list
C
Stack
D
Queue
Answers and explanations are in the Veda app.
Q47.
What is the main advantage of using a data structure over separate variables?
Beginner
A
It makes programs run faster without any trade-offs
B
It brings efficiency, clarity, and organization to programs
C
It uses less memory in all cases
D
It eliminates the need for algorithms
Answers and explanations are in the Veda app.
Q48.
Which access method allows direct retrieval of an element using its index?
Beginner
A
Direct
B
Random
C
Recursive
D
Sequential
Answers and explanations are in the Veda app.
Q49.
What is the relationship between data structures and algorithms?
Beginner
A
Algorithms are a type of data structure
B
Data structures organize data; algorithms manipulate data
C
They are the same concept
D
Data structures are only used in algorithms for sorting
Answers and explanations are in the Veda app.
Q50.
Which of the following is a real-world application of a stack?
Beginner
A
Undo feature in a text editor
B
Finding the shortest path in a map
C
Indexing records in a database
D
Storing contact names in a phone
Answers and explanations are in the Veda app.
Q51.
What is the main trade-off between arrays and linked lists?
Beginner
A
Arrays allow fast access by index but slow insert/delete; linked lists allow fast insert/delete but slow access by index
B
Arrays allow fast insert/delete but slow access; linked lists allow fast access but slow insert/delete
C
Arrays use more memory than linked lists
D
Linked lists use contiguous memory, making access faster
Answers and explanations are in the Veda app.
Q52.
Why is choosing the right data structure important?
Beginner
A
It makes the code shorter regardless of the task
B
It determines the programming language to use
C
It balances memory usage and performance for the required operations
D
It guarantees the program will have no bugs
Answers and explanations are in the Veda app.
Q53.
Which data structure is best suited for implementing a navigation app that finds the shortest route?
Beginner
A
Queue
B
Graph
C
Array
D
Stack
Answers and explanations are in the Veda app.
Q54.
What is a key characteristic of a data structure's formal definition?
Beginner
A
It only describes the data values, not the operations
B
It defines how data is grouped, what operations are allowed, and how data is stored in memory
C
It determines the algorithm's time complexity
D
It specifies the programming language used
Answers and explanations are in the Veda app.
Q55.
A linked list stores elements in contiguous memory locations.
Beginner
Answers and explanations are in the Veda app.
Q56.
Data structures and algorithms are the same concept.
Beginner
Answers and explanations are in the Veda app.
Q57.
Define a data structure in your own words.
Beginner
Answers and explanations are in the Veda app.
Q58.
List the four key components of a data structure.
Beginner
Answers and explanations are in the Veda app.
Q59.
Name five common operations that can be performed on a data structure.
Beginner
Answers and explanations are in the Veda app.
Q60.
What are the three access methods for data structures?
Beginner
Answers and explanations are in the Veda app.
Q61.
What are the benefits of using data structures in programming?
Beginner
Answers and explanations are in the Veda app.
Q62.
How does an array allow direct access to its elements?
Beginner
Answers and explanations are in the Veda app.
Q63.
Which of the following is a linear data structure?
Beginner
A
Queue
B
Graph
C
Tree
D
Trie
Answers and explanations are in the Veda app.
Q64.
Which data structure uses LIFO (Last In, First Out) principle?
Beginner
A
Stack
B
Queue
C
Array
D
Linked List
Answers and explanations are in the Veda app.
Q65.
In a linear data structure, each element (except the first and last) has:
Beginner
A
At least two successors
B
No predecessor or successor
C
Multiple predecessors and successors
D
Exactly one predecessor and one successor
Answers and explanations are in the Veda app.
Q66.
Which of the following is a non-linear data structure?
Beginner
A
Stack
B
Array
C
Graph
D
Queue
Answers and explanations are in the Veda app.
Q67.
What is the primary characteristic of a non-linear data structure?
Beginner
A
Elements are arranged hierarchically or as a graph
B
Elements are arranged sequentially
C
Elements have only one predecessor
D
Elements are stored in contiguous memory
Answers and explanations are in the Veda app.
Q68.
Which real-world scenario best represents a queue data structure?
Beginner
A
A family tree
B
Undo operations in a text editor
C
People waiting in a line
D
A road map
Answers and explanations are in the Veda app.
Building up
· 33 questions
Q69.
What does 'static' refer to in a static data structure?
Intermediate
Answers and explanations are in the Veda app.
Q70.
When should you prefer a static data structure?
Intermediate
Answers and explanations are in the Veda app.
Q71.
What is a common risk when using dynamic structures?
Intermediate
Answers and explanations are in the Veda app.
Q72.
What is the trade-off between static and dynamic structures?
Intermediate
Answers and explanations are in the Veda app.
Q73.
Why do most real-world applications prefer dynamic structures?
Intermediate
Answers and explanations are in the Veda app.
Q74.
A developer needs to store a fixed set of sensor readings collected every second for exactly 60 seconds. Which data structure would be most appropriate and why?
Intermediate
A
A linked list, because it uses non-contiguous memory and is more flexible.
B
A static array, because the size is known in advance and access is faster.
C
A linked list, because it allows dynamic resizing if more readings are added.
D
A dynamic array, because it uses contiguous memory and can grow if needed.
Answers and explanations are in the Veda app.
Q75.
Which of the following best explains why accessing an element in a static array is faster than in a linked list?
Intermediate
A
Static arrays use pointers to directly locate any element.
B
Static arrays store elements contiguously, enabling direct arithmetic to compute an element's address.
C
Static arrays store elements in non-contiguous memory, allowing parallel access.
D
Static arrays allocate memory at compile time, so the CPU can cache the entire array.
Answers and explanations are in the Veda app.
Q76.
A programmer uses `malloc()` to create a linked list node but forgets to call `free()` after the node is no longer needed. What is the most likely consequence?
Intermediate
A
The node's data will be automatically overwritten by the next allocation.
B
The compiler will automatically free the memory at the end of the function.
C
The memory remains allocated but is no longer accessible, leading to a memory leak.
D
The program will crash immediately due to a segmentation fault.
Answers and explanations are in the Veda app.
Q77.
Which of the following scenarios would most likely require a dynamic data structure?
Intermediate
A
Storing the days of the week in a program that always uses exactly 7 days.
B
Storing user-generated posts on a social media platform where the number of posts changes constantly.
C
Storing the coordinates of a fixed 10x10 game board.
D
Storing the monthly sales figures for a company that has been in business for 10 years.
Answers and explanations are in the Veda app.
Q78.
A dynamic array (e.g., using `realloc` in C) can be resized at runtime. Which of the following statements correctly describes its memory layout?
Intermediate
A
It uses contiguous memory, but resizing may require copying all elements to a new memory block.
B
It always uses non-contiguous memory to allow easy resizing.
C
It uses a mix of contiguous and non-contiguous memory depending on the data type.
D
It uses contiguous memory only when the array is small; larger arrays become non-contiguous.
Answers and explanations are in the Veda app.
Q79.
In the C struct `struct Student { int roll; char name[20]; float marks; };`, identify the fields.
Intermediate
Answers and explanations are in the Veda app.
Q80.
In the C struct `struct Student { int roll; char name[20]; float marks; };`, what does the struct represent?
Intermediate
Answers and explanations are in the Veda app.
Q81.
How would you represent a file of student records in C?
Intermediate
Answers and explanations are in the Veda app.
Q82.
Explain the difference between a data structure and a storage structure.
Intermediate
Answers and explanations are in the Veda app.
Q83.
Give an example of a logical data structure that can have multiple storage structures.
Intermediate
Answers and explanations are in the Veda app.
Q84.
In the C struct `struct Student { int roll; char name[20]; float marks; };`, which of the following correctly identifies the roles of `roll`, `name`, and `marks`?
Intermediate
A
They are data items because each stores a single value.
B
They are fields because each is a single attribute of a record.
C
They are records because they together describe a student.
D
They are group items because they are related data items.
Answers and explanations are in the Veda app.
Q85.
Which of the following best explains why a linked list is often preferred over an array for frequent insertions and deletions?
Intermediate
A
A linked list requires only updating pointers for insertion/deletion, not shifting elements.
B
A linked list uses contiguous memory, making insertion faster.
C
A linked list allows direct access to any element by index.
D
A linked list always uses less memory than an array.
Answers and explanations are in the Veda app.
Q86.
Given the logical data structure 'stack', which of the following statements about its storage structure is correct?
Intermediate
A
A stack can only be implemented using an array.
B
The storage structure of a stack is always contiguous memory.
C
A stack can be implemented using either an array or a linked list, with different trade-offs.
D
The storage structure of a stack is determined by the logical model.
Answers and explanations are in the Veda app.
Q87.
In a library catalog, each book is represented with fields like title, author, and ISBN. The entire catalog is a collection of all such book entries. Which term best describes the entire catalog?
Intermediate
A
A data item
B
A group item
C
A file
D
A record
Answers and explanations are in the Veda app.
Q88.
Why is the choice of storage structure important for the performance of operations on a data structure?
Intermediate
A
Because the storage structure is always fixed for a given data structure.
B
Because different storage structures have different time and space trade-offs for operations like access and insertion.
C
Because the storage structure determines the data type of the elements.
D
Because the logical model changes based on the storage structure.
Answers and explanations are in the Veda app.
Q89.
Explain the difference between contiguous and scattered memory storage.
Intermediate
Answers and explanations are in the Veda app.
Q90.
Why are data structures important for program efficiency?
Intermediate
Answers and explanations are in the Veda app.
Q91.
What is the difference between a data structure and an algorithm?
Intermediate
Answers and explanations are in the Veda app.
Q92.
Describe the trade-off between arrays and linked lists.
Intermediate
Answers and explanations are in the Veda app.
Q93.
Give two real-world applications of data structures and identify the data structure used.
Intermediate
Answers and explanations are in the Veda app.
Q94.
What are the formal characteristics of a data structure?
Intermediate
Answers and explanations are in the Veda app.
Q95.
Explain how a stack is used in an undo feature.
Intermediate
Answers and explanations are in the Veda app.
Q96.
What is the role of storage representation in a data structure?
Intermediate
Answers and explanations are in the Veda app.
Q97.
A programmer needs to store a collection of student records and frequently insert new records at the beginning of the collection. Which data structure would be most efficient for this operation, and why?
Intermediate
A
Hash table, because it provides constant-time lookup.
B
Stack, because it follows LIFO order.
C
Array, because it allows direct access by index.
D
Linked list, because insertion at the head only requires updating a few pointers.
Answers and explanations are in the Veda app.
Q98.
Consider the following scenario: You need to implement a feature that finds the shortest path between two locations in a city. Which data structure is most appropriate to model the city's road network?
Intermediate
A
Graph
B
Linked list
C
Stack
D
Array
Answers and explanations are in the Veda app.
Q99.
Which of the following best explains the relationship between a data structure and an algorithm?
Intermediate
A
An algorithm defines how data is stored, while a data structure defines how to manipulate it.
B
A data structure is a step-by-step procedure, while an algorithm is the organization of data.
C
A data structure organizes data, and an algorithm is a procedure that operates on that data.
D
They are interchangeable terms for the same concept.
Answers and explanations are in the Veda app.
Q100.
A developer is choosing between an array and a linked list to store a list of tasks. The tasks are frequently searched by their position (e.g., the 5th task), but rarely inserted or deleted. Which data structure is more suitable, and why?
Intermediate
A
Array, because it uses less memory for pointers.
B
Linked list, because it supports efficient traversal.
C
Linked list, because it uses pointers for flexibility.
D
Array, because it allows direct access by index in O(1) time.
Answers and explanations are in the Veda app.
Q101.
In the context of data structures, what does 'storage representation' refer to?
Intermediate
A
The algorithm used to sort the data.
B
How data is physically laid out in memory, such as contiguous or scattered.
C
The set of operations that can be performed on the data.
D
The logical relationship between data elements.
Answers and explanations are in the Veda app.
Topper level
· 19 questions
Q102.
What is a memory leak?
Advanced
Answers and explanations are in the Veda app.
Q103.
Can a dynamic structure use contiguous memory? Give an example.
Advanced
Answers and explanations are in the Veda app.
Q104.
A developer is designing a system to store sensor readings from a high-frequency data acquisition device. The device produces exactly 1,000 readings per second, and the system must process each batch of 1,000 readings within a strict 10-millisecond deadline. The readings are processed sequentially, and the size never changes. Which data structure should the developer choose, and why?
Advanced
A
A dynamic array (using `realloc`) because it can be resized if the sensor frequency changes.
B
A dynamic structure like a hash table because it provides faster lookup than an array.
C
A linked list because it allows O(1) insertion at the tail.
D
A static array because it provides O(1) access and avoids runtime allocation overhead, ensuring the strict deadline is met.
Answers and explanations are in the Veda app.
Q105.
Consider the following C code snippet:
```c
int *arr = (int*) malloc(10 * sizeof(int));
arr = (int*) realloc(arr, 20 * sizeof(int));
free(arr);
```
Which of the following statements correctly describes the memory behavior of this dynamic array?
Advanced
A
The `realloc` function may extend the existing memory block in place or move it to a new location; in either case, the logical order of elements is preserved.
B
After `realloc`, the array becomes non-contiguous, so accessing elements requires pointer traversal.
C
The `realloc` function always moves the array to a new memory location, leaving the original block untouched.
D
The `free(arr)` call only deallocates the memory allocated by the original `malloc`, not the resized block.
Answers and explanations are in the Veda app.
Q106.
A programmer needs to implement a function that processes a list of integers. The list is built by reading integers from a file until the end of the file is reached. The number of integers is unknown in advance. The programmer decides to use a linked list. Which of the following is the most significant trade-off of this choice compared to using a dynamic array?
Advanced
A
The linked list allocates memory at compile time, making it faster to create nodes.
B
The linked list cannot be resized at runtime, so it is unsuitable for unknown input sizes.
C
The linked list provides O(1) access to any element, which is faster than a dynamic array.
D
The linked list uses more memory per element due to the pointer field, and accessing the i-th element requires O(n) time.
Answers and explanations are in the Veda app.
Q107.
A developer is writing a program that needs to store a fixed set of configuration parameters (e.g., 10 integer values) that are read at startup and never change in size. The program is running on a memory-constrained embedded system. Which of the following statements best justifies using a static array over a dynamic structure?
Advanced
A
A static array uses non-contiguous memory, which reduces fragmentation on the embedded system.
B
A static array allows the program to allocate memory only when needed, saving memory when the configuration is small.
C
A static array can be resized at runtime if the configuration changes, providing flexibility.
D
A static array avoids the overhead of runtime memory allocation, reducing the risk of memory leaks and ensuring predictable memory usage.
Answers and explanations are in the Veda app.
Q108.
A software engineer is designing a text editor that must support undo/redo operations. The number of undo steps is limited to 50, and each step stores a snapshot of the document. The engineer initially uses a linked list to store the snapshots but notices that accessing the most recent snapshot (the last element) is slow. Which of the following changes would best improve the performance of accessing the most recent snapshot while still respecting the fixed limit of 50 steps?
Advanced
A
Use a dynamic array that grows without bound to store all snapshots, ensuring O(1) access to the last element.
B
Use a static array of size 50 but shift all elements on each new snapshot to keep the most recent at the front.
C
Keep the linked list but add a pointer to the last node, allowing O(1) access to the most recent snapshot.
D
Replace the linked list with a static array of size 50, using a circular buffer to overwrite the oldest snapshot when full.
Answers and explanations are in the Veda app.
Q109.
Why is the choice of storage structure important for performance?
Advanced
Answers and explanations are in the Veda app.
Q110.
Consider the following C code snippet:
```c
struct Point {
int x;
int y;
};
struct Point p1 = {3, 4};
struct Point p2 = {5, 6};
struct Point points[2] = {p1, p2};
```
In the context of data structure terminology, which of the following statements is **most accurate**?
Advanced
A
`points` is a record, `p1` and `p2` are fields, and `x` and `y` are data items.
B
`points` is a storage structure, `p1` and `p2` are files, and `x` and `y` are records.
C
`points` is a file, `p1` and `p2` are records, and `x` and `y` are fields.
D
`points` is a data structure, `p1` and `p2` are group items, and `x` and `y` are data items.
Answers and explanations are in the Veda app.
Q111.
A developer is designing a system to store a collection of employee records. Each record has fields: `emp_id`, `name`, and `salary`. The system must support frequent insertions and deletions of records in the middle of the collection, and also occasional searches by `emp_id`. Which storage structure is **most appropriate** for this scenario, and why?
Advanced
A
An array, because it provides O(1) random access for searches by `emp_id` and supports insertions/deletions in O(1) time.
B
A hash table, because it provides O(1) insertions, deletions, and searches, and also maintains the order of records.
C
A linked list, because insertions and deletions in the middle are O(1) once the position is known, and searches can be done by traversing.
D
A binary search tree, because it provides O(log n) insertions, deletions, and searches, and also allows efficient in-order traversal.
Answers and explanations are in the Veda app.
Q112.
A data structure is defined as a stack, and it is implemented using an array. Which of the following statements correctly describes the relationship between the data structure and the storage structure?
Advanced
A
The data structure is the array, and the storage structure is the stack, because the array is the physical implementation.
B
The data structure and storage structure are identical because the stack is always implemented as an array.
C
The data structure is the abstract logical model (stack) with LIFO behavior, and the storage structure is the array that physically stores the elements.
D
The data structure is the stack, and the storage structure is the LIFO behavior, because the behavior defines the storage.
Answers and explanations are in the Veda app.
Q113.
In a database system, a table `Students` has columns `id`, `name`, and `gpa`. Each row represents a student. Which of the following statements is **correct** in terms of data structure terminology?
Advanced
A
Each row is a file, each column is a record, and the entire table is a data structure.
B
Each row is a group item, each column is a data item, and the entire table is a record.
C
Each row is a data item, each column is a field, and the entire table is a group item.
D
Each row is a record, each column is a field, and the entire table is a file.
Answers and explanations are in the Veda app.
Q114.
A programmer needs to store a collection of 2D points. Each point has two coordinates, `x` and `y`. The programmer defines a structure `Point` and then creates an array of `Point` objects. Which of the following statements is **most accurate**?
Advanced
A
The structure `Point` is a record, each instance is a record, and the array is a file.
B
The structure `Point` is a group item, each instance is a data item, and the array is a storage structure.
C
The structure `Point` is a field, each instance is a group item, and the array is a record.
D
The structure `Point` is a data structure, each instance is a record, and the array is a file.
Answers and explanations are in the Veda app.
Q115.
Why is choosing the right data structure important?
Advanced
Answers and explanations are in the Veda app.
Q116.
A software engineer is designing a system to store a dynamic collection of student records. The system must support frequent insertions at the beginning of the collection, but also needs to allow binary search on the records. Which approach best satisfies both requirements, and why?
Advanced
A
Use a hash table to store records, and sort the keys when binary search is needed.
B
Use an array and shift all elements right on each insertion at the beginning, then use binary search on the array.
C
Use a linked list for O(1) insertions at the head, and implement binary search by traversing the list to the midpoint each time.
D
Use a balanced binary search tree (e.g., AVL tree) to maintain sorted order with O(log n) insertions and O(log n) search.
Answers and explanations are in the Veda app.
Q117.
Consider a navigation system that models a city's road network. The system must find the shortest path between two locations, and also frequently update road weights (e.g., due to traffic). Which data structure and algorithm combination is most appropriate, and why?
Advanced
A
Use an adjacency list and Dijkstra's algorithm with a binary heap priority queue.
B
Use a hash table to store edges and perform a depth-first search for the shortest path.
C
Use a linked list of edges and apply Bellman-Ford algorithm without any priority queue.
D
Use an adjacency matrix and Dijkstra's algorithm with a simple array-based priority queue.
Answers and explanations are in the Veda app.
Q118.
A developer needs to implement an undo feature in a text editor. The editor must support undoing the most recent action, but also allow the user to redo an action after undoing. Which data structure(s) would be most appropriate, and what is the trade-off?
Advanced
A
Use a single stack for undo; redo is not possible with a single stack.
B
Use a queue for undo and a stack for redo, allowing FIFO undo order.
C
Use two stacks: one for undo and one for redo. When an undo occurs, the action is pushed onto the redo stack; when a new action is performed, the redo stack is cleared.
D
Use an array to store all actions and a pointer to the current position, but this requires shifting elements on undo.
Answers and explanations are in the Veda app.
Q119.
A programmer is comparing an array and a linked list for storing a list of tasks. The tasks are frequently accessed by their position (e.g., the 5th task), but insertions and deletions are rare. Which data structure is more suitable, and what is the time complexity for accessing the 5th task in each?
Advanced
A
Array, because accessing the 5th task is O(log n) using binary search, while linked list access is O(n).
B
Array, because accessing the 5th task is O(1) via index, while linked list access is O(n) due to traversal.
C
Linked list, because insertions and deletions are rare, so the overhead of pointers is negligible, and access is O(1) with a tail pointer.
D
Linked list, because accessing the 5th task is O(1) if you maintain a pointer to the 5th node, while array access is O(n) due to shifting.
Answers and explanations are in the Veda app.
Q120.
In the formal definition of a data structure, which of the following correctly describes the relationship between storage representation and the operations allowed?
Advanced
A
Storage representation is independent of operations; any storage layout can support any operation with the same efficiency.
B
Operations are defined solely by the logical grouping of data, and storage representation only affects memory usage, not operation speed.
C
Storage representation determines the efficiency of operations; for example, contiguous storage enables O(1) index access, while scattered storage requires traversal for access.
D
Storage representation is only relevant for linked structures; arrays do not have a storage representation.
Answers and explanations are in the Veda app.