Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 0

Check:

The first round checks if any number in the list is equal to [i] (12).

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 0

Check:

j equals i, therefore we skip.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 1

Check:

Are the values at positions [j] and [i] equal?

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 1

Check:

No, so next.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 2

Check:

No, so next.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 2

Check:

Are the values at positions [j] and [i] equal?

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 2

Check:

No, so next.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 3

Check:

No, so next.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 3

Check:

Are the values at positions [j] and [i] equal?

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 3

Check:

No, so next.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 4

Check:

No, so next.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 4

Check:

Are the values at positions [j] and [i] equal?

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 4

Check:

No, so next, but the loop is ended.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 0

j = 4

Check:

The while loop for j is ended, so that i will be increased for the next i while loop

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 4

Check:

The while loop for j is ended, so that i will be increased for the next i while loop

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 4

Check:

And while loop j will be in a complete new loop

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 0

Check:

And while loop j will be in a complete new loop

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 0

Check:

New round will start to find the duplicated element for the [i] (15).

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 0

Check:

Are the values at positions [j] and [i] equal?

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 0

Check:

No, so next.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 1

Check:

No, so next.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 1

Check:

j equals i, therefore we skip.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 2

Check:

j equals i, therefore we skip.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 2

Check:

Are the values at positions [j] and [i] equal?

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 2

Check:

No, so next.

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

Check:

No, so next.

j = 3

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 3

Check:

Are the values at positions [j] and [i] equal?

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 3

Check:

Yes, we found it!

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 3

Check:

Print the 15 value!

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

j = 3

Check:

Break the j while loop

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

i = 1

Check:

And break the i while loop

Python List - Ex02

0

12

[

]

2

18

4

20

1

15

3

15

dna_segments

Check:

Program ended

F4 Lesson08 - List 07 (Ex02) Tutorial Animation

By Mr Peter

F4 Lesson08 - List 07 (Ex02) Tutorial Animation

  • 19