SlideShare uma empresa Scribd logo
1 de 29
CSC112
Algorithms and Data Structures
Lecture 01
Introduction
By
Fayyaz Awan
Contact Information
• Instructor:
Fayyaz Awan (Lecturer)
Department of Computer Sciences
Comsats Insititute of Information Technology, Wah Cantt
• Office Hours:
Monday, 11:00 am – 4:30 pm
Need for Data Structures
 Data structures organize data  more efficient programs.
 More powerful computers  more complex applications.
 More complex applications demand more calculations.
Organizing Data
 Any organization for a collection of records that can be
searched, processed in any order, or modified.
 The choice of data structure and algorithm can make the
difference between a program running in a few seconds or
many days.
Efficiency
 A solution is said to be efficient if it solves the problem within
its resource constraints.
• Space
• Time
 The cost of a solution is the amount of resources that the
solution consumes.
Selecting a Data Structure
Select a data structure as follows:
1. Analyze the problem to determine the resource constraints a
solution must meet.
2. Determine the basic operations that must be supported.
Quantify the resource constraints for each operation.
3. Select the data structure that best meets these
requirements.
Some Questions to Ask
• Are all data inserted into the data structure at the beginning,
or are insertions interspersed with other operations?
• Can data be deleted?
• Are all data processed in some well-defined order, or is
random access allowed?
Data Structure Philosophy
 Each data structure has costs and benefits.
 Rarely is one data structure better than another in all
situations.
 A data structure requires:
• space for each data item it stores,
• time to perform each basic operation,
• programming effort.
Algorithms
• An algorithm is any well defined computational procedure
that takes some values or set of values as input and produces
some value or set of values as output.
• An algorithm is thus a sequence of computational steps that
transforms the input into output.
How do you learn algorithms to
cook?
• To become good chef, you don’t learn lots of recipes by heart.
• You study existing recipes.
• You practice making them.
• You experiment with your own variations.
• Until you can invent your own recipes.
How do you learn about
algorithms?
• A good computer scientist doesn’t need to memorize a big
book of algorithms.
• We will begin studying famous algorithms.
• You can practice executing them by hand.
• Once you recognize more general patterns, you can
experiment with your own variations.
• At the end of the course, I expect you to invent algorithms
yourself.
Analysis of Algorithms
The theoretical study of computer-program performance and
resource usage. What’s more important than performance?
• modularity
• correctness
• maintainability
• functionality
• robustness (strengths)
• user-friendliness
• programmer time
• simplicity
• extensibility
• reliability
Origin of word: Algorithm
• The word Algorithm comes from the name of the muslim
author Abu Ja’far Mohammad ibn Musaal-Khowarizmi. He
was born in the eighth century at Khwarizm (Kheva), a town
south of river Oxus in present Uzbekistan. Uzbekistan, a
Muslim country for over a thousand years, was taken over by
the Russians in 1873.
• Much of al-Khwarizmi’s work was written in a book titled al
Kitab al-mukhatasar fi hisab al-jabrwa’l-muqabalah (The
Compendious Book on Calculation by Completion and
Balancing). It is from the titles of these writings and his name
that the words algebra and algorithm are derived. As a result
of his work, al-Khwarizmi is regarded as the most outstanding
mathematician of his time
Algorithm: Informal
Definition
• An algorithm is any well-defined
computational procedure that takes some
values, or set of values, as input and produces
some value, or set of values, as output.
• An algorithm is thus a sequence of
computational steps that transform the input
into output.
Algorithms, Programming
• A good understanding of algorithms is essential
for a good understanding of the most basic
element of computer science: programming.
Unlike a program, an algorithm is a
mathematical entity, which is independent of a
specific programming language, machine, or
compiler. Thus, in some sense, algorithm
design is all about the mathematical theory
behind the design of good programs.
Why study algorithms and
performance?
• Algorithms help us to understand
scalability.
• Performance often draws the line between
what is feasible and what is impossible.
• Algorithmic mathematics provides a
language for talking about program
behavior.
• Performance is the currency of computing.
Why Study Algorithms?
• Necessary in any computer programming problem
• Improve algorithm efficiency: run faster, process more data, do something that
would otherwise be impossible
• Solve problems of significantly large sizes
• Compare algorithms
• Algorithms as a field of study
• Learn about a standard set of algorithms
• New discoveries arise
• Numerous application areas
• Learn techniques of algorithm design and analysis
• how does one coordinate the efforts of many programmers working on a
single piece of software
Applications
• Multimedia
• CD player, DVD, MP3, JPG, DivX
• Internet
• Packet routing, data retrieval (Google)
• Communication
• Cell-phones, e-commerce
• Computers
• Circuit layout, file systems
• Science
• Human genome (is the complete set of genetic information for
humans)
• Transportation
• Airline crew scheduling, UPS deliveries
Analyzing Algorithms
• Predict the amount of resources required:
• memory: how much space is needed?
• computational time: how fast the algorithm runs?
• FACT: running time grows with the size of the input
• Input size (number of elements in the input)
• Size of an array, polynomial degree, # of elements in a matrix, # of bits in the
binary representation of the input, vertices and edges in a graph
Def: Running time = the number of primitive operations (steps) executed
before termination
• Arithmetic operations (+, -, *), data movement, control, decision making (if,
while), comparison
Definition: Algorithm
• A computer algorithm is a detailed step by step
method for solving the problem
• An algorithm is a sequence of Clear-cut instructions
for solving the problem in a finite amount of time.
• An algorithm is a set of well defined computational
procedure that takes some values, or set of values,
as input and produces some value or set of values
as output.
• More Generally an algorithm is any well defined
computational procedure that takes collection of
elements as input and procedures collection of
elements as output.
Definition: Data Structures
• A data structure is systematic way of organizing
and accessing data with a specific relationship
between the elements.
• Why data structures?
Ultimate goal -- to write efficient programs. In order
to do that, one needs to organize the data in such a
way that it can be accessed and manipulated
efficiently.
Definition: Data Structures (Cont…)
• A data structure is a way of arranging data in a
computer's memory or other disk storage.
• A data structure is a collection of data, organized so that
items can be stored and retrieved by some fixed
techniques.
• Example: Suppose you are hired to create a database of
names with all company's management and employees.
Example: Data Structures
• You can make a list. You can also make a tree.
Data Structures Types
• There are several common data structures: arrays,
linked lists, queues, stacks, binary trees, hash
tables, etc.
• These data structures can be classified as
either linear or nonlinear data structures, based on
how the data is conceptually organized or
aggregated.
LinearVs Non-LinearData Structures
Linear Structures Non-Linear Structures
The array, list, queue, and stack
belong to this category.
Each of them is a collection that
stores its entries in a linear sequence,
and in which entries may be added or
removed at will.
They differ in the restrictions they
place on how these entries may be
added, removed, or accessed. The
common restrictions include FIFO and
LIFO.
Trees and graphs are classical non-
linear structures.
Data entries are not arranged in a
sequence, but with different rules.
Algorithms and Data
Structures
Data Structure Operations
• The data appearing in our data structures are processed
by means of certain operations. The following four
operations play a major role :
1. Traversing: Accessing each record exactly once so that certain
items in the record may be processed.
2. 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.
3. Inserting: Adding a new record to the structure.
4. Deleting : Removing a record from the structure.
Data Structure Operations (Cont…)
• Sometimes two or more of the operations may be
used in given situations; e.g. we may want to delete
the record with a given key, which may mean we
first need to search for the location of the record.
The following two operations , which are used in
special situations, will be considered:
1. Sorting: Arranging record in some logical order
(ascending/ descending)
2. Merging: Combining the records in two different
sorted files into a single sorted file.
For any query Feel Free to ask

Mais conteúdo relacionado

Mais procurados

COMMUNICATION & COMPUTER SKILLS
COMMUNICATION & COMPUTER SKILLSCOMMUNICATION & COMPUTER SKILLS
COMMUNICATION & COMPUTER SKILLSMakaha Rutendo
 
EE5440 – Computer Architecture - Lecture 1
EE5440 – Computer Architecture - Lecture 1EE5440 – Computer Architecture - Lecture 1
EE5440 – Computer Architecture - Lecture 1Dilawar Khan
 
COMPUTER PROGRAMMING UNIT 1 Lecture 1
COMPUTER PROGRAMMING UNIT 1 Lecture 1COMPUTER PROGRAMMING UNIT 1 Lecture 1
COMPUTER PROGRAMMING UNIT 1 Lecture 1Vishal Patil
 
MIS Presentation Chapter III: Hardware
MIS Presentation Chapter III: Hardware MIS Presentation Chapter III: Hardware
MIS Presentation Chapter III: Hardware Sopov Chan
 
Bca i-fundamental of computer-u-2- application and system software
Bca  i-fundamental of  computer-u-2- application and system softwareBca  i-fundamental of  computer-u-2- application and system software
Bca i-fundamental of computer-u-2- application and system softwareRai University
 
Report-computer hardware,system, and software
Report-computer hardware,system, and softwareReport-computer hardware,system, and software
Report-computer hardware,system, and softwareKarl John Piocos
 
Introduction to Computers Lecture # 8
Introduction to Computers Lecture # 8Introduction to Computers Lecture # 8
Introduction to Computers Lecture # 8Sehrish Rafiq
 
Introduction to Computers Lecture # 11
Introduction to Computers Lecture # 11Introduction to Computers Lecture # 11
Introduction to Computers Lecture # 11Sehrish Rafiq
 
1 fundamentals of computer system
1 fundamentals of computer system1 fundamentals of computer system
1 fundamentals of computer systemBaliThorat1
 
Sap basis online training
Sap basis online trainingSap basis online training
Sap basis online trainingkeylabstraining
 

Mais procurados (20)

Software
SoftwareSoftware
Software
 
Introduction to Computer System
Introduction to Computer SystemIntroduction to Computer System
Introduction to Computer System
 
Basics of Computer
Basics of ComputerBasics of Computer
Basics of Computer
 
Internal storage devices
Internal storage devicesInternal storage devices
Internal storage devices
 
Computer Basics and Hardware
Computer Basics and HardwareComputer Basics and Hardware
Computer Basics and Hardware
 
COMMUNICATION & COMPUTER SKILLS
COMMUNICATION & COMPUTER SKILLSCOMMUNICATION & COMPUTER SKILLS
COMMUNICATION & COMPUTER SKILLS
 
EE5440 – Computer Architecture - Lecture 1
EE5440 – Computer Architecture - Lecture 1EE5440 – Computer Architecture - Lecture 1
EE5440 – Computer Architecture - Lecture 1
 
Software
SoftwareSoftware
Software
 
COMPUTER PROGRAMMING UNIT 1 Lecture 1
COMPUTER PROGRAMMING UNIT 1 Lecture 1COMPUTER PROGRAMMING UNIT 1 Lecture 1
COMPUTER PROGRAMMING UNIT 1 Lecture 1
 
MIS Presentation Chapter III: Hardware
MIS Presentation Chapter III: Hardware MIS Presentation Chapter III: Hardware
MIS Presentation Chapter III: Hardware
 
Unit Iv
Unit IvUnit Iv
Unit Iv
 
Bca i-fundamental of computer-u-2- application and system software
Bca  i-fundamental of  computer-u-2- application and system softwareBca  i-fundamental of  computer-u-2- application and system software
Bca i-fundamental of computer-u-2- application and system software
 
Report-computer hardware,system, and software
Report-computer hardware,system, and softwareReport-computer hardware,system, and software
Report-computer hardware,system, and software
 
Introduction to Computers Lecture # 8
Introduction to Computers Lecture # 8Introduction to Computers Lecture # 8
Introduction to Computers Lecture # 8
 
Introduction to Computers Lecture # 11
Introduction to Computers Lecture # 11Introduction to Computers Lecture # 11
Introduction to Computers Lecture # 11
 
Lecture 01 concept of computer system
Lecture 01 concept of computer systemLecture 01 concept of computer system
Lecture 01 concept of computer system
 
1 fundamentals of computer system
1 fundamentals of computer system1 fundamentals of computer system
1 fundamentals of computer system
 
Sap basis online training
Sap basis online trainingSap basis online training
Sap basis online training
 
Chapter 7A Peter Norton
Chapter 7A Peter NortonChapter 7A Peter Norton
Chapter 7A Peter Norton
 
1 introduction-to-computer
1 introduction-to-computer1 introduction-to-computer
1 introduction-to-computer
 

Semelhante a Algorithms and Data Structures

Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithmsiqbalphy1
 
Data structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfData structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfDukeCalvin
 
Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsAkhil Kaushik
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm. Abdul salam
 
data structures and its importance
 data structures and its importance  data structures and its importance
data structures and its importance Anaya Zafar
 
UNIT_5_Data Wrangling.pptx
UNIT_5_Data Wrangling.pptxUNIT_5_Data Wrangling.pptx
UNIT_5_Data Wrangling.pptxBhagyasriPatel2
 
ADS Introduction
ADS IntroductionADS Introduction
ADS IntroductionNagendraK18
 
Lec01-Algorithems - Introduction and Overview.pdf
Lec01-Algorithems - Introduction and Overview.pdfLec01-Algorithems - Introduction and Overview.pdf
Lec01-Algorithems - Introduction and Overview.pdfMAJDABDALLAH3
 
Analysis of Algorithms_RR.pptx
Analysis of Algorithms_RR.pptxAnalysis of Algorithms_RR.pptx
Analysis of Algorithms_RR.pptxKarthikR780430
 
DS M1 full - KQB KtuQbank.pdf
DS M1 full - KQB KtuQbank.pdfDS M1 full - KQB KtuQbank.pdf
DS M1 full - KQB KtuQbank.pdfMidhunM83
 

Semelhante a Algorithms and Data Structures (20)

Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
Data structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfData structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdf
 
Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & Algorithms
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 
data structures and its importance
 data structures and its importance  data structures and its importance
data structures and its importance
 
Lec1.ppt
Lec1.pptLec1.ppt
Lec1.ppt
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
 
Lecture 1 (bce-7)
Lecture   1 (bce-7)Lecture   1 (bce-7)
Lecture 1 (bce-7)
 
UNIT_5_Data Wrangling.pptx
UNIT_5_Data Wrangling.pptxUNIT_5_Data Wrangling.pptx
UNIT_5_Data Wrangling.pptx
 
ADS Introduction
ADS IntroductionADS Introduction
ADS Introduction
 
Unit no_1.pptx
Unit no_1.pptxUnit no_1.pptx
Unit no_1.pptx
 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Lecture 1 and 2
Lecture 1 and 2Lecture 1 and 2
Lecture 1 and 2
 
Lec01-Algorithems - Introduction and Overview.pdf
Lec01-Algorithems - Introduction and Overview.pdfLec01-Algorithems - Introduction and Overview.pdf
Lec01-Algorithems - Introduction and Overview.pdf
 
Analysis of Algorithms_RR.pptx
Analysis of Algorithms_RR.pptxAnalysis of Algorithms_RR.pptx
Analysis of Algorithms_RR.pptx
 
DS M1 full - KQB KtuQbank.pdf
DS M1 full - KQB KtuQbank.pdfDS M1 full - KQB KtuQbank.pdf
DS M1 full - KQB KtuQbank.pdf
 
CPP12 - Algorithms
CPP12 - AlgorithmsCPP12 - Algorithms
CPP12 - Algorithms
 

Mais de sonykhan3

computer visions with full detail
computer visions with full detail computer visions with full detail
computer visions with full detail sonykhan3
 
Deep learning-smaller neural network
Deep learning-smaller neural networkDeep learning-smaller neural network
Deep learning-smaller neural networksonykhan3
 
introduction to deep Learning with full detail
introduction to deep Learning with full detailintroduction to deep Learning with full detail
introduction to deep Learning with full detailsonykhan3
 
Input output devices
Input output devicesInput output devices
Input output devicessonykhan3
 
Information system and its types
Information system and its typesInformation system and its types
Information system and its typessonykhan3
 
Generation of computers
Generation of computersGeneration of computers
Generation of computerssonykhan3
 
Computer software and operating system
Computer software and operating systemComputer software and operating system
Computer software and operating systemsonykhan3
 
computer language with full detail
computer language with full detail computer language with full detail
computer language with full detail sonykhan3
 
computer networking slides with full detail
computer  networking slides with full detailcomputer  networking slides with full detail
computer networking slides with full detailsonykhan3
 
computer virus with full detail
computer virus with full detail computer virus with full detail
computer virus with full detail sonykhan3
 
common computer terminology
common computer terminologycommon computer terminology
common computer terminologysonykhan3
 
Introduction to Computer System
Introduction to Computer System Introduction to Computer System
Introduction to Computer System sonykhan3
 
Information Security
Information SecurityInformation Security
Information Securitysonykhan3
 

Mais de sonykhan3 (13)

computer visions with full detail
computer visions with full detail computer visions with full detail
computer visions with full detail
 
Deep learning-smaller neural network
Deep learning-smaller neural networkDeep learning-smaller neural network
Deep learning-smaller neural network
 
introduction to deep Learning with full detail
introduction to deep Learning with full detailintroduction to deep Learning with full detail
introduction to deep Learning with full detail
 
Input output devices
Input output devicesInput output devices
Input output devices
 
Information system and its types
Information system and its typesInformation system and its types
Information system and its types
 
Generation of computers
Generation of computersGeneration of computers
Generation of computers
 
Computer software and operating system
Computer software and operating systemComputer software and operating system
Computer software and operating system
 
computer language with full detail
computer language with full detail computer language with full detail
computer language with full detail
 
computer networking slides with full detail
computer  networking slides with full detailcomputer  networking slides with full detail
computer networking slides with full detail
 
computer virus with full detail
computer virus with full detail computer virus with full detail
computer virus with full detail
 
common computer terminology
common computer terminologycommon computer terminology
common computer terminology
 
Introduction to Computer System
Introduction to Computer System Introduction to Computer System
Introduction to Computer System
 
Information Security
Information SecurityInformation Security
Information Security
 

Último

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 

Último (20)

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 

Algorithms and Data Structures

  • 1. CSC112 Algorithms and Data Structures Lecture 01 Introduction By Fayyaz Awan
  • 2. Contact Information • Instructor: Fayyaz Awan (Lecturer) Department of Computer Sciences Comsats Insititute of Information Technology, Wah Cantt • Office Hours: Monday, 11:00 am – 4:30 pm
  • 3. Need for Data Structures  Data structures organize data  more efficient programs.  More powerful computers  more complex applications.  More complex applications demand more calculations.
  • 4. Organizing Data  Any organization for a collection of records that can be searched, processed in any order, or modified.  The choice of data structure and algorithm can make the difference between a program running in a few seconds or many days.
  • 5. Efficiency  A solution is said to be efficient if it solves the problem within its resource constraints. • Space • Time  The cost of a solution is the amount of resources that the solution consumes.
  • 6. Selecting a Data Structure Select a data structure as follows: 1. Analyze the problem to determine the resource constraints a solution must meet. 2. Determine the basic operations that must be supported. Quantify the resource constraints for each operation. 3. Select the data structure that best meets these requirements.
  • 7. Some Questions to Ask • Are all data inserted into the data structure at the beginning, or are insertions interspersed with other operations? • Can data be deleted? • Are all data processed in some well-defined order, or is random access allowed?
  • 8. Data Structure Philosophy  Each data structure has costs and benefits.  Rarely is one data structure better than another in all situations.  A data structure requires: • space for each data item it stores, • time to perform each basic operation, • programming effort.
  • 9. Algorithms • An algorithm is any well defined computational procedure that takes some values or set of values as input and produces some value or set of values as output. • An algorithm is thus a sequence of computational steps that transforms the input into output.
  • 10. How do you learn algorithms to cook? • To become good chef, you don’t learn lots of recipes by heart. • You study existing recipes. • You practice making them. • You experiment with your own variations. • Until you can invent your own recipes.
  • 11. How do you learn about algorithms? • A good computer scientist doesn’t need to memorize a big book of algorithms. • We will begin studying famous algorithms. • You can practice executing them by hand. • Once you recognize more general patterns, you can experiment with your own variations. • At the end of the course, I expect you to invent algorithms yourself.
  • 12. Analysis of Algorithms The theoretical study of computer-program performance and resource usage. What’s more important than performance? • modularity • correctness • maintainability • functionality • robustness (strengths) • user-friendliness • programmer time • simplicity • extensibility • reliability
  • 13. Origin of word: Algorithm • The word Algorithm comes from the name of the muslim author Abu Ja’far Mohammad ibn Musaal-Khowarizmi. He was born in the eighth century at Khwarizm (Kheva), a town south of river Oxus in present Uzbekistan. Uzbekistan, a Muslim country for over a thousand years, was taken over by the Russians in 1873. • Much of al-Khwarizmi’s work was written in a book titled al Kitab al-mukhatasar fi hisab al-jabrwa’l-muqabalah (The Compendious Book on Calculation by Completion and Balancing). It is from the titles of these writings and his name that the words algebra and algorithm are derived. As a result of his work, al-Khwarizmi is regarded as the most outstanding mathematician of his time
  • 14. Algorithm: Informal Definition • An algorithm is any well-defined computational procedure that takes some values, or set of values, as input and produces some value, or set of values, as output. • An algorithm is thus a sequence of computational steps that transform the input into output.
  • 15. Algorithms, Programming • A good understanding of algorithms is essential for a good understanding of the most basic element of computer science: programming. Unlike a program, an algorithm is a mathematical entity, which is independent of a specific programming language, machine, or compiler. Thus, in some sense, algorithm design is all about the mathematical theory behind the design of good programs.
  • 16. Why study algorithms and performance? • Algorithms help us to understand scalability. • Performance often draws the line between what is feasible and what is impossible. • Algorithmic mathematics provides a language for talking about program behavior. • Performance is the currency of computing.
  • 17. Why Study Algorithms? • Necessary in any computer programming problem • Improve algorithm efficiency: run faster, process more data, do something that would otherwise be impossible • Solve problems of significantly large sizes • Compare algorithms • Algorithms as a field of study • Learn about a standard set of algorithms • New discoveries arise • Numerous application areas • Learn techniques of algorithm design and analysis • how does one coordinate the efforts of many programmers working on a single piece of software
  • 18. Applications • Multimedia • CD player, DVD, MP3, JPG, DivX • Internet • Packet routing, data retrieval (Google) • Communication • Cell-phones, e-commerce • Computers • Circuit layout, file systems • Science • Human genome (is the complete set of genetic information for humans) • Transportation • Airline crew scheduling, UPS deliveries
  • 19. Analyzing Algorithms • Predict the amount of resources required: • memory: how much space is needed? • computational time: how fast the algorithm runs? • FACT: running time grows with the size of the input • Input size (number of elements in the input) • Size of an array, polynomial degree, # of elements in a matrix, # of bits in the binary representation of the input, vertices and edges in a graph Def: Running time = the number of primitive operations (steps) executed before termination • Arithmetic operations (+, -, *), data movement, control, decision making (if, while), comparison
  • 20. Definition: Algorithm • A computer algorithm is a detailed step by step method for solving the problem • An algorithm is a sequence of Clear-cut instructions for solving the problem in a finite amount of time. • An algorithm is a set of well defined computational procedure that takes some values, or set of values, as input and produces some value or set of values as output. • More Generally an algorithm is any well defined computational procedure that takes collection of elements as input and procedures collection of elements as output.
  • 21. Definition: Data Structures • A data structure is systematic way of organizing and accessing data with a specific relationship between the elements. • Why data structures? Ultimate goal -- to write efficient programs. In order to do that, one needs to organize the data in such a way that it can be accessed and manipulated efficiently.
  • 22. Definition: Data Structures (Cont…) • A data structure is a way of arranging data in a computer's memory or other disk storage. • A data structure is a collection of data, organized so that items can be stored and retrieved by some fixed techniques. • Example: Suppose you are hired to create a database of names with all company's management and employees.
  • 23. Example: Data Structures • You can make a list. You can also make a tree.
  • 24. Data Structures Types • There are several common data structures: arrays, linked lists, queues, stacks, binary trees, hash tables, etc. • These data structures can be classified as either linear or nonlinear data structures, based on how the data is conceptually organized or aggregated.
  • 25. LinearVs Non-LinearData Structures Linear Structures Non-Linear Structures The array, list, queue, and stack belong to this category. Each of them is a collection that stores its entries in a linear sequence, and in which entries may be added or removed at will. They differ in the restrictions they place on how these entries may be added, removed, or accessed. The common restrictions include FIFO and LIFO. Trees and graphs are classical non- linear structures. Data entries are not arranged in a sequence, but with different rules.
  • 27. Data Structure Operations • The data appearing in our data structures are processed by means of certain operations. The following four operations play a major role : 1. Traversing: Accessing each record exactly once so that certain items in the record may be processed. 2. 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. 3. Inserting: Adding a new record to the structure. 4. Deleting : Removing a record from the structure.
  • 28. Data Structure Operations (Cont…) • Sometimes two or more of the operations may be used in given situations; e.g. we may want to delete the record with a given key, which may mean we first need to search for the location of the record. The following two operations , which are used in special situations, will be considered: 1. Sorting: Arranging record in some logical order (ascending/ descending) 2. Merging: Combining the records in two different sorted files into a single sorted file.
  • 29. For any query Feel Free to ask