0.5.66 • Published 10 months ago

actslib v0.5.66

Weekly downloads
131
License
MIT
Repository
github
Last release
10 months ago

Build Status

TypeScript Library for Data Structure, Algorithms and Utilities

INTRODUCTION

This project is target to build a library (abbrv: lib) for Data Structures, algorithms and Utilities.

  • The Data Structure part, including List, Tree, Graph, and others.
  • The Algorithm part, including sorting, searching and others.
  • The Utility part, including finance methods, string utility, number utility, HTML element related methods, etc.

The library written with TypeScript.

HOW TO USE

To use this library in your package, simply run following NPM command:

npm install actslib --save

to add this library into your own topic.

Code snippet 1: calculate the FV (further value) with interest rate 1% and 12 periods:

import { FinanceMethods } from 'actslib';

const rst = FinanceMethods.FV(100, 0.01, 12);
expect(rst).toEqual(112.68); // FV is 112.68

Code snippet 2: show the way to use the Matrix:

import { Matrix, MatrixPosIntf } from 'actslib';

let matrix: Matrix = new Matrix(10, 10);
let arpos = matrix.getSlashOutputPos();

Code snippet 3: show the way to use the Quick-Sorting algorithm:

import { QuickSort } from 'actslib';

let arArray: number[] = [10, 3, 26, 1, 35];
QuickSort(arArray);

REFERENCE

The library in the project actually based the understanding when learning the books below:

  • Introduction to Algorithms, Third Edition, by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein
  • Programming Pearls, by Jon Bentley
  • More Programming Pearls, By Jon Benley
  • 数据结构 用面向对象方法与C++描述, Tsinghua University Press
  • 编程之美, Publishing House of Electronics Industry
  • More to come.

CONTENT

Folder lib (src\lib) contains the kernel part of the whole library. It consists with several sub folders, and it has been exported via index.ts respectively. Folder dist (dist) contains the compiled js files.

UNIT TESTS

Unit test is the mechanism to ensure the quality. It was supported by using Karam.

Run 'npm test' to trigger the unit tests.

HOW TO DEBUG UNIT TESTS

There ar two steps away to debug unit tests in VS Code.

  • Step 1. Start the Karma Runner via the command below
npm run debugtest
  • Step 2. In VS Code, click 'Debug Unit Tests'. VS Code now attach to the Chrome window and debugging is waiting.

DEMO APP

Demo app was located in another repository.

Try the demo app online now via a single click.

DATA STRUCTURE

LIST

Interface IList defines the generic operations supported by List.

  • Class SequenceList implements the Sequence List.
  • Class LinkList implements the Link List.
  • Class StaticLinkList implements the static link list.

STACK AND QUEUE

Interface IStack and IQueue defines the generic operations for Stack and Queue respectively.

  • Class SequenceStack implements the Sequence Stack.
  • Class LinkStack implements the Link Stack.

TREE

Interface ITree defines the generic operations and attributes supported by Tree.

Interface IBinaryTree define the generic operations and attributes for Binary Tree.

  • Class BinaryTree implements the Binary Tree.
  • Class BinarySearchTree implements the Binary Search Tree.
  • Class BinaryThreadTree implements the Binary Thread Tree.
  • More to come.

GRAPH

Interface IGraph defines the generic operations and attributes supported by Graph, such as DFS, BFS, and so on.

Interface IGraphVertex defines the interface for Vertex in the graph.

Interface IGraphEdge defines the interface for the Edge in the graph.

  • Class Graph defines the implementation for the Graph with Adjace Matrix.
  • Class GraphAdjaceList defines the implementation for the Graph with Adjact List.
  • More to come.

ALGORITHM

  • The algorithm KMP which offer the functionality to search source string from the target string.
  • The algorithm InsertionSort using the insertion sort upon the array.
  • The algorithm BinaryInsertSort based on InsertionSort but improves the way to search for suitable position to insert.
  • The algorithm BubbleSort using the bubble-sort on the array: pickup the biggest and move it to the tail of the array.
  • The algorithm QuickSort based on BubbleSort but use recursive way to handle two parts of the array.
  • The algorithm SelectionSort choose the min (or max) from the unsorted part and append it to the sorted part.
  • The algorithm CountingSort give an item a n-th position because there are n-1 item less (or bigger) than it. This algorithm suits only for number based array.
  • The algorithm MergeSort uses divide and consquer methology which try to split the arry and merge it to final results.
  • The algorithm HeapSort try to build maximum (or minimum) heap for the unsorted part, and fetch the root node to the sorted part.
  • More to come.

SUBJECT

  • The subject MaximumSubArray try to fetch out the maxium sub array from an existing array.
  • The subject PriorityQueue try to define a priority queue which can be simulated the real scenario.
  • The subject Matrix defines the matrix object.
  • The subject Polynomial defines the polynomial object.
  • The subject SparseMatrix defines the Sparse Matrix object.
  • The subject ChineseChessGeneralsProblem provides several solutions to the Generals issue in Chinese Chess.
  • The subject PanCakeSort provides the solution to sort the pan cakes.
  • The subject Formula provides the Math Expression Parser.
  • The subject RPN provides the support of Reverse Polish Notation.
  • The subject FinanceMethods provides the support of methods used in Finance area, including Further Value, Present Value, FV of Annity, etc.
  • More to come.

UTILITIES

  • The utility DateUtility provides some helpful methods on Date part, including days between, serialize/deserialize with string, etc.
  • The uitlity UIUtility provides some helpful methods operation on HTML element, including add/remove CSS classes, etc.
  • The uitlity StringUtility provides some helpful methods operation on strings, including check password length, check duplications, etc.
  • The uitlity NumberUtility provides some helpful methods operation on numbers, including adding prefixes, rounding with specified digitals, etc.

PROGRESS

The progress of the project shown in the table below.

#ContentStatusUT StatusComment
1SequenceListFinishedPassedQuestion left: search?
2LinkListFinishedPassedQuestion left: search?
3SequenceStackIn ProcessPassedQuestion left: search?
4MatrixFinishedPassedQuestion left: search?
5SetFinished2 Cases failedQuestion left: search?
6SequenceQueueFinishedPassedQuestion left: search?
7PriorityQueueFinishedPassedQuestion left: search?
8DictionaryFinishedPassedQuestion left: search?
10GraphIn ProcessIn ProcessQuestion left: how to demonstrate the Graph for demo?
11Graph with Adjace ListIn ProcessIn ProcessQuestion left: how to demonstrate the Graph for demo?
12Binary Search Treen/an/aNot started yet
13B Treen/an/aNot started yet
14Red Black Treen/an/aNot started yet
15Strassen Algorithmn/an/aNot started yet
16Birthday Theoryn/an/aNot started yet
17Ball and Boxn/an/aNot started yet
18Hire on-linen/an/aNot started yet
19Priority Queuen/an/aNot started yet
20Hash algorithmsn/an/aNot started yet
21van Emde Boas Treen/an/aNot started yet
22Kruskal Algorithmn/an/aNot started yet
23Prim Algorithmn/an/aNot started yet
24Bellman-Ford Algorithmn/an/aNot started yet
25Dijkstra Algorithmn/an/aNot started yet
26Floyd-Warshall Algorithmn/an/aNot started yet
27Radix sortn/an/aNot started yet
28Bucket sortn/an/aNot started yet
40FormulaDONEDONEFormula.evaluate can be used to workout the figures
41Finance MethodsIn Processn/aFV, FVIF, PV, PVIF, FV of ordinary annity; FV of deferred annity; FV of annity in advance; n/a

CONTRIBUTORS

  • Alva Chien(Hongjun Qian) | 钱红俊 Contact me via Mailbox: alvachien@163.com if necessary;
  • Lily Yao

Licence

MIT

0.5.66

10 months ago

0.5.60

10 months ago

0.5.55

2 years ago

0.4.29

3 years ago

0.4.28

3 years ago

0.4.27

3 years ago

0.4.26

3 years ago

0.4.25

3 years ago

0.4.24

3 years ago

0.4.23

3 years ago

0.4.22

3 years ago

0.4.20

3 years ago

0.4.17

3 years ago

0.4.15

3 years ago

0.4.13

4 years ago

0.4.12

4 years ago

0.4.10

4 years ago

0.4.11

4 years ago

0.4.7

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago