Skip to content

Commit a08a122

Browse files
authored
style: fix some eslint warnings (#240)
* style: mark `stepSize` as `const` * style: fix some `eslint` warnings
1 parent 59984ee commit a08a122

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

graph/dijkstra.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MinHeap, PriorityQueue } from '../data_structures/heap/heap'
1+
import { PriorityQueue } from '../data_structures/heap/heap'
22
/**
33
* @function dijkstra
44
* @description Compute the shortest path from a source node to all other nodes. The input graph is in adjacency list form. It is a multidimensional array of edges. graph[i] holds the edges for the i'th node. Each edge is a 2-tuple where the 0'th item is the destination node, and the 1'th item is the edge weight.
@@ -32,7 +32,7 @@ export const dijkstra = (
3232
distances[start] = 0
3333

3434
while (priorityQueue.size() > 0) {
35-
const [node, _] = priorityQueue.extract()
35+
const node = priorityQueue.extract()[0]
3636
graph[node].forEach(([child, weight]) => {
3737
const new_distance = distances[node] + weight
3838
if (new_distance < distances[child]) {

search/jump_search.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export const jumpSearch = (array: number[], target: number): number => {
2222
if (array.length === 0) return -1
2323

2424
// declare pointers for the current and next indexes and step size
25+
const stepSize: number = Math.floor(Math.sqrt(array.length))
2526
let currentIdx: number = 0,
26-
stepSize: number = Math.floor(Math.sqrt(array.length)),
2727
nextIdx: number = stepSize
2828

2929
while (array[nextIdx - 1] < target) {

0 commit comments

Comments
 (0)