0% found this document useful (0 votes)
2 views25 pages

DS Lecture 1

The document is a lecture on Data Structures and Algorithms by Dr. Taghreed Abdullah, covering fundamental concepts such as data types, data structures, and algorithms. It explains the importance of data structures for efficient data storage and manipulation, and outlines various operations and classifications of data structures. Additionally, it discusses algorithm design, representation, and performance analysis metrics like time and space complexity.
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)
2 views25 pages

DS Lecture 1

The document is a lecture on Data Structures and Algorithms by Dr. Taghreed Abdullah, covering fundamental concepts such as data types, data structures, and algorithms. It explains the importance of data structures for efficient data storage and manipulation, and outlines various operations and classifications of data structures. Additionally, it discusses algorithm design, representation, and performance analysis metrics like time and space complexity.
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/ 25

2nd level _Cyber Security and Networks

Data Structures and Algorithms

Lecture 1

Dr. Taghreed Abdullah


Content 2

What is Data?
Introduction

What
Problem, are data&type?
Questions Objectives

What are Data Structure?

Introduction Importance & Operations of Data Structures

List of Data Structures

Classification of Data Structures

What is an algorithm

Dr. Taghreed Abdullah


What is Data? 3

Data
• A collection of raw facts from which a conclusion may be drawn.
• A collection of letters, symbols, numbers, and text (unorganized,
unprocessed data)
• Example:
o Temperature is 35 degrees Celsius
o Conclusion: It is HOT!

Types of data:
Textual: for example >> Your name (Muhammad)
Numeric: for example >> Your id (090254)
Audio: for example >> Your voice
Dr. Taghreed Abdullah
What are Data Types? 4

Data Types:
 Built-in construct of any programming language to manipulate
“basic types of data”
 Basic Types of Data:
 Character
 Integer
 Real or Floating point number
Example (Data Type): Short, int, long, char, double etc ;
Dr. Taghreed Abdullah
What are Data Structures? 5

Data Structure:
• A particular way of storing and organizing data in a computer so
that it can be used efficiently
• It is a group of data elements stored together under one name
• It is also referred as “Abstract Data Type (ADT)”
• Example:
• An array of integers
int examGrades[30];
Dr. Taghreed Abdullah
Data Structures 6

Dr. Taghreed Abdullah


Data Structures 7

Goals of Data Structures

Improve knowledge of standard data


structures and abstract data types

Improve knowledge of standard


algorithms used to solve several classical
problems

Cover some mathematical concepts that


are useful for the analysis of algorithms

Analyze the efficiency of solutions to


problems

Learn about and be comfortable with


recursion

Dr. Taghreed Abdullah


Importance of Data Structures 8

• For what purpose?


• To facilitate efficient
• storage of data
• retrieval of data
• manipulation of data

• Design Issue:
The challenge is to select the most appropriate data structure for the problem
• Such is one of the motivations for this course

Dr. Taghreed Abdullah


List of Data Structures 9

Arrays

Linked List

Stacks Trees
Queues

Graph

Dr. Taghreed Abdullah


Operation on Data Structures 10

• Traversing
• Accessing/visiting each data element exactly once so that
certain items in the data may be processed
• Searching
• Finding the location of a given data element (key) in the
structure
• Insertion:
• Adding a new data element to the structure

Dr. Taghreed Abdullah


Operation on Data Structures 11

• Deletion
• Removing a data element from the structure
• Sorting
• Arrange the data elements in some logical fashion
• ascending or descending
• Merging
• Combining data elements form two or more data
structures into one

Dr. Taghreed Abdullah


Classification of Data Structures 12

Dr. Taghreed Abdullah


Classification of Data Structures 13

Primitive Data structures are directly supported by the language ie; any
operation is directly performed in these data items.
Ex: integer, Character, Real numbers etc.
Non-primitive data types are not defined by the programming language, but
are instead created by the programmer.

Dr. Taghreed Abdullah


Classification of Data Structures 14

Based on Memory Allocation:


• Static (or fixed sized) data structures
• Such as arrays

• Dynamic data structures (change size as needed)


• Such as Linked Lists

Dr. Taghreed Abdullah


Classification of Data Structures 15

Based on Representation
• Linear representation data structures
• Arrays
• Linked lists
• Stack
• Queues
• Non-linear representation data structures
• Trees
• Graphs
Dr. Taghreed Abdullah
What is an Algorithm 16

An algorithm is a set of unambiguous instructions for solving a problem ,i.e., for


obtaining a required output for any legitimate input in a finite amount time.

Dr. Taghreed Abdullah


What is an Algorithm 17

What is the need for algorithms?

1. Algorithms are necessary for solving complex problems efficiently and effectively.
2. They help to automate processes and make them more reliable, faster, and easier
to perform.
3. Algorithms also enable computers to perform tasks that would be difficult or
impossible for humans to do manually.
4. They are used in various fields such as mathematics, computer science,
engineering, finance, and many others to optimize processes, analyze data, make
predictions, and provide solutions to problems.
Dr. Taghreed Abdullah
18

Clearness: Each of its steps should be Characteristics of Algorithm


clear in all aspects and must lead to only 1
one meaning

2 Order

Inputs and Outputs: Algorithm input and 3


produces the required output

4 Finiteness: The algorithm must be finite, i.e. it


should terminate after a finite time.

Effectiveness: less time and less capacity 5


Dr. Taghreed Abdullah
What is an Algorithm 19

Design and Analysis


In designing and analyzing an algorithm we should consider the following questions:
1. What is the problem we have to solve?
2. Does a solution exist?
3. Can we find a solution (algorithm), and is there more than one solution?
4. Is the algorithm correct?
5. How efficient is the algorithm?

Dr. Taghreed Abdullah


What is an Algorithm 20

Algorithm Representation:

1. Flowchart:
 Flowchart uses graphical elements to Visually depict that flow of logic within a
program
 Flowcharts are employed to find solutions for small problems.
2. Pseudo Code:
 Pseudo-code provides a way of expressing algorithms in a way that is independent of
any programming language.
 It abstracts away other program details such as the type system and declaring
variables and arrays.

Dr. Taghreed Abdullah


Algorithm Representation 21

Pseudo code

1. Start

Flowchart 2. Read n
3. Result = n mod 2
4. If Result =0
Print n is even
else
Print n is odd
5. end

Dr. Taghreed Abdullah


Algorithm Representation 22

Pseudo code
1. Start
2. Initialize sum=0 and
count=0
Flowchart
3. Read n
4. Find sum + n and assign
it to sum and then
increment count by 1
5. If count < 5
Go to step 3
else
Print sum
6. end

Dr. Taghreed Abdullah


What is an Algorithm 23

Performance Analysis an Algorithm:


• The Efficiency of an Algorithm can be measured by the following metrics.
• Time Complexity
• Space Complexity.

• Time Complexity: The amount of time required for an algorithm to complete its
execution is called time complexity. An algorithm is said to be efficient if it takes the
minimum (reasonable) amount of time to complete its execution.

• Space Complexity: The amount of space occupied by an algorithm is known as Space


Complexity. An algorithm is said to be efficient if it occupies less space and required the
minimum amount of time to complete its execution.
References 24

1. D.S. Malik, (2010). "Data Structures Using C++", 2nd Edition (or
Higher), USA, Course Technology, Cengage Learning.

2. D.S. Malik, (2018). " C++ programing: program design including Data
Structures" 8th Edition, USA, Course Technology, Cengage Learning

Dr. Taghreed Abdullah


25

You might also like