13. What is a structure?
Answer:
A structure is a user-defined data type that allows us to group different types of data under one name.
13. What is a stack?
Answer:
A stack is a linear data structure in which insertion and deletion take place from the same end, called the top.
A stack follows the principle:
LIFO – Last In, First Out
This means the element inserted last is removed first.
13.What is a queue?
Answer:
A queue is a linear data structure in which insertion and deletion take place at different ends.
A queue follows:
FIFO – First In, First Out
The element inserted first is removed first.
13. What is a linked-list?
Answer:
A linked list is a linear data structure in which elements are stored in separate nodes. The nodes are connected using pointers.
Unlike an array, the elements of a linked list do not have to occupy consecutive memory locations.
Each node generally contains:
- Data
- A pointer to the next node
13. What is a tree?
Answer:
A tree is a non-linear data structure in which data elements are arranged in a hierarchical manner.
A tree consists of nodes connected by edges.
Trees are commonly used to represent hierarchical information.
Examples include:
- File and folder systems
- Organization structures
- Family trees
- Searching and sorting applications
13. What is a graph?
Answer:
A graph is another important non-linear data structure. It consists of a collection of vertices (or nodes) connected by edges.
For example:
Graphs can be used to represent:
- Road networks
- Computer networks
- Social networks
- Connections between web pages
13. What is the difference between linear and non-linear data structures?
Answer:
Linear | Non-Linear |
Elements are arranged sequentially. | Elements are arranged hierarchically or as networks. |
Generally, each element has a single next element. | An element may be connected to multiple elements. |
Traversal is usually sequential. | Traversal can follow different paths. |
Examples: Array, Stack, Queue, Linked List | Examples: Tree, Graph |