Sample questions
Question 1Medium
Which data structure is used to perform recursion?
- Queue
- Linked List.
- Tree
- Stack
Answer: D. Stack
Explanation
The answer is Stack.
Stack has the LIFO (Last In First Out) property.it remembers it's caller. Therefore, it knows to whom it should return when the function has to return. On the other hand, recursion makes use of the system stack for storing the return addresses of the function calls.
Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written explicit, stack is to be used.
Step-by-step solution
- Recursion requires storing return addresses.
- Stack follows LIFO and stores return addresses.
- Stack helps track function calls in recursion.
- Stack is used for managing recursive calls.
- Final answer: Stack.
Why the other options are wrong
- A. Queue follows FIFO and cannot store return addresses.
- B. Linked List is for dynamic data storage, not recursion.
- C. Tree is for hierarchical data, not recursion.
Tip: Remember: Stack is used in recursion due to its LIFO property.
Question 2Medium
- Way to organize data
- Accessing of data elements in specified manner
- Organization of mathematical and logical concepts
- All of Above
Answer: D. All of Above
Explanation
A Data Structure may be organized in different ways: The logical or mathematical model of a particular organization of data is called Data Structure
Step-by-step solution
- A data structure is a way to organise data.
- It allows data elements to be accessed in a specified manner.
- It is a logical or mathematical model of that organisation. All three parts are true, so the correct answer is All of above (option D).
Why the other options are wrong
- A. True, but it is only one part of the full definition.
- B. True, but it is only one part of the full definition.
- C. True, but it is only one part of the full definition.
Tip: When each option is a true part of the definition, 'all of above' is the answer.
Question 3Medium
List out the areas in which data structures are applied extensively.
- Compiler Design
- Operating System
- Database Management System
- (a), (b) and (c) above.
Answer: D. (a), (b) and (c) above.
Explanation
As the data structure can be used in all the application areas right from the compiler design to operating systems and even in database management system design.
Step-by-step solution
- Compiler Design uses stacks for expression parsing.
- Operating System uses queues for task scheduling.
- Database Management System uses trees for indexing.
- All three areas use data structures extensively.
- Therefore, the correct answer is (a), (b) and (c) above.
Why the other options are wrong
- A. Compiler Design alone does not cover all areas.
- B. Operating System alone does not cover all areas.
- C. Database Management System alone does not cover all areas.
Tip: Remember that data structures are used in multiple fields like compilers, OS, and databases.
Question 4Medium
Which of the following data structure store the nonhomogeneous data elements?
- Arrays
- Records
- Pointers
- None
Answer: B. Records
Explanation
A record is a special type of data structure that, unlike arrays, collects different data types that define a particular structure such a book, product, person and many others. The programmer defines the data structure under the Type user definition.
Let us take the case of defining a book using a record data structure. The main entities of a book are its title, author, unique ISBN number and its price. This is how it is defined in Pascal and in most other programming languages:
Type
Str25 = String[25];
TBookRec = Record
Title, Author,
ISBN: Str25;
Price: Real;
End;
Var myBookRec: TBookRec;
Step-by-step solution
- Records can hold different data types like title, author, ISBN and price.
- Arrays store only similar data types such as all integers or all strings.
- Pointers refer to memory addresses but do not store nonhomogeneous data directly.
- None is incorrect because records are designed for nonhomogeneous data.
- Correct answer is Records.
Why the other options are wrong
- A. Arrays can only store similar data types.
- C. Pointers do not store data elements but memory addresses.
- D. Records are the correct answer for nonhomogeneous data.
Tip: Use records when you need to store mixed data types like title, author, price etc.
Question 5Medium
When new data are to be inserted into a data structure, but there is no available space; this situation is usually called
- underflow
- overflow
- housefull
- saturated
Answer: B. overflow
Explanation
A stack overflow occurs when the on--chip stack capacity is exceeded. This can be detected by a comparison of the top-pointer, the last-pointer and the index specified for a create-frame operation (for push).
Step-by-step solution
- Inserting data when no space is available causes overflow.
- Overflow happens when storage capacity is exceeded.
- This situation is called overflow.
- Overflow is the correct term for this scenario.
- The answer is overflow.
Why the other options are wrong
- A. Underflow refers to removing data when none is present.
- C. Housefull is not a technical term used in data structures.
- D. Saturated is not a standard term for this situation.
Tip: Remember overflow refers to exceeding storage capacity.
Question 6Medium
Which of the following data structures are indexed structures?
- linear arrays
- linked lists
- both of above
- none of above
Answer: A. linear arrays
Explanation
A Linear Array is a list of finite number of n homogeneous data elements i.e. the elements of same data types. All arrays are linear data structures, as are all lists. Arrays are linear because multiple elements are allocated in contiguous memory.
If the array is a pointer array, only the pointer array need be contiguous; the data being pointed at can reside anywhere in memory, whether contiguous or not (you might use a separate pointer array to indirectly alter the order of elements in another array). Large and dynamic multi-dimensional arrays are typically allocated as a large array of pointers each of which points to a small array of data elements.
For instance, a four-dimensional array might be allocated as a contiguous three-dimensional array of pointers, each of which points to a separately allocated one-dimensional array of data elements. Although this uses more memory overall to cater for all the pointer variables, allocating separate memory to each one-dimensional array is more likely to succeed than if all the elements were allocated as a contiguous multi-dimensional array, especially if the individual data elements are quite large.
Step-by-step solution
- Linear arrays store elements in contiguous memory locations.
- Each element has a fixed index for direct access.
- Linked lists use pointers to connect nodes, not indexes.
- So only linear arrays are indexed structures.
Why the other options are wrong
- B. Linked lists are not indexed as they use pointers, not positions.
- C. Only linear arrays are indexed, not both.
- D. Linear arrays are indexed, so this is wrong.
Tip: Remember: only arrays are indexed data structures.
Question 7Medium
Which operation is not possible on Data Structure?
- Traversing
- Insertion
- Reading
- Deletion
Answer: C. Reading
Explanation
Possible operations on the Data Structure are Traversing, Insertion, Searching and Deletion.
Step-by-step solution
- The standard operations on a data structure are traversing, insertion, searching and deletion.
- Reading is not one of these operations, so it is the one that is not possible.
- Marked answer: Reading (option C).
Why the other options are wrong
- A. Traversing visits each element; it is a standard operation.
- B. Insertion adds an element; it is a standard operation.
- D. Deletion removes an element; it is a standard operation.
Tip: Core operations: traverse, insert, search, delete.
Question 8Medium
Which of the following data structure is the best example for the multitasking systems?
- Tree
- Queue
- Stack
- Linked List
Answer: B. Queue
Explanation
Because a queue is used to hold the jobs which are waiting for their turn to work with the common processor.
Step-by-step solution
- A multitasking system shares one processor among jobs that wait their turn.
- Waiting jobs are served in arrival order, first come first served.
- A queue holds waiting jobs in this order. Marked answer: Queue (option B).
Why the other options are wrong
- A. A tree shows a hierarchy; it does not hold waiting jobs in order.
- C. A stack serves the newest job first, not in arrival order.
- D. A linked list stores items but does not define a first-come waiting order by itself.
Tip: Jobs waiting for their turn point to a queue.
Question 9Medium
A list which displays the relationship of adjacency between elements is said to be
- linear
- non linear
- linked list
- trees
Answer: A. linear
Explanation
A list that displays the relationship of adjacency between elements (nodes) is said to be linear list.
Step-by-step solution
- A list where each element has one predecessor and one successor shows adjacency in a line.
- Such a list is a linear list.
- Marked answer: linear (option A).
Why the other options are wrong
- B. A non-linear structure, such as a tree or graph, has branching relationships.
- C. A linked list is one way to store a linear list, not the name of the relationship.
- D. Trees are non-linear structures.
Tip: One predecessor and one successor means linear.
Question 10Medium
The OS of a computer may periodically collect all the free memory space to form contiguous block of free space. This is called
- Concatenation
- Garbage collection
- Collision
- Dynamic Memory Allocation
Answer: B. Garbage collection
Explanation
In order to use memory, programs conduct an action called "allocation" where part of the memory is set aside for a particular use. The C malloc() function and its counter part calloc() are used to allocate memory.
When this memory is no longer needed, it is freed with the free() function.
The prototypes for both functions are available in stdlib.h.
However, as memory is allocated and freed in various locations, the memory can become fragmented. Sometimes requests to allocate memory will fail as a result.
The areas that are causing the allocation problems are referred to as "garbage" for historic reasons. "Garbage collection" is the process of moving allocated memory around to make larger contiguous blocks available (like defragmenting your hard disk).
However, due to very low priority for C and C++.
Step-by-step solution
- Garbage collection frees unused memory.
- It reorganizes memory to create large free spaces.
- This process is called garbage collection.
- Unused memory is moved to form contiguous blocks.
- The correct term for this process is garbage collection.
Why the other options are wrong
- A. Concatenation refers to joining strings, not memory management.
- C. Collision is related to networking, not memory.
- D. Dynamic Memory Allocation is the process of allocating memory, not cleaning it.
Tip: Remember garbage collection is about cleaning up unused memory to make larger blocks available.
Practise all 16 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →