forked from Hithomelabs/DSA_sheets
making image sizes small
This commit is contained in:
parent
7a54eca48c
commit
a776ef2d68
@ -16,7 +16,7 @@
|
|||||||
- We can imagine a scenario where, where at any intermediate stage,
|
- We can imagine a scenario where, where at any intermediate stage,
|
||||||
our input array is divided into three parts, the first part carries all unique numbers in ascending order, the second part contains the repeated numbers and the third part contains numbers that haven't been processed yet. For 3 sections we need 2 pointers to act as dividers.
|
our input array is divided into three parts, the first part carries all unique numbers in ascending order, the second part contains the repeated numbers and the third part contains numbers that haven't been processed yet. For 3 sections we need 2 pointers to act as dividers.
|
||||||
|
|
||||||
<p align="center"><img src="images/sections.png" width="80%" /></p>
|
<p align="center"><img src="images/sections.png" width="50%" /></p>
|
||||||
|
|
||||||
- Let's start with 2 pointers, initially all at index 0,
|
- Let's start with 2 pointers, initially all at index 0,
|
||||||
1. The unique pointer at 0, the left of which exist all unique numbers.
|
1. The unique pointer at 0, the left of which exist all unique numbers.
|
||||||
@ -24,14 +24,14 @@ our input array is divided into three parts, the first part carries all unique n
|
|||||||
|
|
||||||
- In order to process a colony the bounds of a colony must be known, we need to spawn a look-ahead pointer from the seek pointer that moves right to the last number of that colony, to determine the bounds of the colony.
|
- In order to process a colony the bounds of a colony must be known, we need to spawn a look-ahead pointer from the seek pointer that moves right to the last number of that colony, to determine the bounds of the colony.
|
||||||
|
|
||||||
<p align="center"><img src="images/initial pointer positions.png" width="80%" /></p>
|
<p align="center"><img src="images/initial pointer positions.png" width="50%" /></p>
|
||||||
|
|
||||||
- When processing a number colony, the first element moves to the unique section, the rest, if any move to the repeated section and then a new number colony is processed.
|
- When processing a number colony, the first element moves to the unique section, the rest, if any move to the repeated section and then a new number colony is processed.
|
||||||
|
|
||||||
- When every colony is processed, atleast one unique element is addded, we swap the seek pointer value with the unique pointer value. The seek pointer always points to a new un-processed number and the unique pointer always points to the first number of the repeated section.
|
- When every colony is processed, atleast one unique element is addded, we swap the seek pointer value with the unique pointer value. The seek pointer always points to a new un-processed number and the unique pointer always points to the first number of the repeated section.
|
||||||
|
|
||||||
<p align="center"><img src="images/processing_a_number colony.png" width="80%" /></p>
|
<p align="center"><img src="images/processing_a_number colony.png" width="50%" /></p>
|
||||||
|
|
||||||
- We have now added a value to the unique section thus we need to increment the unique pointer, the number at the seek pointer is a repeated value and hence the seek pointer must also be incremented, to the value next to the limit pointer, to the start of a new nunmber colony until, the end of the array is reached.
|
- We have now added a value to the unique section thus we need to increment the unique pointer, the number at the seek pointer is a repeated value and hence the seek pointer must also be incremented, to the value next to the limit pointer, to the start of a new nunmber colony until, the end of the array is reached.
|
||||||
|
|
||||||
<p align="center"><img src="images/final stage.png" width="80%" /></p>
|
<p align="center"><img src="images/final stage.png" width="50%" /></p>
|
||||||
|
Loading…
Reference in New Issue
Block a user