Data Structure - Lesson 1
Data Structure - Lesson 1
Data Structure - Lesson 1
Let’s Start.
What did you do to understand the instruction? Where you able to perform the task
after?
Let’s Level IT UP!
• Have steps that are simple and definite enough to be done by a computer, and
• Terminate after finitely many steps.
Different algorithms may complete the same task with a different set of instructions in
more or less time, space, or effort than others. Algorithms are essential to the way computers
process information, because a computer program is essentially an algorithm that tells the
computer what specific steps to perform (in what specific order) in order to carry out a specified
task Algorithmic problem solving comes in two phases. These includes:
a. human language
b. pseudo code
c. flow chart
EXAMPLE
Problem: Given a list of positive numbers, return the largest number on the list.
Inputs: A list L of positive numbers. This list must contain at least one number.
Characteristics of an Algorithm
1. Each step of an algorithm must be exact; this means that an algorithm must be precise and
ambiguously described. This eliminates any uncertainty. it can also be said to the
characteristic of precision, i.e. the steps are precisely stated(defined).
2. Algorithm must terminate; since the ultimate aim of an algorithm is to solve a problem,
then it must terminate otherwise there won’t be a solution for the problem. This leads to
the fact that an algorithm must have a finite number of steps in its execution. the presence
of endless (infinite) loops must be avoided
3. An algorithm must be effective; this means that an algorithm must provide the correct
answers at all times
4. An algorithm must be general; this means that an algorithm must solve every instance of a
problem
5. Uniqueness: results of each step are uniquely defined and only depend on the input and
the result of the preceding steps.
6. Finiteness: the algorithm stops after a finite number of instructions are executed.
7. Output: the algorithm produces output
Activity 1.1.1
Below are the steps of the program process, you need to create a simple program that
will display the value of max. This is in a form of a short video. You may use an actual code and
show your output.
1. Set max to 0.
2. For each number x in the list L, compare it to max. If x is larger, set max to x.
3. max is now set to the largest number in the list.
1. Outline the algorithmic steps that can be used to add given numbers
2. By using an example, describe how the concept of algorithms can be well presented to a
group of students being introduced
3. With the aid of an appropriate example, explain the characteristics of algorithms
SUGGESTED READING
V. Das, (2008). Principles of Data Structures and Algorithms using C and C++
SAMS. (1999). Teach Yourself Data Structures and Algorithms In 24 hours.
Data Structures. (2010). Using C++, Second Edition, D.S. Malik,