Question: What is Data Structure?
Introduction to Data Structure
- Computer is an electronic machine which is used for data processing and manipulation.
- When programmer collects such type of data for processing, he would require to store all of them in computer’s main memory.
- In order to make computer work we need to know
- Representation of data in computer.
- Accessing of data.
- How to solve problem step by step.
- For doing this task we use data structure.
What is Data Structure?
- Data structure is a representation of the logical relationship existing between individual elements of data.
- Data Structure is a way of organizing all data items that considers not only the elements stored but also their relationship to each other.
- We can also define data structure as a mathematical or logical model of a particular organization of data items.
- The representation of particular data structure in the main memory of a computer is called as storage structure.
- The storage structure representation in auxiliary memory is called as file structure.
- It is defined as the way of storing and manipulating data in organized form so that it can be used efficiently.
- Data Structure mainly specifies the following four things
- Organization of Data
- Accessing methods
- Degree of associativity
- Processing alternatives for information
- Algorithm + Data Structure = Program
- Data structure study covers the following points
- Amount of memory require to store.
- Amount of time require to process.
- Representation of data in memory.
- Operations performed on that data.
Classification of Data Structure:
Data Structures are normally classified into two broad categories:
- Primitive Data Structure
- Non-primitive data Structure
Data types
A particular kind of data item, as defined by the values it can take, the programming language used, or the operations that can be performed on it.
Primitive Data Structure
- Primitive data structures are basic structures and are directly operated upon by machine instructions.
- Primitive data structures have different representations on different computers.
- Integers, floats, character and pointers are examples of primitive data structures.
- These data types are available in most programming languages as built in type.
- Integer: It is a data type which allows all values without fraction part. We can use it for whole numbers.
- Float: It is a data type which use for storing fractional numbers.
- Character: It is a data type which is used for character values.
Pointer: A variable that holds memory address of another variable are called pointer.
Non primitive Data Type
- These are more sophisticated data structures.
- These are derived from primitive data structures.
- The non-primitive data structures emphasize on structuring of a group of homogeneous or heterogeneous data items.
- Examples of Non-primitive data type are Array, List, and File etc.
- A Non-primitive data type is further divided into Linear and Non-Linear data structure
- Array: An array is a fixed-size sequenced collection of elements of the same data type.
- List: An ordered set containing variable number of elements is called as Lists.
- File: A file is a collection of logically related information. It can be viewed as a large list of records consisting of various fields.
Linear data structures
- A data structure is said to be Linear, if its elements are connected in linear fashion by means of logically or in sequence memory locations.
- There are two ways to represent a linear data structure in memory,
- Static memory allocation
- Dynamic memory allocation
- The possible operations on the linear data structure are: Traversal, Insertion, Deletion, Searching, Sorting and Merging.
- Examples of Linear Data Structure are Stack and Queue.
- Stack: Stack is a data structure in which insertion and deletion operations are performed at one end only.
- The insertion operation is referred to as ‘PUSH’ and deletion operation is referred to as ‘POP’ operation.
- Stack is also called as Last in First out (LIFO) data structure.
- Queue: The data structure which permits the insertion at one end and Deletion at another end, known as Queue.
- End at which deletion is occurs is known as FRONT end and another end at which insertion occurs is known as REAR end.
- Queue is also called as First in First out (FIFO) data structure.
Nonlinear data structures
- Nonlinear data structures are those data structure in which data items are not arranged in a sequence.
- Examples of Non-linear Data Structure are Tree and Graph.
- Tree: A tree can be defined as finite set of data items (nodes) in which data items are arranged in branches and sub branches according to requirement.
- Trees represent the hierarchical relationship between various elements.
- Tree consist of nodes connected by edge, the node represented by circle and edge lives connecting to circle.
- Graph: Graph is a collection of nodes (Information) and connecting edges (Logical relation) between nodes.
- A tree can be viewed as restricted graph.
- Graphs have many types:
- Un-directed Graph
- Directed Graph
- Mixed Graph
- Multi Graph
- Simple Graph
- Null Graph
- Weighted Graph