SlideShare a Scribd company logo
1 of 11
Welcome To
My
Presentation.
2/25/2019 1
Submitted To:
Shariful Islam
Lecturer,Software Engineering
Daffodil Internationl University
Submitted By:
Md Emran
ID:181-35-312
2/25/2019 2
Presentation Topic:
O(nlogk) Approach
2/25/2019 3
What is LIS?
LIS abbreviated as “Longest Increasing Subsequence”.
Longest Increasing Subsequence is a subsequence where one item is
greater than its previous item.
It consists of three parts:
Longest - stands for its own meaning.
Increasing - means that it must be an increasing something, for example
[1, 2, 3, 7, 20] is an increasing sequence but [1, 4, 2, 5] is definitely not
an increasing sequence because we have 2 after 4.
Formally, a sequence [a1, a2 ... an] is increasing if a1 < a2 < a3 < … < an.
2/25/2019 4
Subsequence - means a new sequence consisting of some numbers from the
original sequence but the numbers maintain the relative ordering.
For example:
If the sequence is [2,5,3,6,7] then [2, 5, 6,7], [2, 3, 6,7] and [5, 6, 7] etc are
valid subsequences but [2, 3, 5] is not valid. Cause in the original sequence 3 is
listed after 5.
2/25/2019 5
O(nlogk) Approach:
Now I want to describe O(nlogk) approach with An ARRAY.
1) Initially i make a new array, let the name be M[], initially all the
values of the array are infinite, only the 0th element contains
negative infinite. The size of M[] will be total elements in the
sequence + 1.
2) Now I iterate from left and I pick the numbers from Sequence one by
one and insert them into M[]. When inserting a number, I find the
position where all the numbers in left are strictly smaller than the
number.
3) If I insert the numbers this array in M[] will always be in ascending
order.
However, the example will show the procedure fully…
Let’s start…….. 2/25/2019 6
Let, the sequence be
Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2]
There are 10 elements, so, I will contain 11 elements with index from 0 to 10.
So, as described, the elements of M[] will be initially,
M [-i, i, i, i, i, i, i, i, i, i, i]
index 0 1 2 3 4 5 6 7 8 9 10
Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2]
LIS [n, n, n, n, n, n, n, n, n, n]
Here i denotes ‘infinite’ and n denotes ‘not calculated yet’.
Now let’s insert the numbers from sequence into M[].
1) At first we have 8, so the position for 8 in M[] is 1. Since the left item is –i which is
smaller than 8. So, I will assign M[1] = 8. Since 8 is inserted in 1st place, so the
LIS[] value of 8 will be 1. After the first number we will get
M [-i, 8, i, i, i, i, i, i, i, i, i]
index 0 1 2 3 4 5 6 7 8 9 10
Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2]
LIS [1, n, n, n, n, n, n, n, n, n]
2/25/2019 7
2) Now I have 1, the position for 1 in M[] is 1. So, we will assign M[1] = 1 and since 1 is inserted in
1st place, the LIS[] value of 1 will be 1. Observe that M[1] was 8, but after this iteration 8 will be
replaced by 1.
M [-i, 1, i, i, i, i, i, i, i, i, i]
index 0 1 2 3 4 5 6 7 8 9 10
Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2]
LIS [1, 1, n, n, n, n, n, n, n, n]
3) The next number is 9. The position for 9 in M[] is definitely the 2nd position. So, we will assign
M[2] = 9, and since 9 is inserted in the second position, so the LIS[] value of 9 will be 2.
M [-i, 1, 9, i, i, i, i, i, i, i, i]
index 0 1 2 3 4 5 6 7 8 9 10
Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2]
LIS [1, 1, 2, n, n, n, n, n, n, n]
4) Now we have 8, and the position of this 8 in M[] is the second position. So, we put 8 in the
second position of M[] (thus replacing 9). And the LIS[] value of 8 will be 2.
M [-i, 1, 8, i, i, i, i, i, i, i, i]
Index 0 1 2 3 4 5 6 7 8 9 10
Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2]
LIS [1, 1, 2, 2, n, n, n, n, n, n]
2/25/2019 8
5) The next item is 3, and the position in M[] is still the second position. So, I place 3 in the second
position of M[]. And the LIS[] value of 3 is 2.
M [-i, 1, 3, i, i, i, i, i, i, i, i]
index 0 1 2 3 4 5 6 7 8 9 10
Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2]
LIS [1, 1, 2, 2, 2, n, n, n, n, n]
6) Now we have 4, and the position in M[] is 3. So, the LIS[] value of 4 is 3.
M [-i, 1, 3, 4, i, i, i, i, i, i, i]
index 0 1 2 3 4 5 6 7 8 9 10
Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2]
LIS [1, 1, 2, 2, 2, 3, n, n, n, n]
7) Next item is 6, it will be inserted in the 4th position of M[]. So, the LIS[] value of 6 will be 4.
M [-i, 1, 3, 4, 6, i, i, i, i, i, i]
index 0 1 2 3 4 5 6 7 8 9 10
Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2]
LIS [1, 1, 2, 2, 2, 3, 4, n, n, n]
8) Next item is 1, it will be inserted in the 1st position of M[]. So, the L[] value of 1 will be 1.
M [-i, 1, 3, 4, 6, i, i, i, i, i, i]
index 0 1 2 3 4 5 6 7 8 9 10
Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2]
LIS [1, 1, 2, 2, 2, 3, 4, 1, n, n]
2/25/2019 9
9)Next item is 5, it will be inserted in the 4th position of M[]. So, the LIS[] value of 5 will be 4.
M [-i, 1, 3, 4, 5, i, i, i, i, i, i]
index 0 1 2 3 4 5 6 7 8 9 10
Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2]
LIS [1, 1, 2, 2, 2, 3, 4, 1, 4, n]
10)Last item is 2, it will be inserted in the 2 nd position of M[]. So, the LIS[] value of 2 will be 2.
M [-i, 1, 2, 4, 5, i, i, i, i, i, i]
Index 0 1 2 3 4 5 6 7 8 9 10
Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2]
LIS [1, 1, 2, 2, 2, 3, 4, 1, 4, 2]
Now, see that completely process the values in M[] are in ascending order. And since we place a
number in such a place where all the numbers in left are strictly less than the number so, the LIS[]
value will be correct for all the numbers.
One more thing, after all the iterations are over, don’t think that M[] will also contain a sequence.
Because in the example above, see that 1, 2, 4, 5 is not the correct sequence. To get a sequence,
since we already have the LIS[] values, we can use the reconstruction method. Now since the values in
M[] will always be in ascending order, so, to find a position of a number we can definitely use binary
search. So, if the final LIS length is k and there are n numbers then 10 . To insert a number using
binary search the complexity will be O(logk). Thus the overall complexity will be O(nlogk), since we
are inserting n items.
2/25/2019 10
Have You Any
Question??
Thank You
2/25/2019 11

More Related Content

What's hot

Adding Matrices
Adding MatricesAdding Matrices
Adding Matricestempl073
 
Adding Matrices
Adding MatricesAdding Matrices
Adding Matricestempl073
 
Addition shortcuts
Addition shortcutsAddition shortcuts
Addition shortcutsRusty Aquino
 
Adding Numbers with Regrouping
Adding Numbers with RegroupingAdding Numbers with Regrouping
Adding Numbers with RegroupingJohdener14
 
Adding without Regrouping
Adding without RegroupingAdding without Regrouping
Adding without RegroupingJohdener14
 
Adding Without Regrouping
Adding Without RegroupingAdding Without Regrouping
Adding Without RegroupingJohdener14
 
Basic math (addition)
Basic math (addition)Basic math (addition)
Basic math (addition)itutor
 
FRCC MAT050 Writing Equations of Lines II (Sect 3.6)
FRCC MAT050 Writing Equations of Lines II (Sect 3.6)FRCC MAT050 Writing Equations of Lines II (Sect 3.6)
FRCC MAT050 Writing Equations of Lines II (Sect 3.6)cccscoetc
 
New Approach to Find the Maxima and Minima of a Function
New Approach to Find the Maxima and Minima of a FunctionNew Approach to Find the Maxima and Minima of a Function
New Approach to Find the Maxima and Minima of a Functionijtsrd
 
January 6, 2014 intro to functions
January 6, 2014 intro to functionsJanuary 6, 2014 intro to functions
January 6, 2014 intro to functionskhyps13
 
5 5b Slope Intercept Form from Two Points
5 5b Slope Intercept Form from Two Points5 5b Slope Intercept Form from Two Points
5 5b Slope Intercept Form from Two PointsBitsy Griffin
 
Regrouping PowerPoing
Regrouping PowerPoingRegrouping PowerPoing
Regrouping PowerPoing4Lailank
 

What's hot (19)

Adding Matrices
Adding MatricesAdding Matrices
Adding Matrices
 
Adding Matrices
Adding MatricesAdding Matrices
Adding Matrices
 
Addition shortcuts
Addition shortcutsAddition shortcuts
Addition shortcuts
 
Adding Numbers with Regrouping
Adding Numbers with RegroupingAdding Numbers with Regrouping
Adding Numbers with Regrouping
 
Adding without Regrouping
Adding without RegroupingAdding without Regrouping
Adding without Regrouping
 
D.e.v
D.e.vD.e.v
D.e.v
 
Closure properties of numbers
Closure properties of numbersClosure properties of numbers
Closure properties of numbers
 
Adding Without Regrouping
Adding Without RegroupingAdding Without Regrouping
Adding Without Regrouping
 
Basic math (addition)
Basic math (addition)Basic math (addition)
Basic math (addition)
 
FRCC MAT050 Writing Equations of Lines II (Sect 3.6)
FRCC MAT050 Writing Equations of Lines II (Sect 3.6)FRCC MAT050 Writing Equations of Lines II (Sect 3.6)
FRCC MAT050 Writing Equations of Lines II (Sect 3.6)
 
Radix sorting
Radix sortingRadix sorting
Radix sorting
 
New Approach to Find the Maxima and Minima of a Function
New Approach to Find the Maxima and Minima of a FunctionNew Approach to Find the Maxima and Minima of a Function
New Approach to Find the Maxima and Minima of a Function
 
January 6, 2014 intro to functions
January 6, 2014 intro to functionsJanuary 6, 2014 intro to functions
January 6, 2014 intro to functions
 
5 5b Slope Intercept Form from Two Points
5 5b Slope Intercept Form from Two Points5 5b Slope Intercept Form from Two Points
5 5b Slope Intercept Form from Two Points
 
009 lesson 1
009 lesson 1009 lesson 1
009 lesson 1
 
Regrouping PowerPoing
Regrouping PowerPoingRegrouping PowerPoing
Regrouping PowerPoing
 
ON SQUARING A NUMBER AND T-SEMI PRIME NUMBER
ON SQUARING A NUMBER AND T-SEMI PRIME NUMBER ON SQUARING A NUMBER AND T-SEMI PRIME NUMBER
ON SQUARING A NUMBER AND T-SEMI PRIME NUMBER
 
Chapter 1, Lesson 3
Chapter 1, Lesson 3Chapter 1, Lesson 3
Chapter 1, Lesson 3
 
Addition vertical
Addition verticalAddition vertical
Addition vertical
 

Similar to LIS O(nlogk) approach Algorithm

Chapter 10.ppt
Chapter 10.pptChapter 10.ppt
Chapter 10.pptMithuBose3
 
358 33 powerpoint-slides_5-arrays_chapter-5
358 33 powerpoint-slides_5-arrays_chapter-5358 33 powerpoint-slides_5-arrays_chapter-5
358 33 powerpoint-slides_5-arrays_chapter-5sumitbardhan
 
Array 2
Array 2Array 2
Array 2Abbott
 
Data Structure and Algorithms Arrays
Data Structure and Algorithms ArraysData Structure and Algorithms Arrays
Data Structure and Algorithms ArraysManishPrajapati78
 
Introducing R
Introducing RIntroducing R
Introducing Rnzfauna
 
ds 2Arrays.ppt
ds 2Arrays.pptds 2Arrays.ppt
ds 2Arrays.pptAlliVinay1
 
CE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdfCE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdfUmarMustafa13
 
use python Problem 2. Selection Sort In this problem you will implem.pdf
use python Problem 2. Selection Sort In this problem you will implem.pdfuse python Problem 2. Selection Sort In this problem you will implem.pdf
use python Problem 2. Selection Sort In this problem you will implem.pdfsales223546
 
python_avw - Unit-03.pdf
python_avw - Unit-03.pdfpython_avw - Unit-03.pdf
python_avw - Unit-03.pdfAshaWankar1
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updatedvrgokila
 
Time Table Scheduling Problem Using Fuzzy Algorithmic Approach
Time Table Scheduling Problem Using Fuzzy Algorithmic ApproachTime Table Scheduling Problem Using Fuzzy Algorithmic Approach
Time Table Scheduling Problem Using Fuzzy Algorithmic ApproachWaqas Tariq
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...ijceronline
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...ijceronline
 
Arithmetic And Geometric Progressions
Arithmetic And Geometric ProgressionsArithmetic And Geometric Progressions
Arithmetic And Geometric ProgressionsFinni Rice
 

Similar to LIS O(nlogk) approach Algorithm (20)

Chapter 10.ppt
Chapter 10.pptChapter 10.ppt
Chapter 10.ppt
 
358 33 powerpoint-slides_5-arrays_chapter-5
358 33 powerpoint-slides_5-arrays_chapter-5358 33 powerpoint-slides_5-arrays_chapter-5
358 33 powerpoint-slides_5-arrays_chapter-5
 
Array 2
Array 2Array 2
Array 2
 
Data Structure and Algorithms Arrays
Data Structure and Algorithms ArraysData Structure and Algorithms Arrays
Data Structure and Algorithms Arrays
 
Sequences
SequencesSequences
Sequences
 
Introducing R
Introducing RIntroducing R
Introducing R
 
ds 2Arrays.ppt
ds 2Arrays.pptds 2Arrays.ppt
ds 2Arrays.ppt
 
CE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdfCE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdf
 
use python Problem 2. Selection Sort In this problem you will implem.pdf
use python Problem 2. Selection Sort In this problem you will implem.pdfuse python Problem 2. Selection Sort In this problem you will implem.pdf
use python Problem 2. Selection Sort In this problem you will implem.pdf
 
python_avw - Unit-03.pdf
python_avw - Unit-03.pdfpython_avw - Unit-03.pdf
python_avw - Unit-03.pdf
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updated
 
Time Table Scheduling Problem Using Fuzzy Algorithmic Approach
Time Table Scheduling Problem Using Fuzzy Algorithmic ApproachTime Table Scheduling Problem Using Fuzzy Algorithmic Approach
Time Table Scheduling Problem Using Fuzzy Algorithmic Approach
 
Vectormaths and Matrix in R.pptx
Vectormaths and Matrix in R.pptxVectormaths and Matrix in R.pptx
Vectormaths and Matrix in R.pptx
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
 
Ap gp
Ap gpAp gp
Ap gp
 
Arithmetic And Geometric Progressions
Arithmetic And Geometric ProgressionsArithmetic And Geometric Progressions
Arithmetic And Geometric Progressions
 
Sequence function
Sequence functionSequence function
Sequence function
 
Segment tree
Segment treeSegment tree
Segment tree
 
Sortsearch
SortsearchSortsearch
Sortsearch
 

Recently uploaded

Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...amitlee9823
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsJoseMangaJr1
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramMoniSankarHazra
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...amitlee9823
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...amitlee9823
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceDelhi Call girls
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 

Recently uploaded (20)

Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 

LIS O(nlogk) approach Algorithm

  • 2. Submitted To: Shariful Islam Lecturer,Software Engineering Daffodil Internationl University Submitted By: Md Emran ID:181-35-312 2/25/2019 2
  • 4. What is LIS? LIS abbreviated as “Longest Increasing Subsequence”. Longest Increasing Subsequence is a subsequence where one item is greater than its previous item. It consists of three parts: Longest - stands for its own meaning. Increasing - means that it must be an increasing something, for example [1, 2, 3, 7, 20] is an increasing sequence but [1, 4, 2, 5] is definitely not an increasing sequence because we have 2 after 4. Formally, a sequence [a1, a2 ... an] is increasing if a1 < a2 < a3 < … < an. 2/25/2019 4
  • 5. Subsequence - means a new sequence consisting of some numbers from the original sequence but the numbers maintain the relative ordering. For example: If the sequence is [2,5,3,6,7] then [2, 5, 6,7], [2, 3, 6,7] and [5, 6, 7] etc are valid subsequences but [2, 3, 5] is not valid. Cause in the original sequence 3 is listed after 5. 2/25/2019 5
  • 6. O(nlogk) Approach: Now I want to describe O(nlogk) approach with An ARRAY. 1) Initially i make a new array, let the name be M[], initially all the values of the array are infinite, only the 0th element contains negative infinite. The size of M[] will be total elements in the sequence + 1. 2) Now I iterate from left and I pick the numbers from Sequence one by one and insert them into M[]. When inserting a number, I find the position where all the numbers in left are strictly smaller than the number. 3) If I insert the numbers this array in M[] will always be in ascending order. However, the example will show the procedure fully… Let’s start…….. 2/25/2019 6
  • 7. Let, the sequence be Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2] There are 10 elements, so, I will contain 11 elements with index from 0 to 10. So, as described, the elements of M[] will be initially, M [-i, i, i, i, i, i, i, i, i, i, i] index 0 1 2 3 4 5 6 7 8 9 10 Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2] LIS [n, n, n, n, n, n, n, n, n, n] Here i denotes ‘infinite’ and n denotes ‘not calculated yet’. Now let’s insert the numbers from sequence into M[]. 1) At first we have 8, so the position for 8 in M[] is 1. Since the left item is –i which is smaller than 8. So, I will assign M[1] = 8. Since 8 is inserted in 1st place, so the LIS[] value of 8 will be 1. After the first number we will get M [-i, 8, i, i, i, i, i, i, i, i, i] index 0 1 2 3 4 5 6 7 8 9 10 Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2] LIS [1, n, n, n, n, n, n, n, n, n] 2/25/2019 7
  • 8. 2) Now I have 1, the position for 1 in M[] is 1. So, we will assign M[1] = 1 and since 1 is inserted in 1st place, the LIS[] value of 1 will be 1. Observe that M[1] was 8, but after this iteration 8 will be replaced by 1. M [-i, 1, i, i, i, i, i, i, i, i, i] index 0 1 2 3 4 5 6 7 8 9 10 Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2] LIS [1, 1, n, n, n, n, n, n, n, n] 3) The next number is 9. The position for 9 in M[] is definitely the 2nd position. So, we will assign M[2] = 9, and since 9 is inserted in the second position, so the LIS[] value of 9 will be 2. M [-i, 1, 9, i, i, i, i, i, i, i, i] index 0 1 2 3 4 5 6 7 8 9 10 Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2] LIS [1, 1, 2, n, n, n, n, n, n, n] 4) Now we have 8, and the position of this 8 in M[] is the second position. So, we put 8 in the second position of M[] (thus replacing 9). And the LIS[] value of 8 will be 2. M [-i, 1, 8, i, i, i, i, i, i, i, i] Index 0 1 2 3 4 5 6 7 8 9 10 Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2] LIS [1, 1, 2, 2, n, n, n, n, n, n] 2/25/2019 8
  • 9. 5) The next item is 3, and the position in M[] is still the second position. So, I place 3 in the second position of M[]. And the LIS[] value of 3 is 2. M [-i, 1, 3, i, i, i, i, i, i, i, i] index 0 1 2 3 4 5 6 7 8 9 10 Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2] LIS [1, 1, 2, 2, 2, n, n, n, n, n] 6) Now we have 4, and the position in M[] is 3. So, the LIS[] value of 4 is 3. M [-i, 1, 3, 4, i, i, i, i, i, i, i] index 0 1 2 3 4 5 6 7 8 9 10 Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2] LIS [1, 1, 2, 2, 2, 3, n, n, n, n] 7) Next item is 6, it will be inserted in the 4th position of M[]. So, the LIS[] value of 6 will be 4. M [-i, 1, 3, 4, 6, i, i, i, i, i, i] index 0 1 2 3 4 5 6 7 8 9 10 Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2] LIS [1, 1, 2, 2, 2, 3, 4, n, n, n] 8) Next item is 1, it will be inserted in the 1st position of M[]. So, the L[] value of 1 will be 1. M [-i, 1, 3, 4, 6, i, i, i, i, i, i] index 0 1 2 3 4 5 6 7 8 9 10 Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2] LIS [1, 1, 2, 2, 2, 3, 4, 1, n, n] 2/25/2019 9
  • 10. 9)Next item is 5, it will be inserted in the 4th position of M[]. So, the LIS[] value of 5 will be 4. M [-i, 1, 3, 4, 5, i, i, i, i, i, i] index 0 1 2 3 4 5 6 7 8 9 10 Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2] LIS [1, 1, 2, 2, 2, 3, 4, 1, 4, n] 10)Last item is 2, it will be inserted in the 2 nd position of M[]. So, the LIS[] value of 2 will be 2. M [-i, 1, 2, 4, 5, i, i, i, i, i, i] Index 0 1 2 3 4 5 6 7 8 9 10 Sequence [8, 1, 9, 8, 3, 4, 6, 1, 5, 2] LIS [1, 1, 2, 2, 2, 3, 4, 1, 4, 2] Now, see that completely process the values in M[] are in ascending order. And since we place a number in such a place where all the numbers in left are strictly less than the number so, the LIS[] value will be correct for all the numbers. One more thing, after all the iterations are over, don’t think that M[] will also contain a sequence. Because in the example above, see that 1, 2, 4, 5 is not the correct sequence. To get a sequence, since we already have the LIS[] values, we can use the reconstruction method. Now since the values in M[] will always be in ascending order, so, to find a position of a number we can definitely use binary search. So, if the final LIS length is k and there are n numbers then 10 . To insert a number using binary search the complexity will be O(logk). Thus the overall complexity will be O(nlogk), since we are inserting n items. 2/25/2019 10
  • 11. Have You Any Question?? Thank You 2/25/2019 11