Code: BCECCE3102 Data Structure & Algorithm Dr. Bharti Salunke
Department of Computer Science And Engineering, Poornima University, Jaipur, India 2
Data Structure Department of Computer Science And Engineering, Poornima University, Jaipur, India 3 Data is a collection of information. The data is a programming word, it is values or set of values. Data Structure is a way to store and organize data so that it can be used efficiently. Data structure is not any programming language like C, C++, java etc . It is a set of algorithms that we can use in any programming language to structure the data in the memory.
Cont … Where data structures are used? Compiler Design Operating System DBMS Artificial Intelligence Simulation Numerical Analysis etc… Department of Computer Science And Engineering, Poornima University, Jaipur, India 4
Types of Data Structure Department of Computer Science And Engineering, Poornima University, Jaipur, India 5
Primitive Data Structure Department of Computer Science And Engineering, Poornima University, Jaipur, India 6 Primitive data structures are the basic building blocks of data manipulation. These include : Int : Represents integer values . Char: Used to store single characters. Bool: Holds Boolean values, true or false . Float: Used for floating-point numbers, which are numbers with a decimal point.
Non-Primitive Data Structure Department of Computer Science And Engineering, Poornima University, Jaipur, India 7 Moving beyond the basics, non-primitive data structures offer more sophisticated ways to organize and store data. These are generally divided into two categories: Linear and Non-linear. The arrangement of data in a sequential manner is known as a linear data structure. Array, Stack, Queue, Linked-List are the example of linear data structure . Non-linear structures allow data to be stored in a non-sequential manner, facilitating quick retrieval and linkage based on relationships; like Tree and Graph.
Array Department of Computer Science And Engineering, Poornima University, Jaipur, India 8 An array is a collection of items of the same variable type that are stored at contiguous memory locations. Each element in an array is accessed through its index.
Stack Department of Computer Science And Engineering, Poornima University, Jaipur, India 9 Stack is a linear data structure in which elements can be inserted as well as deleted from one end. LIFO policy is used in Stack data structure.
Queue Department of Computer Science And Engineering, Poornima University, Jaipur, India 10 Queue is linear data structure in which elements can be inserted from one end as well deleted from another end FIFO policy is used in queue data structure.
Linked List Department of Computer Science And Engineering, Poornima University, Jaipur, India 11 Linked List is a linear data structure in which each elements contains two nodes: data, link
Tree Department of Computer Science And Engineering, Poornima University, Jaipur, India 12 A hierarchical structure consisting of nodes, with each node containing data and references to child nodes. The tree is a non-linear data structure that is comprised of various nodes.
Graph Department of Computer Science And Engineering, Poornima University, Jaipur, India 13 A graph is a non-linear data structure with a finite number of vertices and edges, and these edges are used to connect the vertices . It’s used to represent relationships between different entities.
Memory Allocation Department of Computer Science And Engineering, Poornima University, Jaipur, India 14
Department of Computer Science And Engineering, Poornima University, Jaipur, India 15 #include < stdio.h > int main() { // Static memory allocation of an array int arr [5] = {1, 2, 3, 4, 5}; // Printing the array elements for ( int i = 0; i < 5; i ++) { printf (" arr [%d] = %d\n", i , arr [ i ]); } return 0; } Static Memory Allocation