feature/OneMoreSorting #9

Merged
lobo merged 2 commits from feature/OneMoreSorting into main 2026-02-04 15:34:18 +01:00
Showing only changes of commit e1680426ad - Show all commits

View File

@@ -6,8 +6,6 @@ import {SortData, SortSnapshot} from '../sorting.models';
})
export class SortingService {
constructor() { }
private createSnapshot(array: SortData[]): SortSnapshot {
return {
array: array.map(item => ({ ...item }))
@@ -25,7 +23,7 @@ export class SortingService {
for (let j = 0; j < n - i - 1; j++) {
arr[j].state = 'comparing';
arr[j + 1].state = 'comparing';
snapshots.push(this.createSnapshot(arr)); // Snapshot Vergleich
snapshots.push(this.createSnapshot(arr));
if (arr[j].value > arr[j + 1].value) {
const temp = arr[j].value;
@@ -76,7 +74,7 @@ export class SortingService {
private partition(arr: SortData[], low: number, high: number, snapshots: SortSnapshot[]): number {
const pivot = arr[high];
arr[high].state = 'comparing'; // Pivot visualisieren
arr[high].state = 'comparing';
snapshots.push(this.createSnapshot(arr));
let i = (low - 1);
@@ -149,7 +147,6 @@ export class SortingService {
arr[largest].state = 'unsorted';
}
// Vergleich Rechts
if (r < n) {
arr[r].state = 'comparing';
arr[largest].state = 'comparing';