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

A1 Overview

The document provides an overview of data structures and algorithms, emphasizing their importance in efficiently storing and accessing data. It outlines the characteristics and properties of algorithms, the need for data structures, and various classifications of data structures, including primitive and non-primitive types. Additionally, it discusses algorithm analysis, execution time cases, and basic terminology related to data structures.

Uploaded by

Gaya Gaya
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

A1 Overview

The document provides an overview of data structures and algorithms, emphasizing their importance in efficiently storing and accessing data. It outlines the characteristics and properties of algorithms, the need for data structures, and various classifications of data structures, including primitive and non-primitive types. Additionally, it discusses algorithm analysis, execution time cases, and basic terminology related to data structures.

Uploaded by

Gaya Gaya
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

ITE 115

Data Structures and


Algorithms

• Overview
Objectives
• Understand different programming concepts
such as the different control construct
• Explain what is data structures and algorithm
• Understand the different characteristics of an
algorithm and its properties
• Understand the different classifications of a
data structure
Data Structures are the systematic way of storing or organizing data in
order to use it efficiently. It can be defined as an organized collection
of data that helps a program to access data efficiently and rapidly so
that the entire program can function in an efficient manner.

We know that in the programming world, data is the center and


everything revolves around data. We need to do all data operations
including storing, searching, sorting, organizing, and accessing data
efficiently and only then our program can succeed.

Algorithm is a step-by-step procedure, which defines a set of


instructions to be executed in a certain order to get the desired output.
Algorithms are generally created independent of underlying languages,
i.e. an algorithm can be implemented in more than one programming
language.
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.
Algorithm Properties
An algorithm possesses the following properties:
 It must be correct.
 It must be composed of a series of concrete steps.
 There can be no ambiguity as to which step will be performed
next.
 It must be composed of a finite number of steps.
 It must terminate.
 It takes zero or more inputs
 It should be efficient and flexible
 It should use less memory space as much as possible
 It results in one or more outputs
Various steps in developing Algorithms
Devising the Algorithm:
It’s a method for solving a problem. Each step of an algorithm must
be precisely defined and no vague statements should be used.
Pseudo code is used to describe the algorithm , in less formal
language than a programming language.
Validating the Algorithm:
The proof of correctness of the algorithm. A human must be able to
perform each step using paper and pencil by giving the required
input , use the algorithm and get the required output in a finite
amount of time.
Expressing the algorithm:
To implement the algorithm in a programming language. The
algorithm used should terminate after a finite number of steps.
Algorithm Analysis
Efficiency of an algorithm can be analyzed at two different stages, before
implementation and after implementation. They are the following:
• A Priori Analysis. This is a theoretical analysis of an algorithm.
Efficiency of an algorithm is measured by assuming that all other factors,
for example, processor speed, are constant and have no effect on the
implementation.

• A Posterior Analysis. This is an empirical analysis of an algorithm. The


selected algorithm is implemented using programming language. This is
then executed on target computer machine. In this analysis, actual
statistics like running time and space required are collected.
We shall learn about a priori algorithm analysis. Algorithm analysis deals with
the execution or running time of various operations involved. The running
time of an operation can be defined as the number of computer instructions
executed per operation.
From the data structure point of view, the 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.
Following terms are the foundation terms of a data structure.

• Interface. Each data structure has an interface. Interface


represents the set of operations that a data structure supports.
An interface only provides the list of supported operations,
type of parameters they can accept and return type of these
operations.

• Implementation. Implementation provides the internal


representation of a data structure. Implementation also
provides the definition of the algorithms used in the
operations of the data structure.
Characteristics of a Data Structure

• Correctness Data structure implementation should implement


its interface correctly.

• Time Complexity Running time or the execution time of


operations of data structure must be as small as possible.

• Space Complexity Memory usage of a data structure operation


should be as little as possible.
Need for Data Structure
As applications are getting complex and data rich, there are three
common problems that applications face now-a-days.

• Data Search Consider an inventory of 1 million(10 6) items of a


store. If the application is to search an item, it has to search an item
in 1 million(106) items every time slowing down the search. As data
grows, search will become slower.

• Processor speed Processor speed although being very high, falls


limited if the data grows to billion records.

• Multiple requests As thousands of users can search data


simultaneously on a web server, even the fast server fails while
searching the data.
Execution Time Cases
There are three cases which are usually used to compare various data
structure's execution time in a relative manner.
• Worst Case This is the scenario where a particular data structure
operation takes maximum time it can take. If an operation's worst case
time is ƒ(n) then this operation will not take more than ƒ(n) time
where ƒ(n) represents function of n.
• Average Case This is the scenario depicting the average execution
time of an operation of a data structure. If an operation takes ƒ(n) time
in execution, then m operations will take mƒ(n) time.
• Best Case This is the scenario depicting the least possible execution
time of an operation of a data structure. If an operation takes ƒ(n) time
in execution, then the actual operation may take time as the random
number which would be maximum as ƒ(n).
Basic Terminology
• Data values or set of values.
• Data Item refers to single unit of values. It is the elementary value. In
figure 1, student no. can be data.
• Group Items data items that are divided into sub items. This is the data
item that has more than one sub-items. In figure 1, Student_name has
First Name, Middle Name and Last Name.
• Elementary Items data items that cannot be divided
• Attribute and Entity an entity is that which contains certain attributes or
properties, which may be assigned values.
• Entity Set entities of similar attributes (form an entity set). It is a class
of records. Figure 1 diagram, the student is an entity.
For example, take a particular student.

A student can have the following details as represented pictorially.

STUDENT

STUDENT
NAME AGE GRADE
NUMBER

FIRST MIDDLE LAST


NAME NAME NAME

Figure 1
Basic Terminology
• Field or Attribute a single elementary unit of information representing an
attribute of an entity. Properties of an entity are called attributes and each
field represents an attribute.
• Record a collection of field values of a given entity. It is a collection of
data items. In the above example, data items like student number, Name,
Age, Grade form a record together.
• File a collection of records of the entities in a given entity set. A file is a
collection of records. In the above example, a student entity can have
thousands of records. Thus a file will contain all these records.
Classification of Data Structures
“Data Structures ”deals with the study of how the data is organized
in the memory, how efficiently the data can be retrieved and
manipulated, and the possible ways in which different data items
are logically related.

Types:
• Primitive Data Structure
Ex. int,float,char
• Non-primitive Data Structures
Ex.Arrays,Structures,stacks
• Linear Data Structures
Ex.Stacks,queues,linked list
• Non-Linear Data Structures
Ex.Trees,Graphs
Data Structure Classification
Data structures used in C++ can be classified as follows.

A data structure is a way of organizing the data. So we can classify data


structures as shown into primitive or standard data structures and non-
primitive or user-defined data structures.
We have seen all the data types supported in C++. As this is also a way of
organizing data, we say it’s a standard data structure.
The other data structures are non-primitive and the user has to define them
before using them in a program. These user-defined data structures are
further classified into linear and non-linear data structures.
Classification of Data Structures

1. Primary Data structures are the basic data structures that


directly operate upon the machine instructions. They have
different representations on different computers.
2. All the basic constants (integers, floating point numbers,
character constants, string constants)and pointers are considered
as primary data structures
3. Secondary Data Structures are more complicated data structures
derived from primary data structures
4. They emphasize on grouping same or different data items with
relationship between each data item
5. Secondary data structures can be broadly classified as static data
structures and dynamic data structures
Classification of Data Structures
 If a data structure is created using static memory allocation (ie. a data
structure formed when the number of data items are known in
advance), it is known as static data structure or fixed size data
structure
 If a data structure is created , using dynamic memory allocation(ie. a
data structure formed when the number of data items are not known
in advance) it is known as dynamic data structure or variable size
data structure
 Dynamic data structures can be broadly classified as linear data
structures and non linear data structures
 Linear data structures have a linear relationship between its
adjacent elements. Linked lists are examples of linear data structures.
Classification of Data Structures
 A linked list is a linear dynamic data structure that can grow and
shrink during its execution time
 A circular linked list is similar to a linked list except that the first and
last nodes are interconnected
 Non linear data structures don’t have a linear relationship between its
adjacent elements
 In a linear data structure , each node has a link which points to another
node, whereas in a non linear data structure, each node may point to
several other nodes
 A tree is a nonlinear dynamic data structure that may point to one or
more nodes at a time
 A graph is similar to tree except that it has no hierarchical relationship
between its adjacent elements
References
• https://www.tutorialspoint.com/data_structures
_algorithms/index.htm
• https://www.slideshare.net/DhavalKaneria/intro
duction-to-data-structures-and-algorithm-35441
665
• https://www.softwaretestinghelp.com/cpp-tutori
als/
• https://scanftree.com/Data_Structure/

You might also like