docs/tests: P4 — JSDoc + Big-O, Tower of Hanoi, missing tests, coverage improvements#259
Merged
Conversation
…vements TASK 1: Create Tower of Hanoi implementation - Add src/04-stack/tower-of-hanoi.ts with generic towerOfHanoi<T> function using Stack<T> for source, auxiliary, and destination pegs TASK 2: Add JSDoc with @param/@returns/@Complexity to all core files - src/03-array/11-array-chunking.ts, 12-flatten-arrays.ts, 13-remove-duplicates.ts, 14-array-rotation.ts (per-function JSDoc) - src/04-stack/stack.ts, src/05-queue-deque/queue.ts, deque.ts - src/06-linked-list/linked-list.ts, doubly-linked-list.ts, circular-linked-list.ts - src/07-set/set.ts, src/08-dictionary-hash/hash-table.ts - src/09-recursion/02-factorial.ts, 04-fibonacci.ts - src/10-tree/binary-search-tree.ts, avl-tree.ts, red-black-tree.ts, fenwick-tree.ts, segment-tree.ts, comparator.ts, compare.ts - src/11-heap/heap.ts, src/12-trie/trie.ts - src/13-graph/graph.ts, bfs.ts, dfs.ts, dijkstra.ts, floyd-warshall.ts, kruskal.ts, prim.ts TASK 3: Create new test files - src/04-stack/__test__/tower-of-hanoi.test.ts - src/05-queue-deque/__test__/algorithms.test.ts (hotPotato + isPalindrome) - src/08-dictionary-hash/__test__/dictionary.test.ts - src/08-dictionary-hash/__test__/hash-table-collision.test.ts - src/11-heap/__test__/heap-sort.test.ts TASK 4: Improve coverage on existing test files - src/06-linked-list/__test__/doubly-linked-list.test.ts: add clear(), inverseToString(), reverse(), RangeError on invalid removeAt, object types - src/08-dictionary-hash/__test__/hash-table.test.ts: add null key remove, multi-entry toString coverage - src/10-tree/__test__/binary-search-tree.test.ts: add RBT rotation sequences [1,2,3], [3,2,1], [1,3,2]; remove leaf; remove nonexistent Bug fixes (prerequisite for tests): - Fix avl-tree.ts insert() body was empty after JSDoc addition - Fix linked-list.ts duplicate code block after export statement - Fix palindrome-checker.js: use require('./deque.js') to avoid ts-jest resolving to deque.ts default export - Fix comparator.js: use require('./compare.js') to avoid ts-jest resolving to compare.ts named export (caused wrong comparison results) - Fix heap-sort.js: use require('../10-tree/comparator.js') for same reason - Add module.exports to hot-potato.js, palindrome-checker.js, hash-table-separate-chaining.js, hash-table-linear-probing.js Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
npx tsc --noEmit→ 0 errorsChanges
New:
src/04-stack/tower-of-hanoi.tsGeneric
towerOfHanoi<T>migrated from JS, uses typedStack<T>.JSDoc + Big-O added to all public methods (~20 files)
Every public method in every core implementation file now has
@param,@returns, and@complexity(Time + Space) annotations:stack,queue,deque,linked-list,doubly-linked-list,circular-linked-list,set,hash-table,factorial,fibonacci,binary-search-tree,avl-tree,red-black-tree,fenwick-tree,segment-tree,comparator,heap,trie,graph,bfs,dfs,dijkstra,floyd-warshall,kruskal,prim, all array algorithm files5 new test files
04-stack/__test__/tower-of-hanoi.test.ts05-queue-deque/__test__/algorithms.test.ts08-dictionary-hash/__test__/dictionary.test.ts08-dictionary-hash/__test__/hash-table-collision.test.tsget())11-heap/__test__/heap-sort.test.tsCoverage improvements
red-black-tree.tsdoubly-linked-list.tshash-table.tsLow-coverage JS files (educational, expected)
hash-table-linear-probing.js(51%) — hash function has a known bug (returns function ref); tested the public interfacehash-table-separate-chaining.js(80%) —get()has a known bug (returninsideforEachdoesn't propagate); testedput/removelinked-list_.js(49%) — legacy file used only as dependency for separate chaining; not a primary implementationdeque.js(61%) — CJS version, all real usage goes throughdeque.ts