1. Algorithm and characteristics of an algorithm.
2. Rules to be followed for design and analysis of an algorithm.
3. The differentiation of data structures, file structures, and storage structures.
4. Top-down and bottom-up design approaches through examples.
5. Rules to be followed while writing the pseudo code of an algorithm.
6. Abstract data type and its necessity in a program.
Binary search works on sorted arrays. Binary search begins by comparing an element in the middle of the array with the target value. If the target value matches the element, its position in the array is returned. If the target value is less than the element, the search continues in the lower half of the array.
1. Introduction to time and space complexity.
2. Different types of asymptotic notations and their limit definitions.
3. Growth of functions and types of time complexities.
4. Space and time complexity analysis of various algorithms.
Binary search works on sorted arrays. Binary search begins by comparing an element in the middle of the array with the target value. If the target value matches the element, its position in the array is returned. If the target value is less than the element, the search continues in the lower half of the array.
1. Introduction to time and space complexity.
2. Different types of asymptotic notations and their limit definitions.
3. Growth of functions and types of time complexities.
4. Space and time complexity analysis of various algorithms.
Presentation On Binary Search Tree using Linked List Concept which includes Traversing the tree in Inorder, Preorder and Postorder Methods and also searching the element in the Tree
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...Umesh Kumar
PPT On Sorting And Searching Concepts In Data Structure. In Many Programming Concepts We Use This Tricks In Algorithms....So Wacth,Learn And Enjoy Study.....Thanks
The Collections Framework (java.util)- Collections overview, Collection Interfaces, The Collection classes- Array List, Linked List, Hash Set, Tree Set, Priority Queue, Array Deque. Accessing a Collection via an Iterator, Using an Iterator, The For-Each alternative, Map Interfaces and Classes, Comparators, Collection algorithms, Arrays, The Legacy Classes and Interfaces- Dictionary, Hashtable ,Properties, Stack, Vector More Utility classes, String Tokenizer, Bit Set, Date, Calendar, Random, Formatter, Scanner
Presentation On Binary Search Tree using Linked List Concept which includes Traversing the tree in Inorder, Preorder and Postorder Methods and also searching the element in the Tree
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...Umesh Kumar
PPT On Sorting And Searching Concepts In Data Structure. In Many Programming Concepts We Use This Tricks In Algorithms....So Wacth,Learn And Enjoy Study.....Thanks
The Collections Framework (java.util)- Collections overview, Collection Interfaces, The Collection classes- Array List, Linked List, Hash Set, Tree Set, Priority Queue, Array Deque. Accessing a Collection via an Iterator, Using an Iterator, The For-Each alternative, Map Interfaces and Classes, Comparators, Collection algorithms, Arrays, The Legacy Classes and Interfaces- Dictionary, Hashtable ,Properties, Stack, Vector More Utility classes, String Tokenizer, Bit Set, Date, Calendar, Random, Formatter, Scanner
Data may be organized in many different ways; the logical or mathematical model of a particular organization of data is called "Data Structure". The choice of a particular data model depends on two considerations:
It must be rich enough in structure to reflect the actual relationships of the data in the real world.
The structure should be simple enough that one can effectively process the data when necessary.
Data Structure Operations
The particular data structure that one chooses for a given situation depends largely on the nature of specific operations to be performed.
The following are the four major operations associated with any data structure:
i. Traversing : Accessing each record exactly once so that certain items in the record may be processed.
ii. Searching : Finding the location of the record with a given key value, or finding the locations of all records which satisfy one or more conditions.
iii. Inserting : Adding a new record to the structure.
iv. Deleting : Removing a record from the structure.
Primitive and Composite Data Types
Primitive Data Types are Basic data types of any language. In most computers these are native to the machine's hardware.
Some Primitive data types are:
Integer
GRID COMPUTING: STRATEGIC DECISION MAKING IN RESOURCE SELECTIONIJCSEA Journal
The rapid development of computer networks around the world generated new areas especially in computer instruction processing. In grid computing, instruction processing is performed by external processors available to the system. An important topic in this area is task scheduling to available external resources. However, we do not deal with this topic here. In this paper we intend to work on strategic decision making on selecting the best alternative resources for processing instructions with respect to criteria in special conditions. Where the criteria might be security, political, technical, cost, etc. Grid computing should be determined with respect to the processing objectives of instructions of a program. This paper seeks a way through combining Analytic Hierarchy Process (AHP) and Technique for Order of Preference by Similarity to Ideal Solution (TOPSIS) to help us in ranking and selecting available resources according to considerable criteria in allocating instructions to resources. Therefore, our findings will help technical managers of organizations in choosing as well as ranking candidate alternatives for processing program instructions.
Download Complete Material - https://www.instamojo.com/prashanth_ns/
This Data Structures and Algorithms contain 15 Units and each Unit contains 60 to 80 slides in it.
Contents…
• Introduction
• Algorithm Analysis
• Asymptotic Notation
• Foundational Data Structures
• Data Types and Abstraction
• Stacks, Queues and Deques
• Ordered Lists and Sorted Lists
• Hashing, Hash Tables and Scatter Tables
• Trees and Search Trees
• Heaps and Priority Queues
• Sets, Multi-sets and Partitions
• Dynamic Storage Allocation: The Other Kind of Heap
• Algorithmic Patterns and Problem Solvers
• Sorting Algorithms and Sorters
• Graphs and Graph Algorithms
• Class Hierarchy Diagrams
• Character Codes
1. Introduction to data structures and their types.
2. Linear, non-linear, homogeneous, non-homogeneous, static and
dynamic data structures.
3. Linear data structures - array, stack, queue and linked list.
4. Non-linear data structures - tree and graph.
1. Introduction to searching and sorting algorithms
2. Types of searching algorithms - Linear search and Binary search.
3. Basic iterative sorting - Bubble sort, Selection sort and Insertion sort.
4. Time and space complexity analysis of searching and sorting
algorithms.
1. Multivariate and High Dimensional Problems.
2. Visualization
2.1 Three Dimensional Visualization
2.2 Parallel Coordinate Plots
3. Multivariate Random Vectors and Data
3.1.Population Case
3.2. Sample Case
3.3. Multivariate Random Vectors
3.4. Gaussian Random Vectors
3.5. Marginal and Conditional Normal Distributions.
What is SMC. SMC Models. Type of Adversaries. Applications. Goals. Actions. Types of Operations. Randomization Techniques. Oblivious Transfer. Cryptographic Techniques
We have compiled the most important slides from each speaker's presentation. This year’s compilation, available for free, captures the key insights and contributions shared during the DfMAy 2024 conference.
About
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Technical Specifications
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
Key Features
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface
• Compatible with MAFI CCR system
• Copatiable with IDM8000 CCR
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
Application
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
Forklift Classes Overview by Intella PartsIntella Parts
Discover the different forklift classes and their specific applications. Learn how to choose the right forklift for your needs to ensure safety, efficiency, and compliance in your operations.
For more technical information, visit our website https://intellaparts.com
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
HEAP SORT ILLUSTRATED WITH HEAPIFY, BUILD HEAP FOR DYNAMIC ARRAYS.
Heap sort is a comparison-based sorting technique based on Binary Heap data structure. It is similar to the selection sort where we first find the minimum element and place the minimum element at the beginning. Repeat the same process for the remaining elements.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
1. Algorithm Specification and Data Abstraction
Dr. Ashutosh Satapathy
Assistant Professor, Department of CSE
VR Siddhartha Engineering College
Kanuru, Vijayawada
September 22, 2022
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 1 / 40
2. Outline
1 Algorithm Specification
Introduction to Algorithm
Algorithm Design and Data Structure
Analyzing an Algorithm
Algorithm Design Approaches
Pseudocode Conventions
2 Data Abstraction
Data Types
Abstract Data Types
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 2 / 40
3. Outline
1 Algorithm Specification
Introduction to Algorithm
Algorithm Design and Data Structure
Analyzing an Algorithm
Algorithm Design Approaches
Pseudocode Conventions
2 Data Abstraction
Data Types
Abstract Data Types
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 3 / 40
4. Introduction to Algorithm
An algorithm is a well defined computational procedure that takes
some value, or set of values, as input and produces some value, or set
of values as output.
It is thus a sequence of computational steps that transform the input
into the output.
The algorithm describes a computational procedure for achieving that
input/output relationship.
An algorithm is a finite set of instructions which accomplish a
particular task.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 4 / 40
5. Introduction to Algorithm
Every algorithm must satisfy the following criteria.
1 Input: There are some (possibly empty) input data which are
externally supplied to the algorithm.
2 Output: There will be at least one output.
3 Definiteness: Each instruction/step of the algorithm must be clear
and unambiguous.
4 Finiteness: If we trace out the instruction/step of an algorithm, then
for all cases, the algorithm will terminate after a finite number of
steps.
5 Effectiveness: The steps of an algorithm must be sufficiently basic
that it can be carried out by a person mechanically using pen and
paper.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 5 / 40
6. Introduction to Algorithm
Algorithm 1 Swap two numbers using third variable
1: start
2: read two values into two variables a, b
3: declare third variable, temp
4: temp = a
5: a = b
6: b = temp
7: write a, b ▷ Display a and b values
8: stop
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 6 / 40
7. Outline
1 Algorithm Specification
Introduction to Algorithm
Algorithm Design and Data Structure
Analyzing an Algorithm
Algorithm Design Approaches
Pseudocode Conventions
2 Data Abstraction
Data Types
Abstract Data Types
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 7 / 40
8. Algorithm Design and Data Structure
To write a computer program for solving a problem we must start with the
following four tasks:
Identify the data items and their relationship.
Find the operations that must be performed on these data items.
Determine the best method to represent these data items in
computer’s memory.
Select a suitable programming language which can efficiently code the
identified data representation.
Note
These data items can be arranged in different ways depending on the
logical relationship between them. Arrangement of these data items is
called data structures. E.g., arrays, records, lists, and files
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 8 / 40
9. Algorithm Design and Data Structure
Important
The storage of data in primary memory is called as data structure
where as the storage of data in secondary memory is called file
structure.
The representation or the data structure in computer’s memory which
is known as storage structure.
Selection of a programming language best suited to represent the
data structure.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 9 / 40
10. Outline
1 Algorithm Specification
Introduction to Algorithm
Algorithm Design and Data Structure
Analyzing an Algorithm
Algorithm Design Approaches
Pseudocode Conventions
2 Data Abstraction
Data Types
Abstract Data Types
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 10 / 40
11. Analyzing an Algorithm
Algorithms are designed using basic program constructs like sequence,
selection or branching, repetition, etc.
We need methods to separate bad algorithm from good ones and to
choose the most effective approach for our problem.
In analyzing an algorithm, the first approach is to check the
correctness of the algorithm.
Tracing the algorithm.
Checking the algorithm for logical correctness.
Implementing the algorithm.
Testing the algorithm, which can yield correct output for all possible
combinations of input values. This is called program proving or
program verification.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 11 / 40
12. Analyzing an Algorithm
Another approach of analysis is to check the simplicity of the
algorithm.
The simplest way of solving the problem is not always the best one.
It is necessary to evaluate the complexity of the algorithm.
The complexity of the algorithm is determined in terms of time and
space.
These determine the amount of time and storage an algorithm may
require for execution.
Finally, predict the performance of the algorithm in the best, worst,
and average cases.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 12 / 40
13. Outline
1 Algorithm Specification
Introduction to Algorithm
Algorithm Design and Data Structure
Analyzing an Algorithm
Algorithm Design Approaches
Pseudocode Conventions
2 Data Abstraction
Data Types
Abstract Data Types
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 13 / 40
14. Algorithm Design Approaches
Figure 1.1: Top-down and bottom-up design approaches
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 14 / 40
15. Algorithm Design Approaches
A complicated algorithm is split into small parts called modules, and
the process of splitting is known as modularization.
Modularization significantly reduces the complications of designing an
algorithm and make its process more easier to design and implement.
It is necessary to evaluate the complexity of the algorithm.
In the top-down approach, the complex module is divided into
submodules.
In bottom-up approach begins with elementary modules and then
combine them further.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 15 / 40
16. Algorithm Design Approaches
Basis for
Comparison
Top-down
Approach
Bottom-up
Approach
Basic
- Break the massive
problem into multiple
subproblems.
- Solves the low-level
problems and integrate
them into a larger one.
Process
- Submodules are
solitarily analyzed.
- Examine what data is
to be encapsulated, and
implies the concept of
information hiding.
Communication
- The communications
is less among modules.
- In this, modules must
have communication.
Redundancy
- Contain redundant
information.
- Redundancy can be
eliminated.
Table 1.1: Comparison between top-down and bottom-up design approaches.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 16 / 40
17. Algorithm Design Approaches
Algorithm 2 Top-down approach: nth number in the Fibonacci sequence
Require: non-negative integer n
Ensure: F(n); nth number in the Fibonacci sequence.
1: function F(n)
2: if n ≤ 1 then
3: return n
4: else
5: return F(n − 1) + F(n − 2)
6: end if
7: end function
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 17 / 40
18. Algorithm Design Approaches
Algorithm 3 Bottom-up approach: nth number in the Fibonacci sequence
Require: non-negative integer n
Ensure: nth number in the Fibonacci sequence.
1: if n = 0 or n = 1 then
2: print n
3: else
4: A ← 0
5: B ← 1
6: for I ← 2 to n do
7: Temp ← A + B
8: A ← B
9: B ← Temp
10: end for
11: write B
12: end if
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 18 / 40
19. Algorithm Design Approaches
Algorithm 4 Top-down approach: Multiplication of 1 to n numbers
Require: non-negative integer n
Ensure: PRODUCT(n); Multiplication of 1 to n numbers.
1: function PRODUCT(n)
2: if n = 1 then
3: return 1
4: else
5: return n ∗ PRODUCT(n − 1)
6: end if
7: end function
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 19 / 40
20. Algorithm Design Approaches
Algorithm 5 Bottom-up approach: Multiplication of 1 to n numbers
Require: non-negative integer n
Ensure: Multiplication of 1 to n numbers.
1: Result ← 1
2: for I ← 1 to n do
3: Result ← Result ∗ I
4: end for
5: write Result
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 20 / 40
21. Outline
1 Algorithm Specification
Introduction to Algorithm
Algorithm Design and Data Structure
Analyzing an Algorithm
Algorithm Design Approaches
Pseudocode Conventions
2 Data Abstraction
Data Types
Abstract Data Types
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 21 / 40
22. Pseudocode Conventions
Till now, we have described each step of an algorithm using natural
language like English. Here, we present most of our algorithms using
pseudocodes that resemble C and Pascal.
1 Comments begin with // and continue until the end of line.
2 Blocks are indicated with matching braces: { and }. The body of a
procedure also forms a block. Statements are delimited by ;
3 An identifier begins with a letter. The data types of variables are not
explicitly declared. The types will be clear from the context. Whether
it is global or local to a procedure will also be evident from context.
4 Compound data types can be formed with records.
node = record
{ datatype 1 data 1;
datatype 2 data 2;
node ∗ link; }
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 22 / 40
23. Pseudocode Conventions
5 link is a pointer to the record type node. For example, if p points to
a record of type node, p←data 1 stands for the value of the first
field. If q is a record of type node, q.data 1 denotes its first field.
6 Assignment of values to variables is done using the assignment
operator or leftwards arrow symbol.
variable := expression; or variable ← expression;
7 There are two boolean values true and false. In order to produce
these values, the logical operators and, or and not and the relational
operators <, ≤, =, ̸=, ≥ and > are provided.
8 Elements of multidimensional arrays are accessed using [ and ]. E.g.,
if A is a two dimensional array, the (i, j)th element of the array is
denoted as A[i, j]. Array indices start at zero.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 23 / 40
24. Pseudocode Conventions
9 The following statements are employed for while, for and do...while.
while < condition > do
Statement 1
Statement 2
Statement n
end while
while < condition > do {
Statement 1;
Statement 2;
Statement n; }
10 The general form of a for loop is
for I ← l to m step s do
Statement 1
Statement 2
Statement n
end for
for I := l to m step s do {
Statement 1;
Statement 2;
Statement n; }
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 24 / 40
25. Pseudocode Conventions
11 The general form of a do...while loop is
do
Statement 1
Statement 2
Statement n
while< condition >
do{
Statement 1;
Statement 2;
Statement n; }
while< condition >
12 A conditional statement has the following forms.
if < condition > then < statement >
if < condition > then < statement1 > else < statement2 > =0
13 We also employ the following case statement.
case {
:< condition1 >: < statement 1 >
:< condition2 >: < statement 2 >
: else : < statement n > }
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 25 / 40
26. Pseudocode Conventions
14 Input and output are done using the instructions read and write.
15 There is only one type of procedure: Algorithm or Procedure. An
algorithm consists of a heading and a body. The heading takes the
form.
Algorithm Name (< P1, P2, ..., P3 >)
Algorithm 6 Maximum of n given numbers
1: procedure MAX(A, n)
2: Result ← A[1]
3: for i ← 2 to n do
4: if A[i] > Result then Result ← A[i]
5: end if
6: end for
7: return Result
8: end procedure
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 26 / 40
27. Pseudocode Conventions
Algorithm 7 Selection Sort
1: procedure SelectionSort(a, n)
2: //Sort the array a[1 : n] into ascending order.
3: for i ← 1 to n do
4: j ← i
5: for k ← i + 1 to n do
6: if a[k] < a[j] then j ← k
7: end if
8: end for
9: t ← a[i]
10: a[i] ← a[j]
11: a[j] ← t
12: end for
13: end procedure
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 27 / 40
28. Pseudocode Conventions
Algorithm 8 Towers of Hanoi
1: procedure TowerOfHanoi(n, x, y, z)
2: {
3: //Move the top n disks from tower x to tower y.
4: if n ≥ 1 then {
5: TOWEROFHANOI(n − 1, x, y, z);
6: write (”move top disk from tower”, x, ”to top of tower”, y);
7: TOWEROFHANOI(n − 1, z, y, x);
8: }
9: }
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 28 / 40
29. Outline
1 Algorithm Specification
Introduction to Algorithm
Algorithm Design and Data Structure
Analyzing an Algorithm
Algorithm Design Approaches
Pseudocode Conventions
2 Data Abstraction
Data Types
Abstract Data Types
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 29 / 40
30. Data Types
We are familiar with the basic data types of C. These include char,
int, float, and double. Some of these data types may be modified by
the keywords short, long, and unsigned.
In addition to these basic types, C helps us by providing two
mechanisms for grouping data together. These are the array and the
structure.
For example, An array is a collection of elements of the same basic
data type.
They are declared implicitly, for example, int list[5] defines a
five-element array of integers whose legitimate subscripts are in the
range 0 ... 4.
Structures are collections of elements whose data types need not be
the same.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 30 / 40
31. Data Types
Data types are declarations for variables. This determines the type
and size of data associated with variables, and a set of operations
that act on those objects.
Whether your program is dealing with predefined data types or
user-defined data types, these two aspects must be considered:
objects and operations.
For example, the data type int consists of the objects {0, +1, -1,
+2, -2, ..., INT MAX, INT MIN}, where INT MAX and
INT MIN are the largest and smallest integers that can be
represented on your machine.
The operations on integers are many, and would certainly include the
arithmetic operators +, -, *, /, and %.
There is also testing for equality/inequality and the operation that
assigns an integer to a variable.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 31 / 40
32. Data Types
Knowing all of the facts about the operations on a data type, we
might also want to know about how the objects of the data type are
represented.
E.g., a char is represented as a bit string occupying 1 byte of
memory on most computers, where as an int might occupy 2 or
possibly 4 bytes of memory. If 2 eight-bit bytes are used, then
INT MAX is 215 -1 = 32,767.
Knowing the representation of the objects of a data type can be
useful and dangerous.
It has been observed by many software designers that hiding the
representation of objects of a data type from its users is a good
design strategy.
In that case, the user is constrained to manipulate the objects solely
through the functions that are provided.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 32 / 40
33. Outline
1 Algorithm Specification
Introduction to Algorithm
Algorithm Design and Data Structure
Analyzing an Algorithm
Algorithm Design Approaches
Pseudocode Conventions
2 Data Abstraction
Data Types
Abstract Data Types
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 33 / 40
34. Abstract Data Types
An Abstract Data Type (ADT) is a data type that is organized in
such a way that the specification of the objects and the operations
on the objects is separated from the representation of the objects
and the implementation of the operations.
The specification consists of the names of every function, the type
of its arguments and result.
There should also be a description of what the function does, but
without appealing to internal representation or implementation
details.
This requirement is quite important, and it implies that an abstract
data type is implementation-independent.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 34 / 40
35. Abstract Data Types
ADT NaturalNumber is
Objects: An ordered sub-range of the integers starting at zero and ending
at the maximum integer (INT-MAX) on the computer.
Functions: for all x, y ∈ NaturalNumber; TRUE, FALSE ∈ Boolean,
where +, -, <, and == are the usual integer operations.
Functions Operations
NaturalNumber Zero() 0
Boolean IsZero(x)
if (x) return FALSE
else return TRUE
Boolean Equal(x, y)
if (x == y) return TRUE
else return FALSE
NaturalNumber Successor(x)
if (x == INT MAX) return x
else return x+1
Table 2.1: Abstract data type NautralNumber
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 35 / 40
36. Abstract Data Types
Functions Operations
NaturalNumber Add(x, y)
if (x+y <= INT MAX) return x+y
else return INT MAX
NaturalNumber Subtract(x, y)
if(x<y) return 0
else return x-y
Table 2.2: Abstract data type NautralNumber
The ADT definition begins with the name of the ADT. There are two
main sections in the definition: the objects and the functions.
The objects are defined in terms of the integers, but we make no
explicit reference to their representation.
For each function, we place the result type to the left of the function
name and a definition of the function to the right.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 36 / 40
37. Abstract Data Types
ADT is a type (or class) for objects whose behavior is defined by a
set of value and a set of operations.
The definition of ADT only mentions what operations are to be
performed but not how these operations will be implemented.
It does not specify how data will be organized in memory and what
algorithms will be used for implementing the operations.
It is called abstract because it gives an implementation-independent
view. The process of providing only the essentials and hiding the
details is known as abstraction.
A user only needs to know what a data type can do, but not how it
will be implemented. Think of ADT as a black box which hides the
inner structure and design of the data type.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 37 / 40
38. Abstract Data Types
Figure 2.1: Abstract data types in data structures
If Stack, Queue and Linked List are the ADTs, then {push(),
pop(), peep()}, {enque(), dequeqe()}, {insert(), delete()} are
the few operations performed on these data structures.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 38 / 40
39. Summary
Here, we have discussed
Algorithm and characteristics of an algorithm.
Rules to be followed for design and analysis of an algorithm.
The differentiation of data structures, file structures, and storage
structures.
Top-down and bottom-up design approaches through examples.
Rules to be followed while writing the pseudo code of an algorithm.
Abstract data type and its necessity in a program.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 39 / 40
40. For Further Reading I
H. Sahni and A. Freed.
Fundamentals of Data Structures in C (2nd edition).
Universities Press, 2008.
A. K. Rath and A. K. Jagadev.
Data Structures Using C (2nd edition).
Scitech Publications, 2011.
Dr. Ashutosh Satapathy Algorithm Specification and Data Abstraction September 22, 2022 40 / 40