-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from raj-rathod/rajesh
feat:<Divide and conquer> content add and structure setup
- Loading branch information
Showing
20 changed files
with
240 additions
and
12 deletions.
There are no files selected for viewing
Empty file.
1 change: 1 addition & 0 deletions
1
...lgorithms/divide-and-conquer/closest-pair-of-points/closest-pair-of-points.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>closest-pair-of-points works!</p> |
25 changes: 25 additions & 0 deletions
25
...rithms/divide-and-conquer/closest-pair-of-points/closest-pair-of-points.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ClosestPairOfPointsComponent } from './closest-pair-of-points.component'; | ||
|
||
describe('ClosestPairOfPointsComponent', () => { | ||
let component: ClosestPairOfPointsComponent; | ||
let fixture: ComponentFixture<ClosestPairOfPointsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ ClosestPairOfPointsComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ClosestPairOfPointsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
.../Algorithms/divide-and-conquer/closest-pair-of-points/closest-pair-of-points.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-closest-pair-of-points', | ||
templateUrl: './closest-pair-of-points.component.html', | ||
styleUrls: ['./closest-pair-of-points.component.css'] | ||
}) | ||
export class ClosestPairOfPointsComponent implements OnInit { | ||
|
||
constructor() { } | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
} |
16 changes: 15 additions & 1 deletion
16
...vide-and-conquer/divide-and-conquer-algorithm/divide-and-conquer-algorithm.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
<p class="text-center mt-5">Coming soon</p> | ||
<h1 class="text-center">Divide And Conquer algorithms</h1> | ||
<div class="mt-md-4 mt-3" [innerHtml]="divideAndConquerMetaData.defination"></div> | ||
<div class="mt-md-4 mt-3" [innerHtml]="divideAndConquerMetaData.terminologies"></div> | ||
<div class="mt-md-4 mt-3" [innerHtml]="divideAndConquerMetaData.algorithms"></div> | ||
<div class="mt-md-4 mt-3" [innerHtml]="divideAndConquerMetaData.timeComplexity"></div> | ||
<div class="mt-md-4 mt-3" [innerHtml]="divideAndConquerMetaData.comparison"></div> | ||
<div class="mt-md-4 mt-3" [innerHtml]="divideAndConquerMetaData.advantage"></div> | ||
<div class="mt-md-4 mt-3" [innerHtml]="divideAndConquerMetaData.disadvantage"></div> | ||
<div class="mt-md-4 mt-3 d-flex align-items-center horizontal-scroll"> | ||
<ng-container *ngFor="let data of divideAndConquerLinks; let i = index"> | ||
<div class="box p-lg-2 p-1 px-lg-3 px-2 tab me-lg-4 me-3" [routerLink]="data.route"> | ||
<p class="m-0">{{data.name}}</p> | ||
</div> | ||
</ng-container> | ||
</div> |
5 changes: 4 additions & 1 deletion
5
...divide-and-conquer/divide-and-conquer-algorithm/divide-and-conquer-algorithm.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/app/components/Algorithms/divide-and-conquer/divide-and-conquer-routing.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
1 change: 1 addition & 0 deletions
1
src/app/components/Algorithms/divide-and-conquer/karatsuba/karatsuba.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>karatsuba works!</p> |
25 changes: 25 additions & 0 deletions
25
src/app/components/Algorithms/divide-and-conquer/karatsuba/karatsuba.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { KaratsubaComponent } from './karatsuba.component'; | ||
|
||
describe('KaratsubaComponent', () => { | ||
let component: KaratsubaComponent; | ||
let fixture: ComponentFixture<KaratsubaComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ KaratsubaComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(KaratsubaComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
src/app/components/Algorithms/divide-and-conquer/karatsuba/karatsuba.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-karatsuba', | ||
templateUrl: './karatsuba.component.html', | ||
styleUrls: ['./karatsuba.component.css'] | ||
}) | ||
export class KaratsubaComponent implements OnInit { | ||
|
||
constructor() { } | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
} |
Empty file.
1 change: 1 addition & 0 deletions
1
src/app/components/Algorithms/divide-and-conquer/strassen/strassen.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>strassen works!</p> |
25 changes: 25 additions & 0 deletions
25
src/app/components/Algorithms/divide-and-conquer/strassen/strassen.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { StrassenComponent } from './strassen.component'; | ||
|
||
describe('StrassenComponent', () => { | ||
let component: StrassenComponent; | ||
let fixture: ComponentFixture<StrassenComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ StrassenComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(StrassenComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
src/app/components/Algorithms/divide-and-conquer/strassen/strassen.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-strassen', | ||
templateUrl: './strassen.component.html', | ||
styleUrls: ['./strassen.component.css'] | ||
}) | ||
export class StrassenComponent implements OnInit { | ||
|
||
constructor() { } | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Helper } from "src/app/helper/helper" | ||
|
||
const divideAndConquerData = { | ||
defination: "A divide and conquer algorithm is a strategy of solving a large problem by breaking the problem into smaller sub-problems, solving the sub-problems, and combining them to get the desired output.", | ||
terminologies:[ | ||
"<b>Divide</b>: This involves dividing the problem into smaller sub-problems", | ||
"<b>Conquer</b>: Solve sub-problems by calling recursively until solved", | ||
"<b>Combine</b>: Combine the sub-problems to get the final solution of the whole problem", | ||
], | ||
algorithms: [ | ||
"<b>Quicksort</b>: is a sorting algorithm. The algorithm picks a pivot element and rearranges the array elements so that all elements smaller than the picked pivot element move to the left side of the pivot, and all greater elements move to the right side. Finally, the algorithm recursively sorts the subarrays on the left and right of the pivot element", | ||
"<b>Merge Sort</b>: is also a sorting algorithm. The algorithm divides the array into two halves, recursively sorts them, and finally merges the two sorted halves", | ||
"<b>Closest Pair of Points</b>: The problem is to find the closest pair of points in a set of points in the x-y plane. The problem can be solved in O(n^2) time by calculating the distances of every pair of points and comparing the distances to find the minimum. The Divide and Conquer algorithm solves the problem in O(N log N) time", | ||
"<b>Strassen’s Algorithm</b>: is an efficient algorithm to multiply two matrices. A simple method to multiply two matrices needs 3 nested loops and is O(n^3). Strassen’s algorithm multiplies two matrices in O(n^2.8974) time", | ||
"<b>Karatsuba algorithm</b>: is a fast multiplication algorithm that uses a divide and conquer approach to multiply two numbers", | ||
], | ||
comparison:"Both paradigms (D & C and DP) divide the given problem into subproblems and solve subproblems. How do choose one of them for a given problem? Divide and Conquer should be used when the same subproblems are not evaluated many times. Otherwise Dynamic Programming or Memoization should be used. For example, Quicksort is a Divide and Conquer algorithm, we never evaluate the same subproblems again. On the other hand, for calculating the nth Fibonacci number, Dynamic Programming should be preferred", | ||
timeComplexity:"T(n) = aT(n/b) + f(n),<br><br> where, <br>     n = size of input<br>    a = number of subproblems in the recursion<br>   n/b = size of each subproblem. All subproblems are assumed to have the same size.<br>   f(n) = cost of the work done outside the recursive call, which includes the cost of dividing the problem and cost of merging the solutions<br>", | ||
advantage:[ | ||
"The difficult problem can be solved easily", | ||
"It divides the entire problem into subproblems thus it can be solved parallelly ensuring multiprocessing", | ||
"Efficiently uses cache memory without occupying much space", | ||
"Reduces time complexity of the problem" | ||
], | ||
disadvantage:[ | ||
"It involves recursion which is sometimes slow", | ||
"Efficiency depends on the implementation of logic", | ||
"It may crash the system if the recursion is performed rigorously" | ||
] | ||
} | ||
|
||
export const divideAndConquerMetaData = { | ||
defination: Helper.setHeader(divideAndConquerData.defination), | ||
terminologies: Helper.setListwithTitleHtml("Terminologies", divideAndConquerData.terminologies), | ||
algorithms: Helper.setListwithTitleHtml("Some Standard Algorithms", divideAndConquerData.algorithms), | ||
timeComplexity: Helper.setTitleDescription("Time Complexity of Divide and Conquer Algorithm", divideAndConquerData.timeComplexity), | ||
comparison: Helper.setTitleDescription("Divide and Conquer (D & C) vs Dynamic Programming (DP)", divideAndConquerData.comparison), | ||
advantage: Helper.setListwithTitleHtml("Advantages", divideAndConquerData.advantage), | ||
disadvantage: Helper.setListwithTitleHtml("Disadvantages", divideAndConquerData.disadvantage) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters