CPE121 - Chapter01 - Introduction To Data Structures and Algorithm
CPE121 - Chapter01 - Introduction To Data Structures and Algorithm
Introduction to
Data Structures
and Algorithm
WMSU Chapter 01
Table 1.
Primitive data types in Java.
For instructional purposes only
Abstract Data Type (ADT)
• ADT is a mathematical model with a collection
of operations defined on the model.
• It specifies the type of data stored.
• It specifies what its operations do but not how
it is done.
• In Java, for example, ADT can be expressed
with an interface, which contains just a list of
methods.
For instructional purposes only
Abstract Data Type (ADT)…
• For example, the following is an interface of
the ADT stack
• Input = There is no user input since the data from where to get the minimum is
already in the program.
• Output = The minimum value from the given set of input elements.
• Definiteness = Each step in the program is precisely defined.
• Finiteness = The declaration, the for loop and the statement to output will all take
a finite time to execute.
• Effectiveness = when run, it returns the minimum among the values in the array
so it is said to be effective. For instructional purposes only
Assignment #2
Examine the given code below. Determine if the code adheres
to the criteria for algorithms. Discuss each criteria.
• Input ?
• Output ?
• Definiteness ?
• Finiteness ?
• Effectiveness ? For instructional purposes only
Activity #5
What does this algorithm represents?
1. Input the number of the integers to compare; call it N.
2. Input the first integer; call it NUM1.
3. Input the second integer; call it LARGE.
4. Set up a counter representing the number of integers that
have been read; call it COUNT. Set COUNT to 2.
5. Compare NUM1 with LARGE; if NUM1 is greater than
LARGE, set LARGE to NUM1.
6. If COUNT equals N, display the value of LARGE and exit.
Otherwise, increment COUNT by 1 and input the next
integer to be compared.
7. Return to Step 5.
For instructional purposes only
• Activity #1 = done
• Activity #2 = due Aug 24, 2022
• Activity #3,4,5 = due Aug 26, 2022 not
later than 2PM