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

Introduction To Data Structures

Uploaded by

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

Introduction To Data Structures

Uploaded by

keamjrke
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Introduction to Data

Structures and Algorithms

DEDANK Y
IMATHI T Y OF TECHNOLOG
UNIVERS
I

Dedan Kimathi University


of Technology
SSE 100
Introduction
Before starting our discussion on data structures, let us first consider what data
are and how they support information systems. Data are represented by data
values held temporarily within a program's data area or recorded permanently on
a file. Often the different data values are related to each other. To enable
programs to make use of these relationships, these data values must be in an
organized form. The organized collection of data is called a data structure.
The Use of Data
1 Data Resource
The large circle labeled "data" represents the overall data resource of the organization. This
resource is an active participant in the organization's operations and planning. The small
circles represent individual elements or items of data.

2 Information Generation
These elements can be considered to be raw facts. They are aggregated and summarized in
various meaningful ways to form information. Decisions are made on the basis of this
information.

3 Decision Cycle
The results of decisions are actions, which in turn generate more data. These data then can
be incorporated into another cycle of the decision making process.
Kinds of Decisions

1 Operational Decisions 2 Control Decisions


Operational decisions govern the daily Control decisions, also called tactical
activities of the organization. decisions, determine the way the
organization executes its designated
mission.

3 Planning Decisions
Planning decisions, also termed strategic decisions, develop and define the organization's
mission.
Data Management

Data Handling Data Handling Objectives


• Measurement • Storage • Represent and store data
• Collection • Aggregation for access

• • • Organize data for


Transcription Update
efficient access
• Validation • Retrieval
• Process and present data
• Organization • Protection
effectively
• Protect and manage data
value
Properties of Data

Accuracy Relevance
Data should be precise, reliable, and free from The data collected should be relevant to the
errors or biases to ensure trustworthy and problem or question being addressed, providing
meaningful insights. valuable and applicable information.

Completeness Timeliness
Data should be comprehensive, covering all the Data should be up-to-date and reflect the current
necessary aspects and components to provide a state of the subject, ensuring that decisions made
holistic understanding of the subject matter. are based on the most recent and accurate
information.
Abstract Data Types

Data Structures Collections Algorithms


Abstract Data Types (ADTs) ADTs describe collections of data, ADTs also define the algorithms
define the structure and operations such as lists, sets, and maps, and and procedures for manipulating
of data, independent of their the operations that can be the data, such as searching,
implementation. performed on them. sorting, and inserting elements.
What is an Algorithm?
Definition Representation
A set of instructions giving a step-by-step Algorithms may be defined in English,
procedure which, given some inputs, diagrams, computer programming
produces some outputs. An algorithm is languages, pseudo code, or other formal
any well-defined computational procedure languages.
that takes some value, or a set of values as
input and produces some value, or a set of
values as output.

Purpose
Data structure is a way of storing and organizing data in order to facilitate access and
modification.
Running Time Analysis
Input Size
The running time depends on the input: an already sorted sequence is easier to sort. Parameterize
the running time by the size of the input, since short sequences are easier to sort than long ones.

Worst-Case Analysis
Generally, we seek upper bounds on the running time, because everybody we need guarantee. This
is known as the worst-case or big O notation analysis.

Average-Case Analysis
Sometimes an average-case or theta notation analysis is done, which requires an assumption of the
statistical distribution of inputs.

Best-Case Analysis
Rarely, a best-case or omega notation analysis is done, which can cheat with a slow algorithm that
works fast on some inputs.
Time Complexity

Time complexity is a fundamental concept in computer science that measures the efficiency
of an algorithm by analyzing the amount of time it takes to run as a function of the size of
its input. It provides a way to understand how the running time of an algorithm scales as the
problem size increases.

The time complexity of an algorithm is usually expressed using big O notation, which
provides an upper bound on the growth rate of the algorithm's running time. By
understanding the time complexity of an algorithm, developers can make informed
decisions about which algorithms to use and how to optimize their code for performance.
Space Complexity
Space complexity refers to the amount of memory or storage required by an algorithm to execute.
It is an important factor in evaluating the efficiency of an algorithm, alongside time complexity.
The space complexity of an algorithm depends on the data structures used, the size of the input,
and the number of variables or temporary values stored during execution.

Analyzing the space complexity of an algorithm helps ensure that it can be executed within the
available memory constraints, especially for large-scale applications. Understanding space
complexity is critical for designing efficient and scalable algorithms.
Order of Growth
Constant
1
O(1)

Logarithmic
2
O(log n)

Linear
3
O(n)

Quadratic
4
O(n^2)

The order of growth refers to how the running time or space usage of an algorithm scales as the input size increases.
This is a crucial concept in algorithm analysis, as it allows us to understand the efficiency and scalability of different
algorithms.
Asymptotic Notation

Big-O Notation Omega Notation Theta Notation


Big-O notation describes the Omega notation describes the Theta notation describes the exact
upper bound of a function's lower bound of a function's growth rate of a function,
growth rate, indicating the growth rate, indicating the capturing both the upper and
maximum possible rate of increase minimum possible rate of increase lower bounds, providing a tight
as the input size approaches as the input size approaches bound on the function's
infinity. infinity. asymptotic behavior.
Big O Notation

Big O notation is a mathematical tool used to analyze the time complexity of


algorithms. It describes the worst-case scenario, providing an upper bound on the
growth rate of a function as the input size increases.

Big O notation helps developers understand how an algorithm's performance will


scale, enabling them to make informed decisions about which algorithms to use
in their applications.
Omega and Theta Notation

Omega (Ω) notation is used to provide a lower bound on the time complexity of an
algorithm. It represents the best-case scenario, indicating the minimum resources required
for the algorithm to perform its task.

Theta (Θ) notation is used to provide both upper and lower bounds on the time
complexity of an algorithm. It represents the exact complexity, indicating the precise
resources required for the algorithm to perform its task.
Classification of Data Structures

Classification Examples

Linear vs Non-linear Arrays (linear), Trees (non-linear)

Homogenous vs Non-homogenous Arrays (homogenous), Records (non-homogenous)

Static vs Dynamic Static arrays, Dynamic linked lists

Logical vs Physical Logical: Lists, Trees. Physical: Arrays, Pointers


Types of Data Structures

Primitive Simple Linear Non-linear


Integers, booleans, Strings, arrays, records - Stacks, queues, linked Trees, graphs -
characters - not built from primitives. lists - relationships are relationships are non-
composed of other data linear. linear and complex.
structures.
Linear Data Structures

Arrays Linked Lists Stacks and Queues

A basic data structure that stores A linear data structure where Last-in-first-out (LIFO) and
a collection of elements in a each element contains a link to first-in-first-out (FIFO) data
contiguous block of memory. the next, allowing for dynamic structures, respectively, with
resizing. specialized access methods.
Non-Linear Data Structures
1 Trees
Hierarchical data structures with a root node and branching child nodes, useful for
efficient searching and sorting.

2 Graphs
Collections of nodes (vertices) connected by edges, modeling complex relationships
and networks.

3 Advanced Structures
More specialized data structures like heaps, hash tables, and tries, each optimized
for particular use cases.
Specialized Data Structures
Hash Tables Heaps
An efficient data structure that uses hashing to A special type of binary tree that maintains the
enable constant-time lookups, insertions, and heap property, making it useful for priority queues
deletions. and sorting.

Tries Bloom Filters


A tree-based data structure that stores strings, A probabilistic data structure that can quickly
optimized for efficient prefix-based searching and determine whether an element is likely to be in a
retrieval. set.
Choosing the Right Data Structure

1 Consider the Problem 2 Evaluate Trade-offs


Identify the key requirements, such as search Understand the strengths and weaknesses of
speed, insertion and deletion operations, and each data structure to make an informed
memory usage. choice.

3 Optimize for Performance 4 Implement Efficiently


Select the data structure that best fits the Leverage the unique properties of the chosen
specific needs of the problem at hand. data structure to write clean, optimized code.
Conclusion

Mastering Fundamentals Efficiency Matters


Understanding the core concepts of data, Analyzing time and space complexity helps
abstract data types, and algorithmic analysis is identify and optimize the most efficient
crucial for effective problem-solving. algorithms for the task at hand.

Asymptotic Notation Continuous Learning


Big O, Omega, and Theta notation provide a Staying up-to-date with the latest data
common language to describe and compare the structures, algorithms, and analytical techniques
performance of algorithms. is crucial for thriving in the ever-evolving field
of computer science.
THANK YOU

Dr Jane Kuria
Private Bag- Dedan kimathi, Nyeri-Mweiga road

Dedan Kimathi University Telephone: +254-721709511


of Technology Email: [email protected]
Website: www.dkut.ac.ke

You might also like