Skip to content

Commit c80bfef

Browse files
committed
feat:<Exponential Search> exponential search content add
1 parent 4f1ca30 commit c80bfef

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
<h1 class="text-center">Coming soon</h1>
1+
<h1 class="text-center">Exponential Search Algorithm</h1>
2+
<div class="mt-md-4 mt-3" [innerHtml]="exponentialSearchMetaData.defination"></div>
3+
<div class="mt-md-4 mt-3" [innerHtml]="exponentialSearchMetaData.explainImage"></div>
4+
<div class="mt-md-4 mt-3" [innerHtml]="exponentialSearchMetaData.properties"></div>
5+
<div class="mt-md-4 mt-3" [innerHtml]="exponentialSearchMetaData.flowChart"></div>
6+
<div class="mt-md-4 mt-3" [innerHtml]="exponentialSearchMetaData.workingProcedure"></div>
7+
<div class="mt-md-4 mt-3" [innerHtml]="exponentialSearchMetaData.applications"></div>
8+
<div class="mt-md-4 mt-3" [innerHtml]="exponentialSearchMetaData.other"></div>
9+
<div class="mt-md-4 mt-3" [innerHtml]="exponentialSearchMetaData.advantage"></div>
10+
<div class="mt-md-4 mt-3" [innerHtml]="exponentialSearchMetaData.disadvantage"></div>

src/app/components/Algorithms/searching/exponential-search/exponential-search.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { exponentialSearchMetaData } from 'src/app/core/algorithms/searching-meta-data';
23

34
@Component({
45
selector: 'app-exponential-search',
56
templateUrl: './exponential-search.component.html',
67
styleUrls: ['./exponential-search.component.css']
78
})
89
export class ExponentialSearchComponent implements OnInit {
9-
10+
exponentialSearchMetaData = exponentialSearchMetaData;
1011
constructor() { }
1112

1213
ngOnInit(): void {

src/app/core/algorithms/searching-meta-data.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,61 @@ export const interpolationSearchMetaData : Algorithms = {
264264

265265
// ----------------------------------- End ----------------------------------------------//
266266

267+
// -------------------------------- Exponential Search ------------------------------------//
268+
269+
const exponentialSearchData = {
270+
defination:`Exponential search allows for searching through a sorted, unbounded list for a specified input value
271+
(the search "key"). The algorithm consists of two stages. The first stage determines a range in which the search
272+
key would reside if it were in the list. In the second stage, a binary search is performed on this range. In the first stage,
273+
assuming that the list is sorted in ascending order, the algorithm looks for the first exponent, j, where the value 2^j is greater
274+
than the search key. This value, 2^j becomes the upper bound for the binary search with the previous power of 2, 2^(j - 1), being the
275+
lower bound for the binary search`,
276+
flowChart: 'assets/ds-image/DSA-404.webp',
277+
explainImage: 'assets/ds-image/DSA-404.webp',
278+
properties: [
279+
`Finding the range in which the key could sit`,
280+
`Applying binary search in this range`,
281+
`Exponential search algorithm (also called doubling search, galloping search, Struzik search) is a search algorithm,
282+
created by Jon Bentley and Andrew Chi-Chih Yao in 1976, for searching sorted, unbounded/infinite lists`
283+
],
284+
workingProcedure: [
285+
`Start with value i=1`,
286+
`Check for a condition i < n and Array[i]<=key, where n is the number of items in the array and key is the element being sought`,
287+
`Increment value of I in powers of 2, that is, i=i*2`,
288+
`Keep on incrementing the value of 'i' until the condition is met`,
289+
`Apply binary on the range i/2 to the end of Array - binarySearch(Array, i/2, min(i,n-1))`
290+
],
291+
applications: [
292+
`Exponential Binary Search is useful for unbounded searches where size of array is infinite`,
293+
`It works better than Binary Search for bounded arrays when the element to be searched is closer to the beginning of the array.`
294+
],
295+
advantages: [
296+
`Exponential Binary Search is useful for unbounded searches where size of array is infinite`,
297+
],
298+
disadvantages: [
299+
`The list should be sorted to perform the exponential search, if the list is unsorted, it will give wrong results`
300+
],
301+
performance: [
302+
`Worst case time complexity: O(log i) where i is the index of the element being searched`,
303+
`Average case time complexity: O(log i)`,
304+
`Best case time complexity: O(1)`,
305+
`Space complexity: O(1)`
306+
]
307+
308+
};
309+
310+
export const exponentialSearchMetaData: Algorithms = {
311+
defination: Helper.setHeader(exponentialSearchData.defination),
312+
properties: Helper.setListwithTitleHtml('Properties of Exponential Search', exponentialSearchData.properties),
313+
explainImage: Helper.setExampleImage('Exponential Search Image', exponentialSearchData.explainImage),
314+
flowChart: Helper.setExampleImage('Flowchart of Exponential Search', exponentialSearchData.flowChart),
315+
advantage: Helper.setListwithTitleHtml('Advantages of Exponential Search', exponentialSearchData.advantages),
316+
disadvantage: Helper.setListwithTitleHtml('Disadvantages of Exponential Search', exponentialSearchData.disadvantages),
317+
applications: Helper.setListwithTitleHtml('Applications of Exponential Search', exponentialSearchData.applications),
318+
other: Helper.setListwithTitleHtml('Performance of Exponential Search', exponentialSearchData.performance),
319+
workingProcedure: Helper.setListwithTitleHtml('Follow the below steps to solve the problem', exponentialSearchData.workingProcedure),
320+
}
321+
322+
// ----------------------------------- End ----------------------------------------------//
323+
267324

0 commit comments

Comments
 (0)