Skip to content

Commit

Permalink
style: fix some eslint warnings (#240)
Browse files Browse the repository at this point in the history
* style: mark `stepSize` as `const`

* style: fix some `eslint` warnings
  • Loading branch information
vil02 authored May 25, 2024
1 parent 59984ee commit a08a122
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions graph/dijkstra.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MinHeap, PriorityQueue } from '../data_structures/heap/heap'
import { PriorityQueue } from '../data_structures/heap/heap'
/**
* @function dijkstra
* @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.
Expand Down Expand Up @@ -32,7 +32,7 @@ export const dijkstra = (
distances[start] = 0

while (priorityQueue.size() > 0) {
const [node, _] = priorityQueue.extract()
const node = priorityQueue.extract()[0]
graph[node].forEach(([child, weight]) => {
const new_distance = distances[node] + weight
if (new_distance < distances[child]) {
Expand Down
2 changes: 1 addition & 1 deletion search/jump_search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const jumpSearch = (array: number[], target: number): number => {
if (array.length === 0) return -1

// declare pointers for the current and next indexes and step size
const stepSize: number = Math.floor(Math.sqrt(array.length))
let currentIdx: number = 0,
stepSize: number = Math.floor(Math.sqrt(array.length)),
nextIdx: number = stepSize

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

0 comments on commit a08a122

Please sign in to comment.