SlideShare a Scribd company logo
Applications in Computer Science
Math V
This Report was Prepared by:
Eng. Ramy Fathi Radwan
Under Supervision of:
Ass.Prof.Eng. Ibrahim El-Kalla
Many Thanks for Ass.Prof Ibrahim El-kalla for his efforts with us
in the summer semester course. Also, for encouraging me to do this
report about Algorithms with its application in Computer Science.
Let Allah rewards his efforts with us with blessing Ensha’Allah.
Eng. Ramy Fathi Radwan
Contents
 Introduction and History of the Science
 Examples for some Algorithms
 Application (Java OOP Search Program)
Introduction
Many problems can be solved by considering them as special cases of general
problems.
For instance, consider the problem of locating the largest integer in the sequence
101,12, 144, 212, 98. This is a specific case of the problem of locating the largest
integer in a sequence of integers. To solve this general problem we must give an
algorithm, which specifies a sequence of steps used to solve this general
problem.We will study algorithms for solving many different types of problems in
this book. For example, in this chapter we will introduce algorithms for two of the
most important problems in computer science, searching for an element in a list
and sorting a list so its elements are in some prescribed order, such as increasing,
decreasing, or alphabetic. Later in the book we will develop algorithms that find
the greatest common divisor of two integers, that generate all the orderings of a
finite set, that find the shortest path between nodes in a network, and for solving
many other problems.
We will also introduce the notion of an algorithmic paradigm, which provides a
general method for designing algorithms. In particular we will discuss brute-force
algorithms, which find solutions using a straightforward approach without
introducing any cleverness.We will also discuss greedy algorithms, a class of
algorithms used to solve optimization problems. Proofs are important in the study
of algorithms. In this chapter we illustrate this by proving that a particular greedy
algorithm always finds an optimal solution.
One important consideration concerning an algorithm is its computational
complexity, which measures the processing time and computer memory required
by the algorithm to solve problems of a particular size.
There are many general classes of problems that arise in discrete mathematics.
For instance:
given a sequence of integers, find the largest one; given a set, list all its subsets;
given a set of integers, put them in increasing order; given a network, find the
shortest path between two vertices. When presented with such a problem, the first
thing to do is to construct a model that translates the problem into a mathematical
context. Discrete structures used in such models include sets, sequences, and
functions—structures discussed in Chapter 2—as well as such other structures as
permutations, relations, graphs, trees, networks, and finite state machines—
concepts that will be discussed in later chapters.
Setting up the appropriate mathematical model is only part of the solution. To
complete the solution, a method is needed that will solve the general problem
using the model. Ideally, what is required is a procedure that follows a sequence
of steps that leads to the desired answer. Such a sequence of steps is called an
algorithm.
The term algorithm is a corruption of the name al-Khowarizmi, a mathematician
of the ninth century, whose book on Hindu numerals is the basis of modern
decimal notation. Originally, the word algorism was used for the rules for
performing arithmetic using decimal notation.
Algorism evolved into the word algorithm by the eighteenth century.With the
growing interest in computing machines, the concept of an algorithm was given a
more general meaning, to include all definite procedures for solving problems, not
just the procedures for performing arithmetic.
In this book, we will discuss algorithms that solve a wide variety of problems. In
this section we will use the problem of finding the largest integer in a finite
sequence of integers to illustrate the concept of an algorithm and the properties
algorithms have. Also, we will describe algorithms for locating a particular
element in a finite set. In subsequent sections, procedures for finding the greatest
common divisor of two integers, for finding the shortest path between two points
in a network, for multiplying matrices, and so on, will be discussed.
PROPERTIES OF ALGORITHMS There are several properties that algorithms
generally share. They are useful to keep in mind when algorithms are described.
These properties are:
Input. An algorithm has input values from a specified set.
Output. From each set of input values an algorithm produces output values from a
specified set. The output values are the solution to the problem.
Definiteness. The steps of an algorithm must be defined precisely.
Correctness. An algorithm should produce the correct output values for each set
of input values.
Finiteness. An algorithm should produce the desired output after a finite (but
perhaps large) number of steps for any input in the set.
Effectiveness. It must be possible to perform each step of an algorithm exactly
and in a finite amount of time.
Generality. The procedure should be applicable for all problems of the desired
form, not just for a particular set of input values.
Examples for Some Algorithms
1- ALGORITHM 1 :
Finding the Maximum Element in a Finite Sequence.
procedure max(a1, a2, . . . , an: integers)
max := a1
for i := 2 to n
if max < ai then max := ai
return max{max is the largest element}
2- ALGORITHM 2 The Linear Search Algorithm.
procedure linear search(x: integer, a1, a2, . . . , an: distinct integers)
i := 1
while (i ≤ n and x = ai )
i := i + 1
if i ≤ n then location := i
else location := 0
return location{location is the subscript of the term that equals x, or is 0 if x
is not found}
3- ALGORITHM The Bubble Sort.
procedure bubblesort(a1, . . . , an : real numbers with n ≥ 2)
for i := 1 to n − 1
for j := 1 to n − i
if aj > aj+1 then interchange aj and aj+1
{a1, . . . , an is in increasing order}
The JAVA OOP Program
This Program lets you choose the number of elements and insert them using an
Insert() method. After you finish inserting the values you use the Search()
method in order to know if the element u want in the Array saved or not and also
to know it’s location in the array.
The Source Code :
/**
* @(#)Search.java
*
* Search application
*
* @author Ramy Fathi Mahmoud Radwan CIE(200)
70011366
* @version 1.00 2013/9/8
*/
import java.util.Scanner;
public class Search {
static int [] A = new int[10];
static int n_elm;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter the num of elments ");
n_elm = input.nextInt() ;
for (int i =0 ; i < n_elm ; i ++ ){
System.out.println(" Please Insert the element
followed by ENTER ");
insert(input.nextInt(),i);
}
System.out.println("Write the Element you Want to
Search for ") ;
search(input.nextInt() , n_elm );
}
public static void insert(int x , int i){
A[i] = x;
}
public static void search( int x , int n_elm )
{
a :
{
for( int i = 0 ; i < n_elm ; i ++ )
{
if (A[i] == x)
{
System.out.println("Yes it Exists in
position " + (i+1));
break a ;
}
if (A[i] != x && i == (n_elm-1))
{
System.out.println("No It Doesn't
Exist in the inserted Array ");
break a ;
}
}
}
}
}

More Related Content

What's hot

Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
Mohammed Hussein
 
SEARCHING
SEARCHINGSEARCHING
SEARCHING
SWATHIR72
 
Linear Search
Linear SearchLinear Search
Linear Search
SWATHIR72
 
Ap Power Point Chpt8
Ap Power Point Chpt8Ap Power Point Chpt8
Ap Power Point Chpt8dplunkett
 
GRID SEARCHING Novel way of Searching 2D Array
GRID SEARCHING Novel way of Searching 2D ArrayGRID SEARCHING Novel way of Searching 2D Array
GRID SEARCHING Novel way of Searching 2D Array
Editor IJCATR
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notationirdginfo
 
Sorting pnk
Sorting pnkSorting pnk
Sorting pnk
pinakspatel
 
Basic data-structures-v.1.1
Basic data-structures-v.1.1Basic data-structures-v.1.1
Basic data-structures-v.1.1
BG Java EE Course
 
Unit 2 algorithm
Unit   2 algorithmUnit   2 algorithm
Unit 2 algorithm
Dabbal Singh Mahara
 
Divide and conquer 1
Divide and conquer 1Divide and conquer 1
Divide and conquer 1Kumar
 
Algorithm designing using divide and conquer algorithms
Algorithm designing using divide and conquer algorithmsAlgorithm designing using divide and conquer algorithms
Algorithm designing using divide and conquer algorithms
SiddhantShelake
 
Big o notation
Big o notationBig o notation
Big o notation
hamza mushtaq
 
Prelim Project OOP
Prelim Project OOPPrelim Project OOP
Prelim Project OOP
Dwight Sabio
 
Data structures using C
Data structures using CData structures using C
Data structures using C
Pdr Patnaik
 
Algorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern AlgorithmsAlgorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern Algorithms
Mohamed Loey
 
Complexity
ComplexityComplexity
Complexity
Malainine Zaid
 
Binary search python
Binary search pythonBinary search python
Binary search python
MaryamAnwar10
 
Search algorithms master
Search algorithms masterSearch algorithms master
Search algorithms master
Hossam Hassan
 

What's hot (20)

Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
SEARCHING
SEARCHINGSEARCHING
SEARCHING
 
Linear Search
Linear SearchLinear Search
Linear Search
 
Ap Power Point Chpt8
Ap Power Point Chpt8Ap Power Point Chpt8
Ap Power Point Chpt8
 
GRID SEARCHING Novel way of Searching 2D Array
GRID SEARCHING Novel way of Searching 2D ArrayGRID SEARCHING Novel way of Searching 2D Array
GRID SEARCHING Novel way of Searching 2D Array
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notation
 
U nit i data structure-converted
U nit   i data structure-convertedU nit   i data structure-converted
U nit i data structure-converted
 
Sorting pnk
Sorting pnkSorting pnk
Sorting pnk
 
Basic data-structures-v.1.1
Basic data-structures-v.1.1Basic data-structures-v.1.1
Basic data-structures-v.1.1
 
Unit 2 algorithm
Unit   2 algorithmUnit   2 algorithm
Unit 2 algorithm
 
Divide and conquer 1
Divide and conquer 1Divide and conquer 1
Divide and conquer 1
 
Algorithm designing using divide and conquer algorithms
Algorithm designing using divide and conquer algorithmsAlgorithm designing using divide and conquer algorithms
Algorithm designing using divide and conquer algorithms
 
Big o notation
Big o notationBig o notation
Big o notation
 
Prelim Project OOP
Prelim Project OOPPrelim Project OOP
Prelim Project OOP
 
Data structures using C
Data structures using CData structures using C
Data structures using C
 
Algorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern AlgorithmsAlgorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern Algorithms
 
Complexity
ComplexityComplexity
Complexity
 
Binary search python
Binary search pythonBinary search python
Binary search python
 
Search algorithms master
Search algorithms masterSearch algorithms master
Search algorithms master
 

Viewers also liked

Chap08
Chap08Chap08
Chap08
Syam Kumar
 
#1 designandanalysis of algo
#1 designandanalysis of algo#1 designandanalysis of algo
#1 designandanalysis of algo
Brijida Charizma Ardoña-Navarro
 
Algorithms - Aaron Bloomfield
Algorithms - Aaron BloomfieldAlgorithms - Aaron Bloomfield
Algorithms - Aaron Bloomfield
Reggie Niccolo Santos
 
Array Presentation
Array PresentationArray Presentation
Array Presentation
Deep Prajapati Microplacer
 
Analysis Of Algorithms I
Analysis Of Algorithms IAnalysis Of Algorithms I
Analysis Of Algorithms ISri Prasanna
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
Julie Iskander
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
jehan1987
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
Eduardo Bergavera
 

Viewers also liked (10)

Chap08
Chap08Chap08
Chap08
 
#1 designandanalysis of algo
#1 designandanalysis of algo#1 designandanalysis of algo
#1 designandanalysis of algo
 
Algorithms - Aaron Bloomfield
Algorithms - Aaron BloomfieldAlgorithms - Aaron Bloomfield
Algorithms - Aaron Bloomfield
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
Array Presentation
Array PresentationArray Presentation
Array Presentation
 
Analysis Of Algorithms I
Analysis Of Algorithms IAnalysis Of Algorithms I
Analysis Of Algorithms I
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
RSA ALGORITHM
RSA ALGORITHMRSA ALGORITHM
RSA ALGORITHM
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
 

Similar to Algorithms

Discrete structure ch 3 short question's
Discrete structure ch 3 short question'sDiscrete structure ch 3 short question's
Discrete structure ch 3 short question's
hammad463061
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
SayanSen36
 
Algoritmos
AlgoritmosAlgoritmos
Algoritmos
Fab Lab LIMA
 
Design & Analysis Of Algorithm
Design & Analysis Of AlgorithmDesign & Analysis Of Algorithm
Design & Analysis Of Algorithm
Computer Hardware & Trouble shooting
 
Lecture 01-2.ppt
Lecture 01-2.pptLecture 01-2.ppt
Lecture 01-2.ppt
RaoHamza24
 
Cuckoo Search: Recent Advances and Applications
Cuckoo Search: Recent Advances and ApplicationsCuckoo Search: Recent Advances and Applications
Cuckoo Search: Recent Advances and Applications
Xin-She Yang
 
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdfADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
RGPV De Bunkers
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptx
skilljiolms
 
Algorithm
AlgorithmAlgorithm
Algorithm
nivlayalat
 
Csallner algorithms1
Csallner algorithms1Csallner algorithms1
Csallner algorithms1
seshagiri rao
 
chapter 1
chapter 1chapter 1
chapter 1
yatheesha
 
DATA STRUCTURE.pdf
DATA STRUCTURE.pdfDATA STRUCTURE.pdf
DATA STRUCTURE.pdf
ibrahim386946
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
RobinRohit2
 
Types of Algorithms.ppt
Types of Algorithms.pptTypes of Algorithms.ppt
Types of Algorithms.ppt
ALIZAIB KHAN
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
ishan743441
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
Tanya Makkar
 
Aad introduction
Aad introductionAad introduction
Aad introductionMr SMAK
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Intro to DS.pptx
Intro to DS.pptxIntro to DS.pptx
Intro to DS.pptx
Usman Ahmed
 
Ic lecture6 architecture and algo
Ic lecture6 architecture and algoIc lecture6 architecture and algo
Ic lecture6 architecture and algo
AttaullahRahimoon
 

Similar to Algorithms (20)

Discrete structure ch 3 short question's
Discrete structure ch 3 short question'sDiscrete structure ch 3 short question's
Discrete structure ch 3 short question's
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
 
Algoritmos
AlgoritmosAlgoritmos
Algoritmos
 
Design & Analysis Of Algorithm
Design & Analysis Of AlgorithmDesign & Analysis Of Algorithm
Design & Analysis Of Algorithm
 
Lecture 01-2.ppt
Lecture 01-2.pptLecture 01-2.ppt
Lecture 01-2.ppt
 
Cuckoo Search: Recent Advances and Applications
Cuckoo Search: Recent Advances and ApplicationsCuckoo Search: Recent Advances and Applications
Cuckoo Search: Recent Advances and Applications
 
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdfADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptx
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Csallner algorithms1
Csallner algorithms1Csallner algorithms1
Csallner algorithms1
 
chapter 1
chapter 1chapter 1
chapter 1
 
DATA STRUCTURE.pdf
DATA STRUCTURE.pdfDATA STRUCTURE.pdf
DATA STRUCTURE.pdf
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Types of Algorithms.ppt
Types of Algorithms.pptTypes of Algorithms.ppt
Types of Algorithms.ppt
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
 
Aad introduction
Aad introductionAad introduction
Aad introduction
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Unit 1 dsa
 
Intro to DS.pptx
Intro to DS.pptxIntro to DS.pptx
Intro to DS.pptx
 
Ic lecture6 architecture and algo
Ic lecture6 architecture and algoIc lecture6 architecture and algo
Ic lecture6 architecture and algo
 

More from Ramy F. Radwan

Literature review for managing projects effectively
Literature review for managing projects effectivelyLiterature review for managing projects effectively
Literature review for managing projects effectively
Ramy F. Radwan
 
Applying agile to large scale corporations - Ramy F Radwan
Applying agile to large scale corporations  - Ramy F RadwanApplying agile to large scale corporations  - Ramy F Radwan
Applying agile to large scale corporations - Ramy F Radwan
Ramy F. Radwan
 
Ramys resume
Ramys resumeRamys resume
Ramys resume
Ramy F. Radwan
 
NASA space apps guide for android
NASA space apps guide for androidNASA space apps guide for android
NASA space apps guide for android
Ramy F. Radwan
 
Session 2 of programming
Session 2 of programmingSession 2 of programming
Session 2 of programming
Ramy F. Radwan
 
Session 1 of programming
Session 1 of programmingSession 1 of programming
Session 1 of programming
Ramy F. Radwan
 
CIEians arduino
CIEians arduinoCIEians arduino
CIEians arduino
Ramy F. Radwan
 

More from Ramy F. Radwan (9)

Literature review for managing projects effectively
Literature review for managing projects effectivelyLiterature review for managing projects effectively
Literature review for managing projects effectively
 
Applying agile to large scale corporations - Ramy F Radwan
Applying agile to large scale corporations  - Ramy F RadwanApplying agile to large scale corporations  - Ramy F Radwan
Applying agile to large scale corporations - Ramy F Radwan
 
Ramys resume
Ramys resumeRamys resume
Ramys resume
 
NASA space apps guide for android
NASA space apps guide for androidNASA space apps guide for android
NASA space apps guide for android
 
certificate
certificatecertificate
certificate
 
Udacity Reviews
Udacity ReviewsUdacity Reviews
Udacity Reviews
 
Session 2 of programming
Session 2 of programmingSession 2 of programming
Session 2 of programming
 
Session 1 of programming
Session 1 of programmingSession 1 of programming
Session 1 of programming
 
CIEians arduino
CIEians arduinoCIEians arduino
CIEians arduino
 

Recently uploaded

Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 

Recently uploaded (20)

Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 

Algorithms

  • 1. Applications in Computer Science Math V This Report was Prepared by: Eng. Ramy Fathi Radwan Under Supervision of: Ass.Prof.Eng. Ibrahim El-Kalla
  • 2. Many Thanks for Ass.Prof Ibrahim El-kalla for his efforts with us in the summer semester course. Also, for encouraging me to do this report about Algorithms with its application in Computer Science. Let Allah rewards his efforts with us with blessing Ensha’Allah. Eng. Ramy Fathi Radwan
  • 3. Contents  Introduction and History of the Science  Examples for some Algorithms  Application (Java OOP Search Program)
  • 4. Introduction Many problems can be solved by considering them as special cases of general problems. For instance, consider the problem of locating the largest integer in the sequence 101,12, 144, 212, 98. This is a specific case of the problem of locating the largest integer in a sequence of integers. To solve this general problem we must give an algorithm, which specifies a sequence of steps used to solve this general problem.We will study algorithms for solving many different types of problems in this book. For example, in this chapter we will introduce algorithms for two of the most important problems in computer science, searching for an element in a list and sorting a list so its elements are in some prescribed order, such as increasing, decreasing, or alphabetic. Later in the book we will develop algorithms that find the greatest common divisor of two integers, that generate all the orderings of a finite set, that find the shortest path between nodes in a network, and for solving many other problems. We will also introduce the notion of an algorithmic paradigm, which provides a general method for designing algorithms. In particular we will discuss brute-force algorithms, which find solutions using a straightforward approach without introducing any cleverness.We will also discuss greedy algorithms, a class of algorithms used to solve optimization problems. Proofs are important in the study of algorithms. In this chapter we illustrate this by proving that a particular greedy algorithm always finds an optimal solution. One important consideration concerning an algorithm is its computational complexity, which measures the processing time and computer memory required by the algorithm to solve problems of a particular size. There are many general classes of problems that arise in discrete mathematics. For instance: given a sequence of integers, find the largest one; given a set, list all its subsets; given a set of integers, put them in increasing order; given a network, find the shortest path between two vertices. When presented with such a problem, the first
  • 5. thing to do is to construct a model that translates the problem into a mathematical context. Discrete structures used in such models include sets, sequences, and functions—structures discussed in Chapter 2—as well as such other structures as permutations, relations, graphs, trees, networks, and finite state machines— concepts that will be discussed in later chapters. Setting up the appropriate mathematical model is only part of the solution. To complete the solution, a method is needed that will solve the general problem using the model. Ideally, what is required is a procedure that follows a sequence of steps that leads to the desired answer. Such a sequence of steps is called an algorithm. The term algorithm is a corruption of the name al-Khowarizmi, a mathematician of the ninth century, whose book on Hindu numerals is the basis of modern decimal notation. Originally, the word algorism was used for the rules for performing arithmetic using decimal notation. Algorism evolved into the word algorithm by the eighteenth century.With the growing interest in computing machines, the concept of an algorithm was given a more general meaning, to include all definite procedures for solving problems, not just the procedures for performing arithmetic. In this book, we will discuss algorithms that solve a wide variety of problems. In this section we will use the problem of finding the largest integer in a finite sequence of integers to illustrate the concept of an algorithm and the properties algorithms have. Also, we will describe algorithms for locating a particular element in a finite set. In subsequent sections, procedures for finding the greatest common divisor of two integers, for finding the shortest path between two points in a network, for multiplying matrices, and so on, will be discussed. PROPERTIES OF ALGORITHMS There are several properties that algorithms generally share. They are useful to keep in mind when algorithms are described. These properties are: Input. An algorithm has input values from a specified set. Output. From each set of input values an algorithm produces output values from a specified set. The output values are the solution to the problem. Definiteness. The steps of an algorithm must be defined precisely.
  • 6. Correctness. An algorithm should produce the correct output values for each set of input values. Finiteness. An algorithm should produce the desired output after a finite (but perhaps large) number of steps for any input in the set. Effectiveness. It must be possible to perform each step of an algorithm exactly and in a finite amount of time. Generality. The procedure should be applicable for all problems of the desired form, not just for a particular set of input values.
  • 7. Examples for Some Algorithms 1- ALGORITHM 1 : Finding the Maximum Element in a Finite Sequence. procedure max(a1, a2, . . . , an: integers) max := a1 for i := 2 to n if max < ai then max := ai return max{max is the largest element} 2- ALGORITHM 2 The Linear Search Algorithm. procedure linear search(x: integer, a1, a2, . . . , an: distinct integers) i := 1 while (i ≤ n and x = ai ) i := i + 1 if i ≤ n then location := i else location := 0 return location{location is the subscript of the term that equals x, or is 0 if x is not found} 3- ALGORITHM The Bubble Sort. procedure bubblesort(a1, . . . , an : real numbers with n ≥ 2) for i := 1 to n − 1 for j := 1 to n − i if aj > aj+1 then interchange aj and aj+1 {a1, . . . , an is in increasing order}
  • 8. The JAVA OOP Program This Program lets you choose the number of elements and insert them using an Insert() method. After you finish inserting the values you use the Search() method in order to know if the element u want in the Array saved or not and also to know it’s location in the array. The Source Code : /** * @(#)Search.java * * Search application * * @author Ramy Fathi Mahmoud Radwan CIE(200) 70011366 * @version 1.00 2013/9/8 */ import java.util.Scanner; public class Search { static int [] A = new int[10]; static int n_elm; public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter the num of elments "); n_elm = input.nextInt() ; for (int i =0 ; i < n_elm ; i ++ ){ System.out.println(" Please Insert the element followed by ENTER "); insert(input.nextInt(),i); } System.out.println("Write the Element you Want to Search for ") ;
  • 9. search(input.nextInt() , n_elm ); } public static void insert(int x , int i){ A[i] = x; } public static void search( int x , int n_elm ) { a : { for( int i = 0 ; i < n_elm ; i ++ ) { if (A[i] == x) { System.out.println("Yes it Exists in position " + (i+1)); break a ; } if (A[i] != x && i == (n_elm-1)) { System.out.println("No It Doesn't Exist in the inserted Array "); break a ; } } } } }