0% found this document useful (0 votes)
16 views

Week 1

This document provides an introduction to data structures. It defines data structures as organized data that allows for efficient storage and manipulation. It categorizes data structures as primitive and non-primitive. Primitive structures like integers and characters are built-in types, while non-primitive structures like arrays and lists are more sophisticated structures derived from primitives. Linear structures like stacks and queues arrange data in a sequence, while nonlinear structures like trees and graphs connect data in other ways. Common operations on data structures include creation, destruction, selection, updating, searching, sorting, merging, splitting, and traversal.

Uploaded by

Hassan Waheed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Week 1

This document provides an introduction to data structures. It defines data structures as organized data that allows for efficient storage and manipulation. It categorizes data structures as primitive and non-primitive. Primitive structures like integers and characters are built-in types, while non-primitive structures like arrays and lists are more sophisticated structures derived from primitives. Linear structures like stacks and queues arrange data in a sequence, while nonlinear structures like trees and graphs connect data in other ways. Common operations on data structures include creation, destruction, selection, updating, searching, sorting, merging, splitting, and traversal.

Uploaded by

Hassan Waheed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Introduction

to
Data Structures
by
Amber Murtaza
Data Structure
• A data structure is a group of data elements that provides the
easiest way to store and perform different actions on the data
of the computer.
• A data structure is a particular way of organizing data in a
computer so that it can be used effectively.
• The idea is to reduce the space and time complexities of
different tasks.
• An efficient data structure also uses minimum memory space
and execution time to process the structure.
Data structures are used in various
fields such as:
• Operating system
• Graphics
• Computer Design
• Blockchain
• Genetics
• Image Processing
• Simulation etc.
Normally Data Structures are classified
into two main categories:
1. Primitive Data Structure
2. Non-primitive data Structure
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.
Cont.
• These data types are available in most programming
languages as built in type.
o Integer: It is a data type which allows all values without
fraction part. We can use it for whole numbers.
o Float: It is a data type which use for storing fractional
numbers.
o Character: It is a data type which is used for character
values.
o 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
Cont.
o Array: An array is a fixed-size sequenced collection of
elements of the same data type.
Cont.
o List: An ordered set containing variable number of elements is
called as Lists.

o 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:
o Static memory allocation
o 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.
Cont.
• Stack: Stack is a data structure in which insertion and deletion
operations are performed at one end only.
o The insertion operation is referred to as ‘PUSH’ and deletion
operation is referred to as ‘POP’ operation.
o Stack is also called as Last in First out (LIFO) data structure.
Cont.
• Queue: The data structure which permits the insertion at one
end and Deletion at another end, known as Queue.
o End at which deletion is occurs is known as FRONT end and
another end at which insertion occurs is known as REAR end.
o 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.
Cont.
• 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.
o Trees represent the hierarchical relationship between various
elements.
o Tree consist of nodes connected by edge, the node represented
by circle and edge lives connecting to circle.
Cont.
• Graph: Graph is a collection of nodes (Information) and
connecting edges (Logical relation) between nodes.
o A tree can be viewed as restricted graph.
o Graphs have many types:
• Un-directed Graph
• Directed Graph
• Mixed Graph
• Multi Graph
• Simple Graph
• Null Graph
• Weighted Graph
Difference between Linear and Non
Linear Data Structure
Linear Data Structure Non-Linear Data Structure
• Every item is related to • Every item is attached
its previous and next with many other items.
time.
• Data is not arranged in
• Data is arranged in linear sequence.
sequence.
• Data items can be • Data cannot be traversed
traversed in a single run. in a single run.
• e.g., Array, Stacks, linked • e.g., tree, graph.
list, queue. • Implementation is
• Implementation is easy. difficult.
Operation on Data Structures
The most commonly used operations on data structure are
broadly categorized into following types.
1. Create:- The create operation results in reserving memory
for program elements. This can be done by declaration
statement. Creation of data structure may take place either
during compile-time or run-time. malloc() function of C
language is used for creation.
2. Destroy:- Destroy operation destroys memory space
allocated for specified data structure. free() function of C
language is used to destroy data structure.
Cont.
3. Selection:- Selection operation deals with accessing a
particular data within a data structure.
4. Updation:- It updates or modifies the data in the data
structure.
5. Searching:- It finds the presence of desired data item in
the list of data items, it may also find the locations of all
elements that satisfy certain conditions.
6. Sorting:- Sorting is a process of arranging all data items in a
data structure in a particular order, say for example, either
in ascending order or in descending order.
Cont.
7. Merging:- Merging is a process of combining the data items
of two different sorted list into a single sorted list.
8. Splitting:- Splitting is a process of partitioning single list to
multiple list.
9. Traversal:- Traversal is a process of visiting each and every
node of a list in systematic manner.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy