Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

CPE 221

Data Structure and Algorithm

• Basic Concepts
Data Definition defines a particular data with the
following characteristics:

• Atomic.  Definition should define a single


concept.
• Traceable.  Definition should be able to be
mapped to some data element.
• Accurate.  Definition should be unambiguous.
• Clear and Concise.  Definition should be
understandable.
Data Object represents an object having a data.

Data type is a way to classify various types of data


such as integer, string, etc. which determines the
values that can be used with the corresponding
type of data, the type of operations that can be
performed on the corresponding type of data.

There are two data types:


• Built-in Data Type
• Derived Data Type
Built-in Data Type
Those data types for which a language has built-
in support are known as Built-in Data types. For
example, most of the languages provide the
following built-in data types.
• Integers
• Boolean (true, false)
• Floating (Decimal numbers)
• Character and Strings
Derived Data Type
Those data types which are implementation
independent as they can be implemented in one
or the other way are known as derived data types.
These data types are normally built by the
combination of primary or built-in data types and
associated operations on them. For example −
• List
• Array
• Stack
• Queue
Basic Operations
The data in the data structures are processed by certain operations. The
particular data structure chosen largely depends on the frequency of the
operation that needs to be performed on the data structure.
• Searching: This operation is performed to search for a particular
element or a key. The most common searching algorithms are
sequential/linear search and binary search.
• Insertion:  This operation deals with adding an element to the
data structure. This is the most important operation and as a result
of the addition of an element, the arrangement changes and we
need to take care that the data structure remains intact.
• Deletion:  This operation removes an element from the data
structure. The same conditions that are to be considered for
insertion are to be fulfilled in case of the deletion operation as
well.
Basic Operations
• Sorting:  This operation involves arranging the elements in a data
structure in a particular order either ascending or descending.
There are various sorting algorithms that are available for data
structures.
• Traversing: We say that we traverse a data structure when we visit
each and every element in the structure. Traversing is required to
carry out certain specific operations on the data structure.
• Merging: This operation is combining the records in two different
file into a single file. Combining elements of two similar data
structures to form a new data structure of the same type.
Abstract data type (ADTs)
 A data type that is defined entirely by a set of operations is referred
to as Abstract data type or simply ADT
 Abstract data types are a way of separating the specification and
representation of data types
 An ADT is a black box, where users can only see the syntax and
semantics of its operations
 An ADT is a combination of interface and implementation The
interface defines the logical properties of the ADT and especially
the signatures of its operations
 The implementation defines the representation of data structure and
the algorithms that implement the operations
 An abstract data type encapsulates data and functions into a named
data type
Abstract data type (ADTs)
It is similar to a structure in C, but can include functions in it
The basic difference between ADTs and primitive data types is that
the latter allow us to look at the representation, whereas former hide the
representation from us
An ADT consists of a collection of values and operations with the
values derive their meaning solely through the operations that can be
performed upon them
Benefits of using ADTs:
Code is easier to understand Implementations of ADTs can be
changed without requiring changes to the program that uses
the ADTs
 Data Structures: Data Collections
Linear structures
 Array: Fixed-size
 Linked-list: Variable-size
 Stack: Add to top and remove from top
 Queue: Add to back and remove from front
 Priority queue: Add anywhere, remove the highest
priority
 Tree: A branching structure with no loops
 Hash tables: Unordered lists which use a ‘hash function’ to
insert and search
 Graph: A more general branching structure, with less
stringent connection conditions than for a tree
 ADTs Collection
ADT is a data structure and a set of operations which can be
performed on it.
• A class in object-oriented design is an ADT
The pre-conditions define a state of the program which the client
guarantees will be true before calling any method
post-conditions define the state of the program that the object's
method will guarantee to create for you when it returns.
create: Create a new collection
add: Add an item to a collection
delete: Delete an item from a collection find Find an item matching
some criterion in the collection
destroy: Destroy the collection
 Data Structures and ADTs

 A container in which data is being stored Example: structure, file,


or array
 An ADT is a data structure which does not exist within the host
language, but rather must be created out of existing tools
 It is both a collection of data and a set of rules that govern how the
data will be manipulated
 Examples: list, stack, queue, tree, table, and graph
 An ADT sits on top of the data structure, and the rules that govern
the use of the data define the interface between the data structure
and the ADT
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