0% found this document useful (0 votes)
2 views

Data Stuctures and Algorithms

The document provides an overview of data structures and algorithms, emphasizing their importance in computer science. It discusses key concepts such as algorithms, their characteristics, and the distinction between imperative and declarative programming. Additionally, it covers the fundamentals of data structures, their goals, features, and classifications, highlighting the need for efficient data management.

Uploaded by

47bdtyftsy
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)
2 views

Data Stuctures and Algorithms

The document provides an overview of data structures and algorithms, emphasizing their importance in computer science. It discusses key concepts such as algorithms, their characteristics, and the distinction between imperative and declarative programming. Additionally, it covers the fundamentals of data structures, their goals, features, and classifications, highlighting the need for efficient data management.

Uploaded by

47bdtyftsy
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/ 21

Data Structures

and
Algorithms
Introduction
Chapter 1

Reference:
JOHN BULLINARIA
School of Computer Science
University of Birmingham
Birmingham, UK
Version of 27 March 2019

MARK ANTHONY C. CATALUÑA


CSIT Instructor
Session Objectives:

Know the fundamental question of algorithm.


Understand the importance of algorithms.
Articulate basic terminology, needs, goals and features of data structures.

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
Introductory activity:

As student in the Computer Science and Information Technology of NORSU Bais,


what is your experiences in the subject CSCC/ITS 101 – computer programming I?

In constructing a house or building, what is first required to make the plan more clear
with your clients?

What do you think is needed for the non-programmers or to the mass users of
computer to better understand this complexity of the program codes and processes?

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
1.1 ALGORITHMS AS OPPOSED TO PROGRAMS
An algorithm for a particular task can be defined as “a finite sequence of
instructions, each of which has a clear meaning and can be performed with a finite
amount of effort in a finite length of time". As such, an algorithm must be precise
enough to be understood by human beings. However, in order to be executed by a
computer, we will generally need a program that is written in a rigorous formal
language; and since computers are quite inflexible compared to the human mind,
programs usually need to contain more details than algorithms.

It is also worth bearing in mind the distinction between different programming


paradigms: Imperative Programming describes computation in terms of instructions
that change the program/data state, whereas Declarative Programming species what
the program should accomplish without describing how to do it.

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
Key Differences:
➢ Imperative is more about describing the steps to achieve a task, whereas declarative is
about describing the result you want.
➢ Imperative programming gives you more control over the flow and state of the program,
while declarative abstracts away these details.
➢ Imperative languages often require more code to manage the flow and state, while
declarative languages are generally more concise and easier to reason about for high-level
tasks.

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
Algorithms can obviously be described in plain English, and we will sometimes do that.
However, for computer scientists it is usually easier and clearer to use something that
comes somewhere in between formatted English and computer program code, but is not
runnable because certain details are omitted. This is called pseudocode, which comes in
a variety of forms. Often these notes will present segments of pseudocode that are very
similar to the languages we are mainly interested in, namely the overlap of C and Java,
with the advantage that they can easily be inserted into runnable programs.

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
From the data structure point of view, following are some important categories of algorithms

▪ Search − Algorithm to search an item in a data structure.


▪ Sort − Algorithm to sort items in a certain order.
▪ Insert − Algorithm to insert item in a data structure.
▪ Update − Algorithm to update an existing item in a data structure.
▪ Delete − Algorithm to delete an existing item from a data structure.

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
1.2 FUNDAMENTAL QUESTIONS ABOUT ALGORITHMS
1. What is it supposed to do?
2. Does it really do what it is supposed to do?
3. How efficiently does it do it?

The technical terms normally used for these three aspects are:
1. Specification.
2. Verification.
3. Performance analysis.

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
The specification should formalize the crucial details of the problem that the
algorithm is intended to solve. Sometimes that will be based on a particular
representation of the associated data, and sometimes it will be presented more
abstractly. Typically, it will have to specify how the inputs and outputs of the algorithm
are related, though there is no general requirement that the specification is complete or
non-ambiguous.

However, for more complicated specifications and/or algorithms, the fact that an
algorithm satisfies its specification may not be obvious at all. In this case, we need to
spend some effort verifying whether the algorithm is indeed correct. In general, testing
on a few inputs can be enough to show that the algorithm is incorrect.

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
However, since the number of different potential inputs for most algorithms is
infinite in theory, and huge in practice, more than just testing on particular cases is
needed to be sure that the algorithm satisfies its specification. We need correctness
proofs. Although we will discuss proofs in these notes, and useful relevant ideas like
invariants, we will usually only do so in a rather informal manner (though, of course, we
will attempt to be rigorous). The reason is that we want to concentrate on the data
structures and algorithms.
Finally, the efficiency or performance of an algorithm relates to the resources
required by it, such as how quickly it will run, or how much computer memory it will
use. This will usually depend on the problem instance size, the choice of data
representation, and the details of the algorithm. Indeed, this is what normally drives the
development of new data structures and algorithms. We shall study the general ideas
concerning efficiency in Chapter 5, and then apply them throughout the remainder of
these notes.

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
BASIC CONCEPT OF DATA STRUCTURE

Data structure is a branch of computer science. The study of data structure helps you to
understand how data is organized and how data flow is managed to increase efficiency
of any process or program. Data structure is the structural representation of logical
relationship between data elements. This means that a data structure organizes data
items based on the relationship between the data elements.

Example:
A house can be identified by the house name, location, number of floors
and so on. These structured set of variables depend on each other to
identify the exact house. Similarly, data structure is a structured set of
variables that are linked to each other, which forms the basic component
of a system

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
Characteristics of an Algorithm
Not all procedures can be called an algorithm. An algorithm should have the following characteristics

Unambiguous − Algorithm should be clear and unambiguous. Each of its steps (or phases), and their
inputs/outputs should be clear and must lead to only one meaning.
Input − An algorithm should have 0 or more well-defined inputs.
Output − An algorithm should have 1 or more well-defined outputs and should match the desired output.
Finiteness − Algorithms must terminate after a finite number of steps.
Feasibility − Should be feasible with the available resources.
Independent − An algorithm should have step-by-step directions, which should be independent of any
programming code.

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
Basic Terminologies
Data: Data can be defined as an elementary value or the collection of values, for
example, student's name and its id are the data about the student.
Group Items: Data items which have subordinate data items are called Group item, for
example, name of a student can have first name and the last name.
Record: Record can be defined as the collection of various data items, for example, if
we talk about the student entity, then its name, address, course and marks can be
grouped together to form the record for the student.
File: A File is a collection of various records of one type of entity, for example, if there
are 60 employees in a company, then there will be 60 records in the related file where
each record contains the data about each employee.
Attribute and Entity: An entity represents the class of certain objects. it contains
various attributes. Each attribute represents the particular property of that entity.
Field: Field is a single elementary unit of information representing the attribute of an
entity. MARK ANTHONY C. CATALUÑA
Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
Need for Data Structure
➢ It gives different level of organization data.
➢ It tells how data can be stored and accessed in its elementary level.
➢ Provide operation on group of data, such as adding an item, looking up highest priority item.
➢ Provide a means to manage huge amount of data efficiently.
➢ Provide fast searching and sorting of data.

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
Goals of Data Structure
Correctness: Data structure is designed such that it operates correctly for all kinds of
input, which is based on the domain of interest. In other words, correctness forms the
primary goal of data structure, which always depends on the specific problems that the
data structure is intended to solve.

Efficiency: Data structure also needs to be efficient. It should process the data at high
speed without utilizing much of the computer resources such as memory space. In a real
time state, the efficiency of a data structure is an important factor that determines the
success and failure of the process.

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
Features of Data Structure
Adaptability: Developing software projects such as word processors, Web browsers and
Internet search engine involves large software systems that work or execute correctly
and efficiently for many years. Moreover, software evolves due to ever changing market
conditions or due to emerging technologies.
Robustness: Generally, all computer programmers wish to produce software that
generates correct output for every possible input provided to it, as well as execute
efficiently on all hardware platforms. This kind of robust software must be able to
manage both valid and invalid inputs.
Reusability: Reusability and adaptability go hand-in-hand. It is a known fact that the
programmer requires many resources for developing any software, which makes it an
expensive enterprise. However, if the software is developed in a reusable and adaptable
way, then it can be implemented in most of the future applications. Thus, by
implementing quality data structures, it is possible to develop reusable software, which
tends to be cost effective and time saving.
MARK ANTHONY C. CATALUÑA
Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
Primitive data structures
Primitive data structures are the most basic types of data structures that
serve as the building blocks for more complex structures. They directly store
data values and do not require any additional structure.

Non-primitive Data Structure


Non-primitive data structures are more complex structures that are derived
from primitive data types. They are used to store collections of data and provide
ways to organize, manage, and manipulate that data more efficiently. Unlike
primitive data types, non-primitive data structures can store multiple values and
may allow for more flexible data manipulation.

Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019
CLASSIFICATION OF DATA STRUCTURES
PRIMITIVE DATA STRUCTURE and NON-PRIMITIVE DATA STRUCTURE

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
Comparison between Primitive and Non-Primitive Data Structures

MARK ANTHONY C. CATALUÑA


Data Structures and Algorithms
Reference: JOHN BULLINARIA - School of Computer Science, University of Birmingham – United Kingdom, 27 March 2019 Bachelor of Science in Information Technology
Thank you!
MARK ANTHONY C. CATALUÑA / JETTY A. CASIDO
Data Structure and Algorithm
Bachelor of Science in Information Technology
Second Semester 2022-2023

You might also like