Introduction To Data Structures
Introduction To Data Structures
DEDANK Y
IMATHI T Y OF TECHNOLOG
UNIVERS
I
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
3 Planning Decisions
Planning decisions, also termed strategic decisions, develop and define the organization's
mission.
Data Management
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
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
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
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.
Dr Jane Kuria
Private Bag- Dedan kimathi, Nyeri-Mweiga road