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

DSA Lecture 1

The document provides an overview of data structures and algorithms, defining key terms and classifications, including primitive and abstract data structures. It explains operations on data structures, such as insertion, deletion, and searching, and highlights the significance of arrays and their features. Additionally, it discusses the applications of data structures in various fields, including data representation, searching, manipulation, and artificial intelligence.

Uploaded by

arkbofficial
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)
7 views

DSA Lecture 1

The document provides an overview of data structures and algorithms, defining key terms and classifications, including primitive and abstract data structures. It explains operations on data structures, such as insertion, deletion, and searching, and highlights the significance of arrays and their features. Additionally, it discusses the applications of data structures in various fields, including data representation, searching, manipulation, and artificial intelligence.

Uploaded by

arkbofficial
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/ 16

Course Instructor: Hafsa Zaman

Department of Computer Science & Information Technology


Thal University Bhakkar
 Key Terminologies
 Definition of Data Structure and Algorithm
 Types of Data Structure
 Classification of Data Structure
 Data Structure Operations
 Arrays
 Applications of Data Structure
Data Data refers to any collection of facts, values, or information that can be
processed or manipulated by a computer.

Data Storage Data is organized in a specific format that makes it easy to access and
modify, which is where data structures come into play.

Data Usage Data is used in algorithms and applications to perform computations,


store information, and manage resources effectively.

Data Types The classification of data based on the kind of values it can hold and the
operations that can be performed on it, such as integers and strings etc.

Data The associations and connections between different data elements within
Relationships a data structure, defining how they interact and relate to one another.
Data Structure is a particular way of storing and organizing data in the memory of the
computer so that these data can easily be retrieved and efficiently utilized in the future when
required.

It refers to the logical or mathematical model of interrelated data.

• Mathematical Model: In data structures, a mathematical model represents abstract data


types and their operations using mathematical concepts; for example, defining a stack with
operations like push and pop using set theory.
• Logical Model: A logical model in data structures outlines how data is organized and
manipulated through structures like trees and graphs, emphasizing relationships and
constraints; for example, a binary tree representing hierarchical data.
• Interrelated Data: It means data is mutually related. Data elements are arranged in such
way that changes in one piece of data may affect another.
“An Algorithm is a step-by-step procedure used to solve a problem or perform a calculation.”

It is a set of instructions, but not the entire program or code; it is simple logic for a problem
represented as an informal description in the form of a pseudo-code.
An Algorithm is generally created independent of underlying any programming language. You
can implement it in any programming language, such as Java, Python, C, C++, etc.

Example: Write an algorithm that inputs two numbers, calculates sum and then
displays the result on screen.

1. Start
2. Input A, B
3. Total= A+B
4. Display Total
5. Exit
Primitive Data • The Primitive Data Structures are fundamentals data types that
Structure are supported by a programming language.
• These data structures can be manipulated or operated directly
by machine-level instructions.
• Such data structures consist of basic and simple data types like
integer, float, character, etc.
Abstract Data • The Non-primitive Data Structures are derived from primitive
structure data structures. These are created by a programmer, but not
defined by a programming language.
• These data structures can't be manipulated or operated directly
by machine-level instructions.
• This type of data structure is used to store group of values in the
form of arrays, queues, stack, trees, graphs, etc.
Linear Data Structure In Linear Data Structure, the elements are arranged in a sequence.
Based on memory allocation, the Linear Data Structures are further
classified into two types:
• Static Data Structure: Fixed-size data structures have memory
allocated at compile time, and their size can't be changed
afterward, though the stored data can be modified (e.g., Array).
• Dynamic Data Structure: Dynamic data structures allocate
memory at runtime, allowing their size and stored data to change
during execution (e.g., linked list, queue, and stack).
Non-Linear Data In Non-Linear Data Structure, the data elements are not arranged in
structure a sequence.
Data insertion and removal aren’t linear; instead, there’s a
hierarchical relationship between items.
Example: Trees and Graphs.
Operation Description

Insertion Adding a new record to the structure.

Deletion Removing a record from the structure

Traversing Accessing and processing each data element exactly once.

Searching Find the location of the key value within the data structure.

Sorting Arranging data elements in descending or ascending order.

Merging Combine elements of two different lists into single sorted list.
An array is a data structure that collects multiple data elements of the same data type under
one variable name, using index numbers (subscripts) for access. All elements are stored in
contiguous memory locations, allowing easy traversal by their indexes.

Features of an Array

• Linear Data Structure


• Static Data Structure(Fixed Size)
• Contiguous Memory Locations
• Adjacent Memory Locations
• Homogenous Elements (Same Data Type)
• Randomly Individual Access of Elements
• Simple Data Structure
Element • Each data item stored in an array is called its element.
• The actual data value stored within an Array.
Index • Each array element has a numerical index for identification.
• The index represents the address assigned to the element.
• Used to access or modify the element.
• Known as the subscript, written as: Array[0], Array[1], etc.
Memory Address • The actual physical memory (RAM) location where array is being
stored.
• Not fixed for any program or compiler.
• Stored in available free space in memory (RAM).
• Limited to a specified region of memory.
Length of an Array • Total number of elements present in an array.
Width of an Element • The memory space required by each element in an array is called
its width or size (e.g., 1 byte, 2 byte, 4 byte, etc.).
Base Address • It is usually the address of the first element of the array.
• The base address is a reference point for other addresses.
• It helps locate linked addresses.
Lower Bound • The address of the first element (first index) of the array.
• It is also known as lower limit of an array.
Upper Bound • The address of the last element (last index) of the array.
• It is also known as upper limit of an array.

Example:

Array[5]= {15,20,10,5,25}
Lower Bound:
Array[0]= 15
Upper Bound:
Array[4]= 25
score[7]={1,2,3,4,5,6,7}

Q#1: How to calculate the length of an array?


Length= UB-LB+1
Length= 6-0+1= 7

Q#2: How to calculate the address to access an element (score[3]) in an array?


array[index]= base address + size of an element * (index – LB)
score[3]= 1000 + 2 * (3-0)
=1000 + 6= 1006
1. Information Representation: Represent information in databases, used to store and
retrieve data efficiently.
2. Data Searching: Enable algorithms for data searching (e.g., search engines).
3. Data Manipulation: Support algorithms for data manipulation (e.g., word processors).
4. Data Analysis: Facilitate algorithms for data analysis (e.g., data mining).
5. Data Generation: Support algorithms for data generation (e.g., random number
generators).
6. Data Compression: Enable algorithms for data compression and decompression (e.g., zip
utilities).
7. Data Security: Implement algorithms for data encryption and decryption (e.g., security
systems).
8. File Management: Assist in building software for file and directory management.
9. Graphics Rendering: Support software for rendering graphics (e.g., web browsers, 3D
rendering software). Represent geometric shapes and graphical elements.
10.Operating Systems: Manage system resources like memory and files in operating
systems.
11.Artificial Intelligence: Represent knowledge and information in AI systems.

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