You are on page 1of 20

CSC2100: Data Structures

and Algorithms
Dragule Swaib
Swaib.dragule@mak.ac.ug
0701 678 444/0772285111
Thursday and Friday: 8:00 – 10:00, 17:00 – 19:00
Course Objectives
• To appreciate role of data structures and algorithms in computer
programs;
• Improve students’ problem solving skills
• Introduce students to concepts of Data structures;
• Introduce students to concepts of algorithm analysis and design;
• To expose students to generic algorithmic problems and apply them
to other computational scenarios.
Indicative content
• Introduction to Data structures and Algorithms
• Data structures
• Scalar Data Structure
• Vector or Linear Data Structure
• Non-linear Data Structure
• Algorithm analysis (complexity analysis)
• Algorithm design strategies
• Greedy
• Divide and conquer
• Dynamic programming
• Back tracking
• Sorting algorithms
• Searching Algorithms
• Tree data structures and algorithms
Reference Books
• Classic Data structures by D. Samantha. Prentice Hall of India, 2009.
• Data Structures and Algorithms by Alfred V. Aho, Jeffrey D. Ullman, John E. Hopcroft.
Addison-Wesley, 1983
• The Design and Analysis of Computer Algorithms by Alfred V. Aho, Addison-Wesley
Longman, 1974
• Introduction to Algorithms 2nd Ed by Thomas H. Cormen, Charles E. Leiserson, Ronald L.
Rivest, and Clifford Stein,
• McGraw-Hill, 2008.
• Problem Solving with Algorithms and Data Structures Using Python, by Brad Miller, David
Ranum, 2011
• Data Structures and Algorithm Analysis in Java, by Clifford A. Shaffer - Dover
Publications , 2012
Introduction
• Computer
• Computer Science
• Algorithm
• Data structure
Computer Science
• Computer science isn't the study of computers;
• It's the study of computing; the study of processes for solving
problems.
• The phrase "science of computing" emphasizes this concern with
general computing processes instead of with machines
• Computer science (informatics) deals with information and information
processing
• The processes are the algorithms and the information is kept in data
structures
• Computer science is the study of algorithms and data structures
Algorithm
• A computational procedure that takes input(s) and
produces output(s)
• A sequence of computational steps that transform the
input into the output
• Finite sequence of effective statements that, when
applied to a problem will solve it
• Precise computational procedures to be followed
• Each step must be unique (definite) from other steps
Why Algorithms
• If computers were infinitely faster and memory is free, why
algorithms.
• Is solution correct and terminates
• Computing time is therefore a bounded resource, and so is space in
memory
• algorithms should be efficient in terms of time and/or space
• Algorithm →efficient effectiveness
• Total system performance depends on efficient algorithms and fast hardware.
• Having a solid base of algorithmic knowledge and technique is one
characteristic that separates the truly skilled programmers from the
novices.
Characteristics of an algorithm
• Input
• Output
• Termination-finite
• Definite, unique, distinct steps
• Effectiveness, must give results; preferably efficiently.
Terminologies in Data structures
• Data – value or set of values e.g.: 10, 17/02/2022, 25.4, UAE121E,
Kamau.
• Entity – Attribute and value e.g., employee entity with attributes of
name, sex, salary and values name – Peter, Sex – Male, Salary – 100$.
• Domain – range of values of an attribute e.g, sex {Male, Female,
Bisexual}; Name {Peter, Agondu, Ayinebyona, Juma}
• Information – Data with meaning e.g data {male} and meaning {sex}.
Information is data with attribute, processed data.
Terminologies in Data structures
• Information Continued. Information 1
Information 2
Information 3
Procedure to ---
Data process data ---

Information n

• Data: airtime
• Information: amount used per given time, location, type of people
etc.
Terminologies in Data structures
• Data type – kind of data that may appear in computation e.g. integer,
real, image, date, string. Can be built-in or abstract data type
• Built-in data types – these are language specific
• C – int, float, char, double, enum, etc.
• Pascal – Integer, Character, Real, Boolean, etc.
• FORTRAN – INTEGER, REAL, LOGICAL, COMPLEX, DOUBLE PRECISION,
CHARACTER, etc.
• List Built-in data types in Java, Python, C# etc
• Built-in data types have predefined
• How to store value for each type
• Amount of memory required
• Possible operation per type
Terminologies in Data structures
• Abstract data type – defined by the user-programmer
• Data types not part of the built-in types
• The programmer decides on
• How to store value for each type
• Amount of memory required
• Possible operation per type
• Abstract data types can be built using built-in data types, class/struc in
C/C++, record in Pascal.
• Date is abstract data type in Pascal, Fortran.
The concept of data structures
• Manipulation of real-life data requires
• Storage representation should be understandable by computer
• Retrieved data from storage should be understood by humans
• There must be operations to transform data into various forms.
• The structure of any data is defined based on the following
• Domain – range of data values
• Functions – operations and the
• Axioms – rules to use the operations
• Data structure is the definition of domain, functions and the rules to
implement the functions of a given data.
The concept of data structures
• Example of integer data structure in C programming language
• Domain – integers ± {0, 1, 2, 3, …}
• Functions – operators {+, -, /, *, %}
• Axioms – operator rules: binary arithmetic {data1 operator data2} e.g 1 + 4
• Exercise: Define a date data structure, clearly specifying the domain,
functions and axioms that can be applied to implement the functions.
Classification of Data Structure
Data structures

Scalar Linear Non-linear

Integer, Character, Arrays, Linked Lists, Graphs, Sets,


Boolean, Float, Double,
etc. Stacks, Queues, etc. Tables, Trees, etc.

Other data structures include: neurol networks, petri-


nets, semantic nets, DNA structure, etc.
Classification of Data structure
• Scalar Data Structure:
• Integer, Character, Boolean, Float, Double, etc.
• Vector or Linear Data Structure:
• Array, linked List, Queue, Stack, Priority Queue, etc.
• Non-linear Data Structure:
• Tree, Table, Graph, sets, Hash Table, etc.
Data Structures
• Is the organization of data in memory
• Each data structured is defined by;
• Domain
• Functions
• Axioms (rules, limits)
• Algorithms, accept inputs (data), process the data to output
(information).
• Data structures provide the data
• Algorithms manipulate the data
Summary Slide

You might also like