Skip to content
This repository was archived by the owner on Dec 29, 2019. It is now read-only.

Added linear search in typescript. #144

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
409 changes: 409 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ Linear search is a very simple search algorithm. In this type of search, a seque
|20| [Marco Wang](https://github.com/aesophor) | University of Taipei | Taiwan | Java, C, Bash, Python-3 |
|21| [Grzegorz Wcisło](https://github.com/grzegorz-wcislo) | | Poland | |
|22| [Ivan Dyominov](https://github.com/dyominov) | | Ukraine | Scala |
|23| [Jacob Fjerbaek Olsen](https://github.com/fjerbaek) | Aarhus University | Denmark | SML (Standard ML) |
|23| [Yatheesan](https://github.com/Yatheesan) | | Sri Lanka | TypeScript |
|24| [Jacob Fjerbaek Olsen](https://github.com/fjerbaek) | Aarhus University | Denmark | SML (Standard ML) |

Binary file added typescript-linear-search/.DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions typescript-linear-search/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# typescript-linear-search
*Example Linear Search in Typescript*

7 changes: 7 additions & 0 deletions typescript-linear-search/exe-linear-search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var typescript_linear_search_1 = require("./typescript-linear-search");
var data = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var search = new typescript_linear_search_1.linearSearch();
var result = search.findValue(data, 4);
console.log(result);
8 changes: 8 additions & 0 deletions typescript-linear-search/exe-linear-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { linearSearch} from './typescript-linear-search';

var data = [1,2,3,4,5,6,7,8,9];

var search = new linearSearch();
var result = search.findValue(data,4);

console.log(result);
17 changes: 17 additions & 0 deletions typescript-linear-search/typescript-linear-search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var linearSearch = (function () {
function linearSearch() {
}
linearSearch.prototype.findValue = function (collection, find) {
var message = 'Value ' + find + ' not found';
collection.forEach(function (value) {
if (value === find) {
message = 'found value ' + find.toString() + ' in the collection at index of ' + collection.indexOf(find);
}
});
return message;
};
return linearSearch;
}());
exports.linearSearch = linearSearch;
13 changes: 13 additions & 0 deletions typescript-linear-search/typescript-linear-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export class linearSearch {

public findValue(collection: any[], find:any): string{
var message = 'Value '+ find +' not found';
collection.forEach(value => {
if (value === find){
message = 'found value ' + find.toString() + ' in the collection at index of ' + collection.indexOf(find);

}
});
return message;
}
}