Data Structures SQA
Data Structures SQA
Linear: A data structure is said to be linear if its elements form a sequence or a linear list.
Examples: Array. Linked List, Stacks and Queues.
Non-Linear: A data structure is said to be non-linear if the traversal of nodes is nonlinear in nature.
Example: Graph and Trees.
4. What are the various operations that can be performed on different Data Structures?
• Insertion: Add a new data item in the given collection of data items.
• Deletion: Delete an existing data item from the given collection of data items.
• Traversal: Access each data item exactly once so that it can be processed.
• Searching: Find out the location of the data item if it exists in the given collection of data items.
• Sorting: Arranging the data items in some order i.e. in ascending or descending order in case of numerical
data and in dictionary order in case of alphanumeric data.
The complexity of an algorithm is the function which gives the running time and /or space in terms of the input
size. It describes the efficiency of the algorithm in terms of the amount of data the algorithm must process. There
are two main complexity measures of the efficiency of an algorithm:
• Time complexity
• Space complexity
• The size of the arrays is fixed, Linked Lists are Dynamic in size.
• Inserting and deleting a new element in an array of elements is expensive, whereas both insertion and
deletion can easily be done in Linked Lists.
• Random access is not allowed in Linked Listed.
• Extra memory space for a pointer is required with each element of the Linked list.
• Arrays have better cache locality that can make a pretty big difference in performance.
7. What are the control structures available in DS?
8. What is a Queue, how it is different from the stack and how is it implemented?
Queue is a linear structure that follows the order is First in First Out (FIFO) to access elements. Mainly the
following are basic operations on queue: Enqueue, Dequeue, Front, Rear.
The difference between stacks and queues is in removing. In a stack we remove the item the most recently
added; in a queue, we remove the item the least recently added. Both Queues and Stacks can be implemented
using Arrays and Linked Lists.
Infix notation: X + Y – Operators are written in-between their operands. This is the usual way we write
expressions. An expression such as
A*(B+C)/D
Postfix notation (also known as “Reverse Polish notation”): X Y + Operators are written after their operands.
The infix expression given above is equivalent to
A B C + * D/
Prefix notation (also known as “Polish notation”): + X Y Operators are written before their operands. The
expressions given above are equivalent to
/*A+BCD
A linked list is a linear data structure (like arrays) where each element is a separate object. Each element (that is
node) of a list is comprising of two items – the data and a reference to the next node. Types of Linked List are:
Singly Linked List: In this type of linked list, every node stores address or reference of next node in list and the
last node has next address or reference as NULL.
Doubly Linked List: Here, here are two references associated with each node, One of the reference points to
the next node and one to the previous node.
Circular Linked List: Circular linked list is a linked list where all nodes are connected to form a circle. There
is no NULL at the end. A circular linked list can be a singly circular linked list or doubly circular linked list.
11. Which data structures are used for BFS and DFS of a graph?
12. What is the difference between a File Structure and a Data Structure?
• Substring
• Indexing
• Concatenation
• Length
Following are some of the scenarios where data structures are widely used:
• Numerical computation
• Operating system design
• Artificial Intelligence
• Compiler design
• Database handling
• Lexical analysis
• Statistics
18. What are the types of searching used in Data Structures?
The two primary methods of searching are linear search and binary search. Linear search involves iterating over
a data unit in order to perform the required operation. Binary search is more efficient in a way that it has the
ability to split the data unit into chunks and then perform a search operation.
Memory Allocation
The maintenance of linked lists in memory assumes the possibility of inserting new nodes into the lists and hence
requires some mechanism which provides unused memory space for the new nodes.
Garbage Collection
Suppose some memory space becomes reusable because a node is deleted from a list or an entire list is deleted
from a program. Clearly, we want the space to be available for future use. One way to bring this about is to
immediately reinsert the space into the free-storage list.
Underflow
Underflow refers to the situation where one wants to delete data from a data structure that is empty. Underflow
will occur in linked lists when START= NULL and there is a deletion.
A grounded header list is a header list where the last node contains the null pointer.
A circular header list is a header list where the last node points back to the header node.
- in the usual forward direction from the beginning of the list to the end.
- in the backward direction from the end of the list to the beginning.
32. What is the difference between void and null in Data Structures?
Void is a data type identifier in data structures, while null is considered to be a value with no physical presence.
When void is used, it indicates that there is no size while initializing the data structure.
43. What are the Data Structures that are used in graphs?
To implement graphs, two data structures play a key role. They are:
Adjacency matrix: Used for sequential data representation
Adjacency list: Used to represent linked data
44. What are the Data Structures that are used in DFS and BFS algorithms?
In the depth-first search (DFS), the stack data structure is made use of. In the case of the breadth-first search
(BFS) technique, queues are used.
Array sizing: The queue has to be constantly extended to make way for more elements that get implemented.
Always extending the size of the array will not be feasible as there will be a discrepancy in the creation of the
correct array size.
Memory dumps: The memory that is used to store the queue elements cannot be reused to actually store the
queue. This is because of the working of queues where insertion happens at the head node only.