0% found this document useful (0 votes)
8 views22 pages

Data Models and Data Structures LECTURE5

The document discusses data and its transformation into meaningful information through structured data models, including hierarchical, network, relational, and object-oriented models. It also outlines various data structures such as arrays, linked lists, stacks, queues, trees, and graphs, detailing their operations and applications in programming. Understanding these concepts is essential for efficient data management and manipulation in software systems.

Uploaded by

bankyemax001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views22 pages

Data Models and Data Structures LECTURE5

The document discusses data and its transformation into meaningful information through structured data models, including hierarchical, network, relational, and object-oriented models. It also outlines various data structures such as arrays, linked lists, stacks, queues, trees, and graphs, detailing their operations and applications in programming. Understanding these concepts is essential for efficient data management and manipulation in software systems.

Uploaded by

bankyemax001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Data Models and Data

Structures
LECTURE 5
WHAT IS DATA?
When data becomes information?
• DATA : nhoj si eman my
• INFORMATION: My name is John
If data is arranged in a systematic way then it gets a structure and
become meaningful
Therefore, meaningful or processed data is called INFORMATION.
However, data needs to be managed in such a way so that it can
produce some meaningful information.
Therefore,
• A data model defines how data is structured, stored, and manipulated in
a database or system.
• It represents the logical structure of the data and the relationships
between different data elements.
Types of Data Models:
1. Hierarchical Model:
•Data is organized in a tree-like structure with parent-child
relationships.
•Example: File systems, where folders can contain other folders and
files.
Example
2. Network Model
Emerged from the Hierarchical Model to overcome the
disadvantages of the hierarchical Model for representing
complex data relationships to improve database performance
3. Relational Model:
•Data is organized into tables (relations) where each row represents a
record, and columns represent attributes.
•Example: A database table storing student information (name, ID,
course).
TABLE

The rows and columns are


interrelated to each other
4. Object-Oriented Model: Data is represented as objects, similar to
object-oriented programming.
• Each object contains data (attributes) and methods (functions).
• Example: A car object containing attributes like colour and model, and
methods like start and stop.
• Importance of Data Models:
1. Helps in structuring and organizing data efficiently.
2. Allows for the definition of relationships between data elements.
3. Simplifies data access and manipulation in software systems.
Basic Data Structures

• What is a Data Structure?


A data structure is a way to organize and store data in a computer so
that it can be used efficiently.
• Data structures enable effective data management, making tasks like
searching, sorting, and manipulating data faster.
• Types of Data Structures:
• Linear Data Structures: Elements are arranged in a sequential
manner.
• Non-Linear Data Structures: Elements are arranged in a hierarchical
or interconnected way.
•Types of Data Structures
1. Arrays:
A collection of elements of the same type stored at contiguous memory locations.
Operations:
•Access: Retrieve an element using its index.
•Insertion and Deletion: Adding or removing elements may require shifting other elements.
•Example: List of student grades.
2. Linked Lists:
•A sequence of nodes where each node contains data and a reference (or link) to the next node.
•More flexible than arrays because they allow easy insertion and deletion of elements.

Types:
•Singly Linked List: Nodes contain data and a reference to the next node.
•Doubly Linked List: Nodes contain data and references to both the next and previous
nodes.
• Example of Operations in a Linked List:
• Insert: Add a node at the beginning, middle, or end.
• Delete: Remove a node by updating links.
• Search: Find a node by traversing from the head node.
3. Stacks:
•A collection of elements that follows the Last In, First Out (LIFO) principle.
Operations:
•Push: Add an element to the top of the stack.
•Pop: Remove the top element.
•Peek: View the top element without removing it.
•Example: Undo function in text editors.
4. Queues:
•A collection of elements that follows the First In, First Out (FIFO) principle.
Operations:
•Enqueue: Add an element to the back of the queue.
•Dequeue: Remove an element from the front of the queue.
•Example: Printer task scheduling.
5. Trees:

A hierarchical data structure with a root node and child nodes.

Types:

•Binary Tree: A tree where each node has at most two children.

•Binary Search Tree (BST): A binary tree where the left child is smaller than the parent, and the right

child is greater.

•Example: File directory structure, family trees.

6. Graphs:

A collection of nodes (vertices) connected by edges.

•Used to represent relationships and connections between data points.

•Example: Social networks, where users are nodes, and friendships are edges.
Operations on Data Structures
• Common Operations:
1. Traversal: Visiting every element in the data structure.
• Example: In a tree, traversing each node from top to bottom (pre-order, in-
order, post-order).
2. Insertion: Adding an element to the data structure.
3. Deletion: Removing an element from the data structure.
4. Searching: Finding an element in the data structure (e.g., linear
search in an array, binary search in a sorted array).
5. Sorting: Arranging elements in a particular order (e.g., ascending or
descending).
Application of Data Structures
• Choosing the Right Data Structure:
• The choice of data structure depends on the problem you’re solving:
• For searching: Use arrays, linked lists, or hash tables.
• For hierarchical data: Use trees.
• For relationships between entities: Use graphs.
• Real-World Applications:
1. Arrays: Storing multiple variables like employee records in a database.
2. Stacks: Implementing undo/redo functionality in applications.
3. Queues: Managing tasks in a print queue or customer support system.
4. Trees: Representing folder hierarchies or performing fast
lookups in databases (binary search trees).
5. Graphs: Modeling social networks, cities connected by roads,
or computer networks.
Data Structures in Programming
• Implementing Data Structures:
• Most programming languages provide built-in data structures (e.g.,
lists, dictionaries in Python, arrays in Java).
• For custom applications, you may need to implement your own data
structures to optimize performance or meet specific requirements.

You might also like