Finally, in javaScript 2015 we get 2 new built-in data structures that makes our life a little bit easier. On this lecture, we will explore various implementations of common data structures in javaScript using Arrays, Objects and the new members in javaScript 2015: Maps and Sets.
Finally, in javaScript 2015 we get 2 new built-in data structures that makes our life a little bit easier. On this lecture, we will explore various implementations of common data structures in javaScript using Arrays, Objects and the new members in javaScript 2015: Maps and Sets.
Binary Search is a searching algorithm used in a sorted array by repeatedly dividing the search interval in half. The idea of binary search is to use the information that the array is sorted and reduce the time complexity to O(Log n).
This presentation about Scikit-learn will help you understand what is Scikit-learn, what can we achieve using Scikit-learn and a demo on how to use Scikit-learn in Python. Scikit is a powerful and modern machine learning python library. It's a great tool for fully and semi-automated advanced data analysis and information extraction. There are a lot of reasons why Scikit-Learn is a preferred machine learning tool. It has efficient tools to identify and organize problems, such as whether it fits a supervised or unsupervised learning model. It contains many free and open data sets. It has a rich set of built-in libraries for learning and predicting. It provides model support for every problem type. It also has built-in functions such as pickle for model persistence. It is supported by a huge open source community and vendor base. Now, let us get started and understand Sciki-Learn in detail.
Below topics are explained in this Scikit-Learn presentation:
1. What is Scikit-learn?
2. What we can achieve using Scikit-learn
3. Demo
Simplilearn’s Python Training Course is an all-inclusive program that will introduce you to the Python development language and expose you to the essentials of object-oriented programming, web development with Django and game development. Python has surpassed Java as the top language used to introduce U.S. students to programming and computer science. This course will give you hands-on development experience and prepare you for a career as a professional Python programmer.
What is this course about?
The All-in-One Python course enables you to become a professional Python programmer. Any aspiring programmer can learn Python from the basics and go on to master web development & game development in Python. Gain hands-on experience creating a flappy bird game clone & website functionalities in Python.
What are the course objectives?
By the end of this online Python training course, you will be able to:
1. Internalize the concepts & constructs of Python
2. Learn to create your own Python programs
3. Master Python Django & advanced web development in Python
4. Master PyGame & game development in Python
5. Create a flappy bird game clone
The Python training course is recommended for:
1. Any aspiring programmer can take up this bundle to master Python
2. Any aspiring web developer or game developer can take up this bundle to meet their training needs
Learn more at https://www.simplilearn.com/mobile-and-software-development/python-development-training
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
This is a presentation on Arrays, one of the most important topics on Data Structures and algorithms. Anyone who is new to DSA or wants to have a theoretical understanding of the same can refer to it :D
Transformation rules
Propositional calculus
Rules of inference
Implication introduction / elimination
Biconditional introduction / elimination
Conjunction introduction / elimination
Disjunction introduction / elimination
Disjunctive / Hypothetical syllogism
Constructive / Destructive dilemma
Absorption / Modus tollens /
Modus ponendo tollens
Rules of replacement
Associativity Commutativity Distributivity Double negation De Morgan's laws Transposition Material implication Exportation Tautology Negation introduction
Predicate logic
Universal generalization / instantiation
Existential generalization / instantiation
v t e
Propositional calculus (also called propositional logic, statement logic, sentential calculus, sentential logic, or sometimes zeroth-order logic) is the branch of logic concerned with the study of propositions (whether they are true or false) that are formed by other propositions with the use of logical connectives. First-order logic extends propositional logic by allowing a proposition to be expressed as constructs such as "for every", "exists", "equality" and "membership", whereas in proposition logic, propositions are thought of as atoms.
Key Features
•Covers a broad range of algorithms in depth
•Each chapter
–focuses on an algorithm
–discusses its design techniques and areas of application
•Algorithms are written in Pseudocode
Learn More: www.phindia.com
This is a seminar presentation on "SORTING" for Semester 2 exam at St. Xavier's College.The power point presenation deals with the requirement of sorting in our life,types of sorting techniques,code for implementing them,the time and space complexity of different sorting algorithms,the applications of sorting,its use in the industry and its future scope.The slide show contains .gif files which can't be seen here.For more details or any queries send me a mail at agmajumder@gmail.com
This will introduce you to Sorting in Python and help you understand the importance of Sorting. This Python tutorial will take you through various Sorting Algorithms. The Algorithms are lined after one another, starting with Bubble Sort moving to Insertion Sort, Merge Sort, and finally Quick Sort. The demonstration examples will educate you on Sorting Algorithms.
Binary Search is a searching algorithm used in a sorted array by repeatedly dividing the search interval in half. The idea of binary search is to use the information that the array is sorted and reduce the time complexity to O(Log n).
This presentation about Scikit-learn will help you understand what is Scikit-learn, what can we achieve using Scikit-learn and a demo on how to use Scikit-learn in Python. Scikit is a powerful and modern machine learning python library. It's a great tool for fully and semi-automated advanced data analysis and information extraction. There are a lot of reasons why Scikit-Learn is a preferred machine learning tool. It has efficient tools to identify and organize problems, such as whether it fits a supervised or unsupervised learning model. It contains many free and open data sets. It has a rich set of built-in libraries for learning and predicting. It provides model support for every problem type. It also has built-in functions such as pickle for model persistence. It is supported by a huge open source community and vendor base. Now, let us get started and understand Sciki-Learn in detail.
Below topics are explained in this Scikit-Learn presentation:
1. What is Scikit-learn?
2. What we can achieve using Scikit-learn
3. Demo
Simplilearn’s Python Training Course is an all-inclusive program that will introduce you to the Python development language and expose you to the essentials of object-oriented programming, web development with Django and game development. Python has surpassed Java as the top language used to introduce U.S. students to programming and computer science. This course will give you hands-on development experience and prepare you for a career as a professional Python programmer.
What is this course about?
The All-in-One Python course enables you to become a professional Python programmer. Any aspiring programmer can learn Python from the basics and go on to master web development & game development in Python. Gain hands-on experience creating a flappy bird game clone & website functionalities in Python.
What are the course objectives?
By the end of this online Python training course, you will be able to:
1. Internalize the concepts & constructs of Python
2. Learn to create your own Python programs
3. Master Python Django & advanced web development in Python
4. Master PyGame & game development in Python
5. Create a flappy bird game clone
The Python training course is recommended for:
1. Any aspiring programmer can take up this bundle to master Python
2. Any aspiring web developer or game developer can take up this bundle to meet their training needs
Learn more at https://www.simplilearn.com/mobile-and-software-development/python-development-training
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
This is a presentation on Arrays, one of the most important topics on Data Structures and algorithms. Anyone who is new to DSA or wants to have a theoretical understanding of the same can refer to it :D
Transformation rules
Propositional calculus
Rules of inference
Implication introduction / elimination
Biconditional introduction / elimination
Conjunction introduction / elimination
Disjunction introduction / elimination
Disjunctive / Hypothetical syllogism
Constructive / Destructive dilemma
Absorption / Modus tollens /
Modus ponendo tollens
Rules of replacement
Associativity Commutativity Distributivity Double negation De Morgan's laws Transposition Material implication Exportation Tautology Negation introduction
Predicate logic
Universal generalization / instantiation
Existential generalization / instantiation
v t e
Propositional calculus (also called propositional logic, statement logic, sentential calculus, sentential logic, or sometimes zeroth-order logic) is the branch of logic concerned with the study of propositions (whether they are true or false) that are formed by other propositions with the use of logical connectives. First-order logic extends propositional logic by allowing a proposition to be expressed as constructs such as "for every", "exists", "equality" and "membership", whereas in proposition logic, propositions are thought of as atoms.
Key Features
•Covers a broad range of algorithms in depth
•Each chapter
–focuses on an algorithm
–discusses its design techniques and areas of application
•Algorithms are written in Pseudocode
Learn More: www.phindia.com
This is a seminar presentation on "SORTING" for Semester 2 exam at St. Xavier's College.The power point presenation deals with the requirement of sorting in our life,types of sorting techniques,code for implementing them,the time and space complexity of different sorting algorithms,the applications of sorting,its use in the industry and its future scope.The slide show contains .gif files which can't be seen here.For more details or any queries send me a mail at agmajumder@gmail.com
This will introduce you to Sorting in Python and help you understand the importance of Sorting. This Python tutorial will take you through various Sorting Algorithms. The Algorithms are lined after one another, starting with Bubble Sort moving to Insertion Sort, Merge Sort, and finally Quick Sort. The demonstration examples will educate you on Sorting Algorithms.
Daniel Glazman, W3C CSS Working Group Chair and Web Tech Lead from Samsung OSG, discusses how CSS 3 and stylesheets will affect web standards in the future.
Google Algorithm Change History - 2k14-2k16.Saba SEO
For the organizations like "Saba SEO" to stick to the Google exercises and generate the relevant piece of content, it is important to know about the Google algorithm changes. The work of these algo(s) is to restrict companies and individual from spamming the content of the website with links that risen up the website traffic. In other words, these algorithms do justice with the sites in order to rank in the search engines. By the help of algorithms, if someone is doing spam for the sake of rankings can't take your place if you're on the right path. This infographic explains the 13 algorithms used by Google in between 2014 and 2016.
Array is a container which can hold a fix number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms. Following are the important terms to understand the concept of array.
* Brief History
* Differences Between Web 1.0 and Web 2.0
* The Web as Platform
* Harnessing Collective Intelligence
* Blogging and the Wisdom of Crowds
* Data is the Next Intel Inside
* End of the Software Release Cycle
* Lightweight Programming Models
* Software Above the Level of a Single Device
* Rich User Experiences
* Core Competencies
* Differences between Websites and Web Applications
* Research Techniques for Knowing Your Users
* Task Analysis
* UI/UX Design Principles for Web Applications
* Introduction
* Define "video game"
* Video Game Industry Overview
* Aspects of Game Development
* Game Development Community
* Careers Available in Game Development
* Testimonies
* Options for Developing Required Skillset
* Other Avenues for Career Development
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
Keep tabs on your field staff effortlessly with Informap Technology Centre LLC. Real-time tracking, task assignment, and smart features for efficient management. Request a live demo today!
For more details, visit us : https://informapuae.com/field-staff-tracking/
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
Accelerate Enterprise Software Engineering with PlatformlessWSO2
Key takeaways:
Challenges of building platforms and the benefits of platformless.
Key principles of platformless, including API-first, cloud-native middleware, platform engineering, and developer experience.
How Choreo enables the platformless experience.
How key concepts like application architecture, domain-driven design, zero trust, and cell-based architecture are inherently a part of Choreo.
Demo of an end-to-end app built and deployed on Choreo.
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
In this slide, we show the simulation example and the way to compile this solver.
In this solver, the Helmholtz equation can be solved by helmholtzFoam. Also, the Helmholtz equation with uniformly dispersed bubbles can be simulated by helmholtzBubbleFoam.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
In software engineering, the right architecture is essential for robust, scalable platforms. Wix has undergone a pivotal shift from event sourcing to a CRUD-based model for its microservices. This talk will chart the course of this pivotal journey.
Event sourcing, which records state changes as immutable events, provided robust auditing and "time travel" debugging for Wix Stores' microservices. Despite its benefits, the complexity it introduced in state management slowed development. Wix responded by adopting a simpler, unified CRUD model. This talk will explore the challenges of event sourcing and the advantages of Wix's new "CRUD on steroids" approach, which streamlines API integration and domain event management while preserving data integrity and system resilience.
Participants will gain valuable insights into Wix's strategies for ensuring atomicity in database updates and event production, as well as caching, materialization, and performance optimization techniques within a distributed system.
Join us to discover how Wix has mastered the art of balancing simplicity and extensibility, and learn how the re-adoption of the modest CRUD has turbocharged their development velocity, resilience, and scalability in a high-growth environment.
1. Algorithms
Reggie Niccolo Santos
UP Information Technology Development Center
(ITDC)
Slideshare: reggieniccolo.santos
Adapted from Aaron Bloomfield’s set of slides
2. Outline
What is an algorithm?
Algorithm 1: Maximum element
Properties of algorithms
8. Some algorithms are
harder than others
Some algorithms are easy
■
Finding the largest (or smallest)
value in a list
■
Finding a specific value in a list
Some algorithms are a bit harder
■
Sorting a list
9. Some algorithms are
harder than others
Some algorithms are very hard
■
Finding the shortest path between
Rizal and Quezon City
Some algorithms are essentially
impossible
■
Factoring large composite numbers
10. Algorithm 1:
Maximum element
Given a list, how do we find the
maximum element in the list?
!
To express the algorithm, we’ll use
pseudocode
■ Pseudocode is kinda like a
programming language, but not really
11. Algorithm 1:
Maximum element
Algorithm for finding the maximum element in a
list:
!
procedure max (a1, a2, …, an: integers)
max := a1
for i := 2 to n
if max < ai then max := ai
!
{max is the largest element}
12. Maximum element
running time
How long does this take?
!
If the list has n elements, worst case
scenario is that it takes n “steps”
■
Here, a step is considered a
single step through the list
13. Properties of
algorithms
Algorithms generally share a set of
properties:
■ Input: what the algorithm takes in as input
■ Output: what the algorithm produces as
output
■ Definiteness: the steps are defined
precisely
■ Correctness: should produce the correct
output
14. Properties of
algorithms
Algorithms generally share a set of
properties:
■ Finiteness: the steps required should be
finite
■ Effectiveness: each step must be able to
be performed in a finite amount of time
■ Generality: the algorithm should be
applicable to all problems of a
similar form
15. Searching
algorithms
Given a list, find a specific element in
the list
!
We will see two types
■
Linear search
a.k.a. sequential search
■
Binary search
16. Algorithm 2: Linear
search
Given a list, find a specific element in the list
■ List does NOT have to be sorted!
!
procedure linear_search (x: integer; a1, a2, …, an:
integers)
i := 1
while ( i ≤ n and x ≠ ai )
i := i + 1
if i ≤ n then location := i
else location := 0
!
{location is the subscript of the term that equals x, or
it is 0 if x is not found}
17. Linear search
running time
How long does this take?
!
If the list has n elements, worst case
scenario is that it takes n “steps”
■
Here, a step is considered a
single step through the list
18. Algorithm 3: Binary
search
Given a list, find a specific element in the list
■ List MUST be sorted!
Each time it iterates through, it cuts the list in half
!
procedure binary_search (x: integer; a1
, a2
, …, an
: increasing integers)
i := 1 { i is left endpoint of search interval }
j := n{ j is right endpoint of search interval }
while i < j
begin
m := (i+j)/2 { m is the point in the middle }
if x > am
then i := m+1
else j := m
end
if x = ai
then location := i
else location := 0
!
{location is the subscript of the term that equals x, or it is 0 if x is
not found}
20. Binary search
running time
How long does this take (worst case)?
!
If the list has 8 elements
■ It takes 3 steps
If the list has 16 elements
■ It takes 4 steps
If the list has 64 elements
■ It takes 6 steps
!
If the list has n elements
■ It takes log2 n steps
21. Sorting algorithms
Given a list, put it into some order
■ Numerical, lexicographic, etc.
!
We will see two types
■ Bubble sort
■ Insertion sort
22. Algorithm 4:
Bubble sort
One of the most simple sorting algorithms
■ Also one of the least efficient
It takes successive elements and “bubbles” them up
the list
!
procedure bubble_sort (a1, a2, …, an)
for i := 1 to n-1
for j := 1 to n-i
if aj > aj+1
then interchange aj and aj+1
{ a1, …, an are in increasing order }
24. Bubble sort running
time
Bubble sort algorithm:
for i := 1 to n-1
for j := 1 to n-i
if aj > aj+1
then interchange aj and aj+1
!
Outer for loop does n-1 iterations
Inner for loop does
■ n-1 iterations the first time
■ n-2 iterations the second time
■ …
■ 1 iteration the last time
Total: (n-1) + (n-2) + (n-3) + … + 2 + 1 = (n
2
-n)/2
■ We can say that’s “about” n
2
time
25. Algorithm 5:
Insertion sort
Another simple (and inefficient) algorithm
It starts with a list with one element, and inserts new elements into their proper
place in the sorted part of the list
!
procedure insertion_sort (a1, a2, …, an)
for j := 2 to n
begin
i := 1
while aj > ai
i := i +1
m := aj
for k := 0 to j-i-1
aj-k := aj-k-1
ai := m
end { a1, a2, …, an are sorted }
26. Insertion sort
running time
Outer for loop runs n-1 times
In the inner for loop:
■
Worst case is when the while keeps i at
1, and the for loop runs lots of times
■
If i is 1, the inner for loop runs 1
time (k goes from 0 to 0) on the first
iteration, 1 time on the second, up to
n-2 times on the last iteration
Total is 1 + 2 + … + n-2 = (n-1)(n-2)/2
■
We can say that’s “about” n2
time
27. Comparison of
running times
Searches
■ Linear: n steps
■ Binary: log2 n steps
■ Binary search is about as fast as you can get
!
Sorts
■ Bubble: n
2
steps
■ Insertion: n
2
steps
■ There are other, more efficient, sorting techniques
In principle, the fastest are heap sort, quick sort, and merge sort
These each take take n * log2 n steps
In practice, quick sort is the fastest, followed by
merge sort
28. Summary
What is an algorithm?
Algorithm 1: Maximum element
Properties of algorithms