1 Data Structures and Algorithms
1 Data Structures and Algorithms
Algorithms
What is data?
Data
A collection of facts from which conclusion may be
drawn
e.g. Data: Temperature 35°C; Conclusion: It is hot.
Types of data
Textual: For example, your name (Jose Rizal)
Numeric: For example, your ID (XYZ-0001)
Audio: For example, your voice
Video: For example, your voice and picture
What is data structure?
A particular way of storing and organizing data in
a computer so that it can be used efficiently and
effectively.
Linked List
Queue Stack
Tree
The Need for Data Structures
Design Issue:
select and design appropriate data types
Data Structure Operations
Traversing
Accessing each data element exactly once so that certain
items in the data may be processed
Searching
Finding the location of the data element (key) in the
structure
Insertion
Adding a new data element to the structure
Data Structure Operations
Deletion
Removing a data element from the structure
Sorting
Arrange the data elements in a logical order
(ascending/descending)
Merging
Combining data elements from two or more data
structures into one
What is algorithm?
A finite set of instructions which accomplish a particular task
A method or process to solve a problem
Transforms input of a problem to output
Expressions
Standard mathematical symbols are used
o Left arrow sign (←) as the assignment operator in assignment
statements (equivalent to the = operator in Java)
o Equal sign (=) as the equality relation in Boolean expressions
(equivalent to the "= =" relation in Java)
o For example
Sum ← 0
Sum ← Sum + 5