SlideShare a Scribd company logo
Introduction:
Basic Concepts and Notations
Complexity analysis: time space tradeoff
Algorithmic notations, Big O notation
Introduction to omega, theta and little o
notation
Basic Concepts and Notations
Algorithm: Outline, the essence of a computational
procedure, step-by-step instructions
Program: an implementation of an algorithm in some
programming language
Data Structure: Organization of data needed to
solve the problem
Classification of Data
StructuresData Structures
Primitive
Data Structures
Non-Primitive
Data Structures
Linear
Data Structures
Non-Linear
Data Structures
• Integer
• Real
• Character
• Boolean
• Array
• Stack
• Queue
• Linked List
• Tree
• Graph
Data Structure Operations
Data Structures are processed by using certain operations.
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 location of all the records that satisfy one or
more conditions.
3.Inserting: Adding a new record to the structure.
4.Deleting: Removing a record from the structure.
Special Data Structure-
Operations
• Sorting: Arranging the records in some logical order
(Alphabetical or numerical order).
• Merging: Combining the records in two different sorted
files into a single sorted file.
Algorithmic Problem
Infinite number of input instances satisfying the
specification. For example: A sorted, non-decreasing
sequence of natural numbers of non-zero, finite
length:
1, 20, 908, 909, 100000, 1000000000.
3.
Specification
of input ?
Specification
of output as a
function of
input
Algorithmic Solution
Algorithm describes actions on the input instance
Infinitely many correct algorithms for the same
algorithmic problem
Specification
of input
Algorithm
Specification
of output as a
function of
input
What is a Good Algorithm?
Efficient:
Running time
Space used
Efficiency as a function of input size:
The number of bits in an input number
Number of data elements(numbers, points)
Complexity analysis
Why we should analyze algorithms?
Predict the resources that the algorithm requires
 Computational time (CPU consumption)
 Memory space (RAM consumption)
 Communication bandwidth consumption
The running time of an algorithm is:
 The total number of primitive operations executed (machine
independent steps)
 Also known as algorithm complexity
Time Complexity
Worst-case
An upper bound on the running time for any input of
given size
Average-case
Assume all inputs of a given size are equally likely
Best-case
The lower bound on the running time
Time Complexity – Example
Sequential search in a list of size n
Worst-case:
 n comparisons
Best-case:
 1 comparison
Average-case:
 n/2 comparisons
time space tradeoff
A time space tradeoff is a situation where the memory use
can be reduced at the cost of slower program execution
(and, conversely, the computation time can be reduced at
the cost of increased memory use).
As the relative costs of CPU cycles, RAM space, and hard
drive space change—hard drive space has for some time
been getting cheaper at a much faster rate than other
components of computers[citation needed]—the
appropriate choices for time space tradeoff have changed
radically.
Often, by exploiting a time space tradeoff, a program can
be made to run much faster.
Asymptotic notations
Algorithm complexity is rough estimation of
the number of steps performed by given
computation depending on the size of the
input data
Measured through asymptotic notation
O(g) where g is a function of the input data size
Examples:
 Linear complexity O(n) – all elements are processed once (or
constant number of times)
 Quadratic complexity O(n2
) – each of the elements is
processed n times
O-notation
Asymptotic upper bound
Example
The running time is O(n2
) means there is a function
f(n) that is O(n2
) such that for any value of n, no
matter what particular input of size n is chosen, the
running time of that input is bounded from above by
the value f(n).
3 * n2
+ n/2 + 12 ∈ O(n2
)
4*n*log2(3*n+1) + 2*n-1 ∈ O(n * log n)
Ω notation
Asymptotic lower bound
Example
When we say that the running time (no modifier) of
an algorithm is Ω (g(n)).
we mean that no matter what particular input of size
n is chosen for each value of n, the running time on
that input is at least a constant times g(n), for
sufficiently large n.
n3
+ 20n ∈ Ω(n2
)
Θ notation
g(n) is an asymptotically tight bound of f(n)
Example
little o notation
ω-notation
22
Notes on o-notation
O-notation may or may not be asymptotically
tight for upper bound.
2n2
= O(n2
) is tight, but 2n = O(n2
) is not tight.
o-notition is used to denote an upper bound
that is not tight.
2n = o(n2
), but 2n2
≠ o(n2
).
Difference: for some positive constant c in O-
notation, but all positive constants c in o-
notation.
In o-notation, f(n) becomes insignificant
relative to g(n) as n approaches infinitely.
Big O notation
f(n)=O(g(n)) iff there exist a positive constant c and
non-negative integer n0 such that
f(n) ≤ cg(n) for all n≥n0.
g(n) is said to be an upper bound of f(n).
Basic rules
1. Nested loops are multiplied together.
2. Sequential loops are added.
3. Only the largest term is kept, all others are
dropped.
4. Constants are dropped.
5. Conditional checks are constant (i.e. 1).
Example 1
//linear
for(i = 1 to n) {
 display i;
}
Ans: O(n)
Example 2
//quadratic
for(int i = 0; i < n; i++) {
 for(int j = 0; j < n; j++){
 //do swap stuff, constant time
 }
}
Ans O(n^2)
Example 3
for(int i = 0; i < 2*n; i++) {
 cout << i << endl;
}
At first you might say that the upper bound is O(2n);
however, we drop constants so it becomes O(n)
Example 4
//linear
for(int i = 0; i < n; i++) {
 cout << i << endl;
}

//quadratic
for(int i = 0; i < n; i++) {
 for(int j = 0; j < n; j++){
 //do constant time stuff
 }
}
Ans : In this case we add each loop's Big O, in this
case n+n^2. O(n^2+n) is not an acceptable answer
since we must drop the lowest term. The upper bound
is O(n^2). Why? Because it has the largest growth
rate
Example 5
for(int i = 0; i < n; i++) {
 for(int j = 0; j < 2; j++){
 //do stuff
 }
}
Ans: Outer loop is 'n', inner loop is 2, this we have 2n,
dropped constant gives up O(n)
Example 6
for(int i = 1; i < n; i *= 2) {
 cout << i << endl;
}
There are n iterations, however, instead of simply
incrementing, 'i' is increased by 2*itself each run.
Thus the loop is log(n).
Example 7
for(int i = 0; i < n; i++) { //linear
 for(int j = 1; j < n; j *= 2){ // log (n)
 //do constant time stuff
 }
}
Ans: n*log(n)
Comp 122
Thank You

More Related Content

PPT
C++ Data Structure PPT.ppt
Mukesh Thakur
 
PPTX
Data structures and algorithms
Julie Iskander
 
PPTX
Introduction to data structure and algorithms
Research Scholar in Manonmaniam Sundaranar University
 
PPT
Data Structures and Algorithm Analysis
Mary Margarat
 
PPT
Unit 1 introduction to data structure
kalyanineve
 
PDF
Data Structures
Prof. Dr. K. Adisesha
 
PDF
Data structures chapter 1
priyavanimurugarajan
 
PDF
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
C++ Data Structure PPT.ppt
Mukesh Thakur
 
Data structures and algorithms
Julie Iskander
 
Introduction to data structure and algorithms
Research Scholar in Manonmaniam Sundaranar University
 
Data Structures and Algorithm Analysis
Mary Margarat
 
Unit 1 introduction to data structure
kalyanineve
 
Data Structures
Prof. Dr. K. Adisesha
 
Data structures chapter 1
priyavanimurugarajan
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Sowmya Jyothi
 

What's hot (20)

PDF
Measures of query cost
Hitesh Mohapatra
 
PPT
Introduction to data structures and Algorithm
Dhaval Kaneria
 
PPTX
Hashing
Amar Jukuntla
 
PPTX
Graph traversals in Data Structures
Anandhasilambarasan D
 
PPTX
Data Structures (CS8391)
Elavarasi K
 
PPT
Divide and conquer
Dr Shashikant Athawale
 
PPT
Pattern matching
shravs_188
 
PPT
Dinive conquer algorithm
Mohd Arif
 
PDF
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
PPTX
Binary search
AparnaKumari31
 
PDF
Algorithms Lecture 4: Sorting Algorithms I
Mohamed Loey
 
PPTX
Linked list
KalaivaniKS1
 
PPT
Binary Search
kunj desai
 
PPTX
Demand paging
SwaroopSorte
 
PPT
Heap tree
Shankar Bishnoi
 
PPTX
Instruction Formats
RaaviKapoor
 
PPTX
Data Structures and Algorithm - Module 1.pptx
EllenGrace9
 
PPT
header, circular and two way linked lists
student
 
PPT
Abstract data types
Poojith Chowdhary
 
PPTX
Tree - Data Structure
Ashim Lamichhane
 
Measures of query cost
Hitesh Mohapatra
 
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Hashing
Amar Jukuntla
 
Graph traversals in Data Structures
Anandhasilambarasan D
 
Data Structures (CS8391)
Elavarasi K
 
Divide and conquer
Dr Shashikant Athawale
 
Pattern matching
shravs_188
 
Dinive conquer algorithm
Mohd Arif
 
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
Binary search
AparnaKumari31
 
Algorithms Lecture 4: Sorting Algorithms I
Mohamed Loey
 
Linked list
KalaivaniKS1
 
Binary Search
kunj desai
 
Demand paging
SwaroopSorte
 
Heap tree
Shankar Bishnoi
 
Instruction Formats
RaaviKapoor
 
Data Structures and Algorithm - Module 1.pptx
EllenGrace9
 
header, circular and two way linked lists
student
 
Abstract data types
Poojith Chowdhary
 
Tree - Data Structure
Ashim Lamichhane
 
Ad

Similar to Data Structure and Algorithms (20)

PPT
Basics of data structure types of data structures
kavita20193
 
PPT
How to calculate complexity in Data Structure
debasisdas225831
 
PPT
Time complexity.ppt
YekoyeTigabuYeko
 
PPT
Time complexity.pptr56435 erfgegr t 45t 35
DickyNsjg1
 
PPT
how to calclute time complexity of algortihm
Sajid Marwat
 
PPT
Algorithm And analysis Lecture 03& 04-time complexity.
Tariq Khan
 
PPTX
asymptotic analysis and insertion sort analysis
Anindita Kundu
 
PPTX
Time complexity.pptxghhhhhhhhhhhhhhhjjjjjjjjjjjjjjjjjjjjjjjjjj
shesnasuneer
 
PDF
Annotations.pdf
GauravKumar295392
 
PPT
Lecture 1 and 2 of Data Structures & Algorithms
haseebanjum2611
 
PPTX
Algorithm for the DAA agscsnak javausmagagah
RaviPandey598038
 
PPTX
Algorithm Complexity and Main Concepts
Adelina Ahadova
 
PPT
Lec03 04-time complexity
Abbas Ali
 
PPTX
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
Tanya Makkar
 
PDF
Data Structure & Algorithms - Introduction
babuk110
 
PPTX
1_Asymptotic_Notation_pptx.pptx
pallavidhade2
 
PDF
Chapter One.pdf
abay golla
 
PPT
Data_Structure_and_Algorithms_Lecture_1.ppt
ISHANAMRITSRIVASTAVA
 
PDF
Data Structure & Algorithms - Mathematical
babuk110
 
Basics of data structure types of data structures
kavita20193
 
How to calculate complexity in Data Structure
debasisdas225831
 
Time complexity.ppt
YekoyeTigabuYeko
 
Time complexity.pptr56435 erfgegr t 45t 35
DickyNsjg1
 
how to calclute time complexity of algortihm
Sajid Marwat
 
Algorithm And analysis Lecture 03& 04-time complexity.
Tariq Khan
 
asymptotic analysis and insertion sort analysis
Anindita Kundu
 
Time complexity.pptxghhhhhhhhhhhhhhhjjjjjjjjjjjjjjjjjjjjjjjjjj
shesnasuneer
 
Annotations.pdf
GauravKumar295392
 
Lecture 1 and 2 of Data Structures & Algorithms
haseebanjum2611
 
Algorithm for the DAA agscsnak javausmagagah
RaviPandey598038
 
Algorithm Complexity and Main Concepts
Adelina Ahadova
 
Lec03 04-time complexity
Abbas Ali
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
Tanya Makkar
 
Data Structure & Algorithms - Introduction
babuk110
 
1_Asymptotic_Notation_pptx.pptx
pallavidhade2
 
Chapter One.pdf
abay golla
 
Data_Structure_and_Algorithms_Lecture_1.ppt
ISHANAMRITSRIVASTAVA
 
Data Structure & Algorithms - Mathematical
babuk110
 
Ad

More from ManishPrajapati78 (15)

PPT
Data Structure and Algorithms Binary Search Tree
ManishPrajapati78
 
PPT
Data Structure and Algorithms Binary Tree
ManishPrajapati78
 
PPT
Data Structure and Algorithms Queues
ManishPrajapati78
 
PPTX
Data Structure and Algorithms Merge Sort
ManishPrajapati78
 
PPTX
Data Structure and Algorithms The Tower of Hanoi
ManishPrajapati78
 
PPT
Data Structure and Algorithms Stacks
ManishPrajapati78
 
PPT
Data Structure and Algorithms Linked List
ManishPrajapati78
 
PPT
Data Structure and Algorithms Sorting
ManishPrajapati78
 
PPT
Data Structure and Algorithms Arrays
ManishPrajapati78
 
PPT
Data Structure and Algorithms Hashing
ManishPrajapati78
 
PPTX
Data Structure and Algorithms Graph Traversal
ManishPrajapati78
 
PPT
Data Structure and Algorithms Graphs
ManishPrajapati78
 
PPT
Data Structure and Algorithms Huffman Coding Algorithm
ManishPrajapati78
 
PPT
Data Structure and Algorithms Heaps and Trees
ManishPrajapati78
 
PPT
Data Structure and Algorithms AVL Trees
ManishPrajapati78
 
Data Structure and Algorithms Binary Search Tree
ManishPrajapati78
 
Data Structure and Algorithms Binary Tree
ManishPrajapati78
 
Data Structure and Algorithms Queues
ManishPrajapati78
 
Data Structure and Algorithms Merge Sort
ManishPrajapati78
 
Data Structure and Algorithms The Tower of Hanoi
ManishPrajapati78
 
Data Structure and Algorithms Stacks
ManishPrajapati78
 
Data Structure and Algorithms Linked List
ManishPrajapati78
 
Data Structure and Algorithms Sorting
ManishPrajapati78
 
Data Structure and Algorithms Arrays
ManishPrajapati78
 
Data Structure and Algorithms Hashing
ManishPrajapati78
 
Data Structure and Algorithms Graph Traversal
ManishPrajapati78
 
Data Structure and Algorithms Graphs
ManishPrajapati78
 
Data Structure and Algorithms Huffman Coding Algorithm
ManishPrajapati78
 
Data Structure and Algorithms Heaps and Trees
ManishPrajapati78
 
Data Structure and Algorithms AVL Trees
ManishPrajapati78
 

Recently uploaded (20)

PDF
Become an Agentblazer Champion Challenge
Dele Amefo
 
PDF
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Hironori Washizaki
 
PDF
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PDF
Microsoft Teams Essentials; The pricing and the versions_PDF.pdf
Q-Advise
 
PDF
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
QAware GmbH
 
PDF
How to Seamlessly Integrate Salesforce Data Cloud with Marketing Cloud.pdf
NSIQINFOTECH
 
PDF
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
DOCX
The Five Best AI Cover Tools in 2025.docx
aivoicelabofficial
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PDF
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
Q-Advise
 
PDF
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
PPTX
Materi_Pemrograman_Komputer-Looping.pptx
RanuFajar1
 
PPTX
AZ900_SLA_Pricing_2025_LondonIT (1).pptx
chumairabdullahph
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
PDF
Appium Automation Testing Tutorial PDF: Learn Mobile Testing in 7 Days
jamescantor38
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
Become an Agentblazer Champion Challenge
Dele Amefo
 
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Hironori Washizaki
 
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Microsoft Teams Essentials; The pricing and the versions_PDF.pdf
Q-Advise
 
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
QAware GmbH
 
How to Seamlessly Integrate Salesforce Data Cloud with Marketing Cloud.pdf
NSIQINFOTECH
 
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
The Five Best AI Cover Tools in 2025.docx
aivoicelabofficial
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
Q-Advise
 
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
Materi_Pemrograman_Komputer-Looping.pptx
RanuFajar1
 
AZ900_SLA_Pricing_2025_LondonIT (1).pptx
chumairabdullahph
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
Appium Automation Testing Tutorial PDF: Learn Mobile Testing in 7 Days
jamescantor38
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 

Data Structure and Algorithms

  • 1. Introduction: Basic Concepts and Notations Complexity analysis: time space tradeoff Algorithmic notations, Big O notation Introduction to omega, theta and little o notation
  • 2. Basic Concepts and Notations Algorithm: Outline, the essence of a computational procedure, step-by-step instructions Program: an implementation of an algorithm in some programming language Data Structure: Organization of data needed to solve the problem
  • 3. Classification of Data StructuresData Structures Primitive Data Structures Non-Primitive Data Structures Linear Data Structures Non-Linear Data Structures • Integer • Real • Character • Boolean • Array • Stack • Queue • Linked List • Tree • Graph
  • 4. Data Structure Operations Data Structures are processed by using certain operations. 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 location of all the records that satisfy one or more conditions. 3.Inserting: Adding a new record to the structure. 4.Deleting: Removing a record from the structure.
  • 5. Special Data Structure- Operations • Sorting: Arranging the records in some logical order (Alphabetical or numerical order). • Merging: Combining the records in two different sorted files into a single sorted file.
  • 6. Algorithmic Problem Infinite number of input instances satisfying the specification. For example: A sorted, non-decreasing sequence of natural numbers of non-zero, finite length: 1, 20, 908, 909, 100000, 1000000000. 3. Specification of input ? Specification of output as a function of input
  • 7. Algorithmic Solution Algorithm describes actions on the input instance Infinitely many correct algorithms for the same algorithmic problem Specification of input Algorithm Specification of output as a function of input
  • 8. What is a Good Algorithm? Efficient: Running time Space used Efficiency as a function of input size: The number of bits in an input number Number of data elements(numbers, points)
  • 9. Complexity analysis Why we should analyze algorithms? Predict the resources that the algorithm requires  Computational time (CPU consumption)  Memory space (RAM consumption)  Communication bandwidth consumption The running time of an algorithm is:  The total number of primitive operations executed (machine independent steps)  Also known as algorithm complexity
  • 10. Time Complexity Worst-case An upper bound on the running time for any input of given size Average-case Assume all inputs of a given size are equally likely Best-case The lower bound on the running time
  • 11. Time Complexity – Example Sequential search in a list of size n Worst-case:  n comparisons Best-case:  1 comparison Average-case:  n/2 comparisons
  • 12. time space tradeoff A time space tradeoff is a situation where the memory use can be reduced at the cost of slower program execution (and, conversely, the computation time can be reduced at the cost of increased memory use). As the relative costs of CPU cycles, RAM space, and hard drive space change—hard drive space has for some time been getting cheaper at a much faster rate than other components of computers[citation needed]—the appropriate choices for time space tradeoff have changed radically. Often, by exploiting a time space tradeoff, a program can be made to run much faster.
  • 13. Asymptotic notations Algorithm complexity is rough estimation of the number of steps performed by given computation depending on the size of the input data Measured through asymptotic notation O(g) where g is a function of the input data size Examples:  Linear complexity O(n) – all elements are processed once (or constant number of times)  Quadratic complexity O(n2 ) – each of the elements is processed n times
  • 15. Example The running time is O(n2 ) means there is a function f(n) that is O(n2 ) such that for any value of n, no matter what particular input of size n is chosen, the running time of that input is bounded from above by the value f(n). 3 * n2 + n/2 + 12 ∈ O(n2 ) 4*n*log2(3*n+1) + 2*n-1 ∈ O(n * log n)
  • 17. Example When we say that the running time (no modifier) of an algorithm is Ω (g(n)). we mean that no matter what particular input of size n is chosen for each value of n, the running time on that input is at least a constant times g(n), for sufficiently large n. n3 + 20n ∈ Ω(n2 )
  • 18. Θ notation g(n) is an asymptotically tight bound of f(n)
  • 22. 22 Notes on o-notation O-notation may or may not be asymptotically tight for upper bound. 2n2 = O(n2 ) is tight, but 2n = O(n2 ) is not tight. o-notition is used to denote an upper bound that is not tight. 2n = o(n2 ), but 2n2 ≠ o(n2 ). Difference: for some positive constant c in O- notation, but all positive constants c in o- notation. In o-notation, f(n) becomes insignificant relative to g(n) as n approaches infinitely.
  • 23. Big O notation f(n)=O(g(n)) iff there exist a positive constant c and non-negative integer n0 such that f(n) ≤ cg(n) for all n≥n0. g(n) is said to be an upper bound of f(n).
  • 24. Basic rules 1. Nested loops are multiplied together. 2. Sequential loops are added. 3. Only the largest term is kept, all others are dropped. 4. Constants are dropped. 5. Conditional checks are constant (i.e. 1).
  • 25. Example 1 //linear for(i = 1 to n) {  display i; }
  • 27. Example 2 //quadratic for(int i = 0; i < n; i++) {  for(int j = 0; j < n; j++){  //do swap stuff, constant time  } }
  • 29. Example 3 for(int i = 0; i < 2*n; i++) {  cout << i << endl; }
  • 30. At first you might say that the upper bound is O(2n); however, we drop constants so it becomes O(n)
  • 31. Example 4 //linear for(int i = 0; i < n; i++) {  cout << i << endl; }  //quadratic for(int i = 0; i < n; i++) {  for(int j = 0; j < n; j++){  //do constant time stuff  } }
  • 32. Ans : In this case we add each loop's Big O, in this case n+n^2. O(n^2+n) is not an acceptable answer since we must drop the lowest term. The upper bound is O(n^2). Why? Because it has the largest growth rate
  • 33. Example 5 for(int i = 0; i < n; i++) {  for(int j = 0; j < 2; j++){  //do stuff  } }
  • 34. Ans: Outer loop is 'n', inner loop is 2, this we have 2n, dropped constant gives up O(n)
  • 35. Example 6 for(int i = 1; i < n; i *= 2) {  cout << i << endl; }
  • 36. There are n iterations, however, instead of simply incrementing, 'i' is increased by 2*itself each run. Thus the loop is log(n).
  • 37. Example 7 for(int i = 0; i < n; i++) { //linear  for(int j = 1; j < n; j *= 2){ // log (n)  //do constant time stuff  } }

Editor's Notes

  • #4: 목차 자바의 생성배경 자바를 사용하는 이유 과거, 현재, 미래의 자바 자바의 발전과정 버전별 JDK에 대한 설명 자바와 C++의 차이점 자바의 성능 자바 관련 산업(?)의 경향
  • #5: 목차 자바의 생성배경 자바를 사용하는 이유 과거, 현재, 미래의 자바 자바의 발전과정 버전별 JDK에 대한 설명 자바와 C++의 차이점 자바의 성능 자바 관련 산업(?)의 경향
  • #6: 목차 자바의 생성배경 자바를 사용하는 이유 과거, 현재, 미래의 자바 자바의 발전과정 버전별 JDK에 대한 설명 자바와 C++의 차이점 자바의 성능 자바 관련 산업(?)의 경향