- 1. ESIT137: Fundamentals of Data Structure Sanjivani Rural Education Society’s Sanjivani College of Engineering, Kopargaon-423603 (An Autonomous Institute Affiliated to Savitribai Phule Pune University, Pune) NACC ‘A’ Grade Accredited, ISO 9001:2015 Certified Department of Information Technology (UG Programme - NBAAccredited) Dr. M.A. Jawale Professor and Head, Dept. of IT
- 2. Fundamentals of Data Structure Introduction Data Structure, Abstract Data Types, Types of Data Structure: a) Primitive and non-primitive, b) Linear and Non-linear, c) Static and Dynamic, d) Persistent and Ephemeral data structures. References Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 3. Data Structure A data structure is a storage that is used to store and organize data. It is a way of arranging data on a computer so that it can be accessed and updated efficiently. A data structure is not only used for organizing the data. It is also used for processing, retrieving, and storing data. The choice of a good data structure makes it possible to perform a variety of critical operations effectively. An efficient data structure also uses minimum memory space and execution time to process the structure. Data structures provide an easy way of organising, retrieving, managing, and storing data.. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 4. Abstract Data Types Data types such as int, float, double, long, etc. are considered to be in-built data types and we can perform basic operations with them such as addition, subtraction, division, multiplication, etc. When we need operations for our user-defined data type which have to be defined. These operations can be defined only as and when we require them. So, in order to simplify the process of solving problems, we can create data structures along with their operations, and such data structures that are not in-built are known as Abstract Data Type (ADT). Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 5. Continue….. Abstract Data type (ADT) is a type (or class) for objects whose behavior is defined by a set of values and a set of operations. The definition of ADT only mentions what operations are to be performed but not how these operations will be implemented. It does not specify how data will be organized in memory and what algorithms will be used for implementing the operations. It is called “abstract” because it gives an implementation-independent view. The process of providing only the essentials and hiding the details is known as abstraction. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 6. Continue….. The user of data type does not need to know how that data type is implemented, for example, we have been using Primitive values like int, float, char data types only with the knowledge that these data type can operate and be performed on without any idea of how they are implemented. So a user only needs to know what a data type can do, but not how it will be implemented. Think of ADT as a black box which hides the inner structure and design of the data type. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 7. Classification of Data Structure Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 8. Primitive and Non-primitive Data Structures Primitive data structures are the fundamental data types which are supported by a programming language. Some basic data types are integer, real, character, and float. The terms ‘data type’, ‘basic data type’, and ‘primitive data type’ are often used interchangeably. Non-primitive data structures are those data structures which are created using primitive data structures. Examples of such data structures include linked lists, stacks, trees, and graphs. Non-primitive data structures can further be classified into two categories: linear and non-linear data structures. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 9. Linear Data Structure Data structure in which data elements are arranged sequentially or linearly, where each element is attached to its previous and next adjacent elements, is called a linear data structure. Examples of linear data structures are array, stack, queue, linked list, etc. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 10. Static Data Structure Static data structure has a fixed memory size. It is easier to access the elements in a static data structure. An example of this data structure is an array. Static data structures, such as arrays, have a fixed size and are allocated at compile-time. This means that their memory size cannot be changed during program execution. Index-based access to elements is fast and efficient since the address of the element is known. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 11. Dynamic Data Structure In the dynamic data structure, the size is not fixed. It can be randomly updated during the runtime which may be considered efficient concerning the memory (space) complexity of the code. Examples of this data structure is linked list. Dynamic data structures, on the other hand, have a variable size and are allocated at run-time. This means that their memory size can be changed during program execution. Memory can be dynamically allocated or deallocated during program execution. Due to this dynamic nature, accessing elements based on index may be slower as it may require memory allocation and deallocation. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 12. Static Data Structure vs Dynamic Data Structure Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 13. Advantage of Static Data Structure : Fast access time: Static data structures offer fast access time because memory is allocated at compile-time and the size is fixed, which makes accessing elements a simple indexing operation. Predictable memory usage: Since the memory allocation is fixed at compile- time, the programmer can precisely predict how much memory will be used by the program, which is an important factor in memory-constrained environments. Ease of implementation and optimization: Static data structures may be easier to implement and optimize since the structure and size are fixed, and algorithms can be optimized for the specific data structure, which reduces cache misses and can increase the overall performance of the program. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 14. Continue…. Efficient Memory Management: Static data structures allow for efficient memory allocation and management. Since the size of the data structure is fixed at compile-time, memory can be allocated and released efficiently, without the need for frequent reallocations or memory copies. Simplified Code: Since static data structures have a fixed size, they can simplify code by removing the need for dynamic memory allocation and associated error checking. Reduced overhead: Static data structures typically have lower overhead than dynamic data structures, since they do not require extra bookkeeping to manage memory allocation and deallocation. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 15. Advantage Of Dynamic Data Structure Flexibility: Dynamic data structures can grow or shrink at runtime as needed, allowing them to adapt to changing data requirements. This flexibility makes them well-suited for situations where the size of the data is not known in advance or is likely to change over time. Reduced memory waste: Since dynamic data structures can resize themselves, they can help reduce memory waste. For example, if a dynamic array needs to grow, it can allocate additional memory on the heap rather than reserving a large fixed amount of memory that might not be used. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 16. Continue….. Improved performance for some operations: Dynamic data structures can be more efficient than static data structures for certain operations. For example, inserting or deleting elements in the middle of a dynamic list can be faster than with a static array, since the remaining elements can be shifted over more efficiently. Simplified code: Dynamic data structures can simplify code by removing the need for manual memory management. Dynamic data structures can also reduce the complexity of code for data structures that need to be resized frequently. Scalability: Dynamic data structures can be more scalable than static data structures, as they can adapt to changing data requirements as the data grows. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 17. Non-linear Data Structure Data structures where data elements are not placed sequentially or linearly are called non-linear data structures. In a non-linear data structure, we can’t traverse all the elements in a single run only. Examples of non-linear data structures are trees and graphs. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 18. Persistent Data Structures. A persistent structure is one where, multiple versions are simultaneously accessible: after an update, both old and new versions can be used. A persistent data structure is a data structure that always preserves the previous version of itself when it is modified. They can be considered as ‘immutable’ as updates are not in-place. A data structure is partially persistent if all versions can be accessed but only the newest version can be modified. Fully persistent if every version can be both accessed and modified. Unit-I: Part-I of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 19. Ephemeral Data Structures. An ephemeral data structure is one for. which only one version is available at a time: after an update operation, the structure as it existed before the update is lost. A persistent structure is one where. multiple versions are simultaneously accessible: after an update, both old and new versions can be used. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 20. Arrays An array is a linear data structure and it is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together in one place. The first element of the array is indexed by a subscript of 0. There are different operations possible in an array, like Searching, Sorting, Inserting, Traversing, Reversing, and Deleting. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology
- 21. Reference 1. Richard F. Gilberg & Behrouz A. Forouzan, “Data Structures: A Pseudocode Approach with C, Second Edition”, Cengage Learning. 2. Ellis Horowitz, Sartaj Sahani, Susan Anderson-Freed “Fundamentals of Data Structures in C”, Universities Press, 2008. Unit-I: Part-I Fundamentals of Data Structure Dr. Madhuri Jawale Department of Information Technology