The document provides an overview of data structures, defining them as systematic ways to organize data for efficient use. It discusses the transition from data to information, the importance of data types, user-defined data types, and abstract data types (ADTs), along with their advantages. Additionally, it differentiates between linear and non-linear data structures, and static versus dynamic data structures, highlighting their respective characteristics and use cases.
The document provides an overview of data structures, defining them as systematic ways to organize data for efficient use. It discusses the transition from data to information, the importance of data types, user-defined data types, and abstract data types (ADTs), along with their advantages. Additionally, it differentiates between linear and non-linear data structures, and static versus dynamic data structures, highlighting their respective characteristics and use cases.
operations are performed by a computer, which may be stored and transmitted in the form of electric signals and recorded on magnetic or optical media. Example: c = a + b When Data becomes Information
DATA: ANAHRAF SI EMAN YM
INFORMATION: MY NAME IS FARHANA If data is arranged in a systematic way it gets a structure and becomes meaningful. THIS MEANINGFUL OR PROCESSED DATA IS CALLED INFORMATION. When Data becomes Information It is not difficult to understand that the data needs to be managed in such a way so that it can produce some meaningful information. To provide an appropriate way to structure the data, we need to know about DATA STRUCTURES. What is Data Structure
A data structure is the systematic way to organize
data so that it can be used efficiently. Example: arrays Instead of creating multiple variables of same type, why not create an array to store all the values. Storing strings is equivalent of storing a sequence of characters. This requires an array. Some Real-Life Examples
❖Stack data structure is used in implementing the redo
and undo features.
❖Which data structure is used to store an image as a
bitmap? Some Real Life Examples. Bitmap image are stored a series of tiny dots called pixels. Here, each pixel is actually a small square that is assigned a colour and then arranged in a pattern to form an image like the following:
A 2-Dimensional Array of (40X30)
Some Real Life Examples. ❖ Storing the friendship information on a social networking site. What is a Data Type? Two Important things about data types: 1.It defines a certain domain of values 2.It defines operations allowed on those values. Example: int type - Takes only integer values - Operations: addition subtraction, multiplication, modulus What is a Data Type? Example: Float type - Takes only floating point values - Operations: addition subtraction, multiplication (% operations are not allowed). User-Defined Data types Primitive Data Types: int, char, float, char The operations and values of user-defined data types are not specified in the language itself but it is specified by the user. Example: structure By using structures, we are defining our own type by combining other data types: struct point { int a; int b; }; ABSTRACT DATA TYPE ADTs are like user-defined data types which define operations on values using functions without specifying what is there inside the function and how the operations are performed. Example: Stack ADT A stack consists of elements of the same type arranged in a sequential manner. Operations: initialize(), push(), pop(), isEmpty(), isFull() ABSTRACT DATA TYPE There are multiple ways to implement an ADT. Example: A Stack ADT can be implemented using arrays and linked lists. The program which uses data structures is called a client program. It has access to ADT i.e. interface The program which implements the data structure is known as implementation. Advantages of ADTs If someone wants to use the stack in the client program, then one can use the push() and pop( ) operations without knowing its implementation. Also, in future, if the implementation of the stack is changed from array to linked lists, then the client program will work in the same way without being affected. ADT provides abstraction i.e. hiding details from the user. A data structure is used to implement an ADT. For example, in order to implement a stack ADT, we can use an array data structure or linked list data structure. ADT tells us what is to be done and data structures tell us how to do it.
ADT provides abstraction i.e. hiding details from the
user. How to know which data structure to use for a particular ADT? In reality, different implementations of ADT are compared for time and space efficiency. The one best suited according to the current requirement of the user will be selected: For Example: A Stack ADT can be implemented using arrays and linked lists. Advantages of Data Structures:
Efficiency: If the choice of a data structure for implementing
o
a particular ADT is proper, it makes the program very
efficient in terms of time and space.
Reusability: The data structures provide reusability means
o
that multiple client programs can use the data structure.
Abstraction: The data structure specified by an ADT also
o
provides the level of abstraction. The client cannot see the
internal workings of the data structure, so it does not have to worry about the implementation part. The client can only see the interface. Linear Data Structure A data structure where all elements are arranged in a sequential order or where each element has one predecessor or one successor. e.g. Array, Linked Lists, Stack, Queues. Non- Linear Data Structure A data structure is non-linear when all the elements are not arranged in a linear or sequential order. e.g. Tree, Graphs Static Data Structures In these types of data structures, the memory is allocated at compile time. Therefore , the maximum size is fixed. Advantages: Fast access Disadvantage: Slower insertion and deletion E.g. Array Dynamic Data Structures In these types of data structures, the memory is allocated at run-time time. Therefore , the maximum size is flexible. Advantages: Fast insertion and deletion Disadvantage: slower access E.g. Linked-Lists Conclusion