[go: up one dir, main page]

0% found this document useful (0 votes)
18 views54 pages

DSA Lec01 Introduction

The document outlines a course on Data Structures and Algorithms, emphasizing the importance of efficient data management in the information age. It covers course content, including object-oriented programming concepts, data structures, algorithms, and evaluation criteria. Additionally, it provides a course schedule, grading system, and references for further reading.

Uploaded by

6731503077
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)
18 views54 pages

DSA Lec01 Introduction

The document outlines a course on Data Structures and Algorithms, emphasizing the importance of efficient data management in the information age. It covers course content, including object-oriented programming concepts, data structures, algorithms, and evaluation criteria. Additionally, it provides a course schedule, grading system, and references for further reading.

Uploaded by

6731503077
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/ 54

1501118

Data Structures
and Algorithms
Lecture 1:
Introduction

School of Information
Technology

Copyright 2025
Outline
• Course Outline
• Review of Object-Oriented Programming
• Summary

2
Why Studying Data Structures &
Algorithms?
• Recently we are in information age
• All processes need data i.e. social
networking, online shopping etc.
• Big data / Information Overload
• How to store, access and modify data
efficiently?
– Local storage i.e. files and databases
– Cloud or distributed data storage
3
Huge
Data
Transferring
4
Why Studying Data Structures &
Algorithms?
• Data are crucial for processing
• To process data efficiently, we need to keep
data in suitable structures and select the
appropriate algorithms
• Efficient data structures and algorithms →
less required resources (time, memory etc.)

5
Example of Data Structures
• To keep a value, we can use a variable
• To keep two values → use two variables
• To keep 100 values?
– It may not be good to declare 100 variables
– It may be difficult to access a value at the 50th
position
• OK, we can use an array of 100 members
– how about adding a 101st member to an array?
6
Example of Algorithms
• We have five numbers: 4 1 3 5 2
• What is the maximum?
• What is the minimum?
• Can we sort these numbers in ascending
and descending orders?
• Is there a value “5” in this list? If yes, where
is it?

7
Suggested Self Review
• Computer Programming
• Object-Oriented Programming
• Mathematics 1 / Math for IT 1

8
Course Description
• 1501118 Data Structures and Algorithms
• Credits 3(2-2-5)
• Array; linked lists; stacks; queues; tree;
graph; hash table; algorithm analysis;
recursion; sorting; searching.

9
Course Plan

10
Course Plan

11
Course Plan

12
Course Plan

13
Course Schedule
Onsite:
Sec Lecture Lab
1 MON 13:00 – 15:00 @ C1-313 MON 13:00 – 15:00 @ S1-206

2 THU 8:00 – 10:00 @ S7-A 402 THU 8:00 – 10:00 @ S1-305


3 THU 8:00 – 10:00 @ S7-A 402 THU 8:00 – 10:00 @ S1 304
4 MON 13:00 – 15:00 @ C1-314 MON 13:00 – 15:00 @ S1-305

14
Evaluation
Topic Score
Lecture Assignment 10

Lab Assignment 10

Lab Test 1 and 2 5+10

Midterm Exam 25

Final Exam 30

Group Project 10

Total 100

15
Grading
• Criteria-based
Score Grade
[80,100] A
[75,79.99] B+
[70,74.99] B
[65,69.99] C+
[60,64.99] C
[55,59.99] D+
[50,54.99] D
[0,49.99] F 16
References
M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,
Data Structures and Algorithms in Java, 6 edition.
Hoboken, NJ: Wiley, 2014.

Image source: http://www.amazon.com

17
References
A. Drozdek, Data structures and algorithms in
Java, 4th edition. Singapore: Cengage Learning
Asia, 2013.

Image source: http://www.amazon.com

18
References
J. Hubbard, Schaum’s Outline of Data Structures
with Java, 2ed, 2 edition. New York: McGraw-Hill,
2009.

Image source: http://www.amazon.com

19
Contact Us
Sec 1 2-4
Image:

Name: Aj. Dr.Paweena Asst. Prof. Dr.Worasak


Suebsombut Rueangsirarak

Email: paweena.sue@mfu.ac.th worasak.rue@mfu.ac.th

20
Review

OBJECT-ORIENTED PROGRAMING
(JAVA—CLASS)
21
Basic Java

22
Image source: M. T. Goodrich et. al., Data Structures and Algorithms in Java
Based Type (Primitive Type)

23
Image source: M. T. Goodrich et. al., Data Structures and Algorithms in Java
Object-Oriented Programming
• Structured (Procedural) Programming
– Algorithm then data structure
– Program is separated to many procedures (functions)
– Good for small problems
• OOP
– Data structure (class) then algorithm
– Program is broken down to many classes. Each class has
data and methods
– Good for large problems

24
OOP vs. Structured Programming

procedure method
Object Data
procedure method

procedure Global Data

method
procedure Object Data
method

Structured OOP

25
Example of OOP <Class & Objects>
Class: Sim
Attributes - Ethic
- Name - Weight
- Gender - Height
- Hair color - Personality

Behavior: Eat, Dance, Sleep

Emily Judy Heike Mike Lucy Mica Sandy


Object: Sandy
- Name: Sandy
- Gender: Female
- Hair color: Red
- Ethic: Latin
- Weight: 45
- Height: 160
- Personality: Nice

26
Class’s Components
• Properties (Variables)
• Behaviors (Methods) I have
ID and
name

• Ex: a class of student


I can
• Properties: ID, name study

• Behaviors: study

27
Class Diagram
• Ex: a class of student
• Properties: ID, name
• Behaviors: study

28
Class Declaration
modifier class CLASS_NAME {
modifier TYPE variable; Attribute

modifier method( ){
statement; Method

}
}

29
Modifier
Java applies concept of information hiding by using
modifiers which are applied on both attribute &
method
Some Examples of Modifier
• Private can be referred only within its own class
• Public can be referred from other classes

public private

30
Lecture Assignment 1
• Design a class of “Dog” by
– listing some properties and methods
– drawing a class diagram
• Convert to Java code

* write to the re-use paper provided by lecturer 31


Objects
• A class is only a template. We cannot use it
directly
• To use a class, we need to create its objects

Object: student1

Class: Student
Object: student2 32
Creating Objects

Object: student1 Object: student2 33


Using Sim Class
When class is in used.
Class is a type, Instance is a variable

New instance
Call public
method members

34
Getter and Setter
• Usually class’s variables are designed to be
private (accessible only within its class)
• To access them outside of its class, we need
two public methods: getter and setter

ID and name
are private

35
Class: “Sim”

Getter/ Setter
Other class

Error on these statements, “By Design, attribute is


age is private variable member
recommend to be private”
Therefore, we need..
– Setter (Mutator)
36
– Getter (Accessor)
Getter
• Getter is a method to return a variable to
other classes

37
Setter
• Setter is a method to change a variable’s
value from other classes

38
Using Setter and Getter
• Use outside of their class
• object.setter() and
object.getter()

39
Ex. Getter/ Setter
Modify code of Class: “Sim”

………………………
Also a Setter for setting
name

New Setter is added


for setting age variable

New Getter is added


for returning age

40
Ex. Getter/ Setter (Cont.)
Class: “Sim” after modifying
Other class which create
object: “toby” inside and then
call method: ‘setAge()’ for
setting age + method:
‘getAge()’ for getting age

………………………

Result:
18

41
Lecture Assignment 2
• From a class “Dog” of which you have
created previously, create setter and getter.
Draw a new class diagram and Java code.

* write to the re-use paper provided by lecturer 42


CONSTRUCTOR

43
Constructor
• Each instances contains different value of data
members

• For convenience, Java provides Constructor


which is method called when creating new
instance to initialize/set data members.

• Method with same name as class name

44
Constructor (Cont.)
• One class can contains multiple constructors
which get different arguments

• When constructor is not declared, a constructor


without arguments is default

45
Sample: Constructor

Multiple Constructors
with
Methods with
different arguments
• Same name as
class name
• No return type
defined

46
Constructor: How does it work?
How many created
objects (people)???
Which constructor is
called?

47
EX. Constructor
• A method having the
same name of its class
• To give the initial
values to class’s
variables
• No return type

48
Exercise
• Add a constructor to your class “Dog”

* write to the re-use paper provided by lecturer 49


Overloaded Constructors
• Two or more
constructors with
different types or
number of
parameters

50
Wrapper Types
• Object types comparable with Base types

51
Image source: M. T. Goodrich et. al., Data Structures and Algorithms in Java
Self Study
• Review the following OOP concepts by
yourself
– Com Pro: chapter 10
– Static Variable & Static Method
– Keeping encapsulation
– Inheritance
– Polymorphism
– Abstract class and Interface
– Exceptions
52
– Nested classes
Class Design Hints
1. Always keep data private
2. Always initialize data (e.g. by constructor)
3. Use setter and getter methods
4. Make classes and methods’ names reflect
their responsibilities
5. If a class is too large, try to split it to
smaller classes

53
Summary
• Why do we need different data structures?
• What would be advantages for studying
data structures and algorithms?
• How different is structural programming
and OOP?
• What is data encapsulation?

54

You might also like