Skip to content

Commit 4263dac

Browse files
Add time and space complexity information to various algorithms (#744)
* Add time and space complexity information to various algorithms * Added the implementation of Kosaraju algorithm * Added some style issues in articulationpoints.go * Formatted code with gofmt -s to meet style requirements --------- Co-authored-by: Rak Laptudirm <[email protected]>
1 parent 94689d8 commit 4263dac

File tree

114 files changed

+385
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+385
-72
lines changed

cache/lru.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// lru.go
2+
// description : Least Recently Used (LRU) cache
3+
// details : A Least Recently Used (LRU) cache is a type of cache algorithm used to manage memory within a computer. The LRU algorithm is designed to remove the least recently used items first when the cache reaches its limit.
4+
// time complexity : O(1)
5+
// space complexity : O(n)
6+
// ref : https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)
7+
18
package cache
29

310
import (

checksum/crc8.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// details:
44
// A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks
55
// and storage devices to detect accidental changes to raw data.
6+
// time complexity: O(n)
7+
// space complexity: O(1)
68
// See more [CRC](https://en.wikipedia.org/wiki/Cyclic_redundancy_check)
79
// author(s) [red_byte](https://github.com/i-redbyte)
810
// see crc8_test.go

checksum/luhn.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// lunh.go
22
// description: Luhn algorithm
33
// details: is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, etc [Lunh](https://en.wikipedia.org/wiki/Luhn_algorithm)
4+
// time complexity: O(n)
5+
// space complexity: O(1)
46
// author(s) [red_byte](https://github.com/i-redbyte)
57
// see lunh_test.go
68

cipher/caesar/caesar.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
// Package caesar is the shift cipher
2+
// description: Caesar cipher
3+
// details : Caesar cipher is a type of substitution cipher in which each letter in the plaintext is shifted a certain number of places down the alphabet.
4+
// time complexity: O(n)
5+
// space complexity: O(n)
26
// ref: https://en.wikipedia.org/wiki/Caesar_cipher
37
package caesar
48

cipher/diffiehellman/diffiehellmankeyexchange.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
// Package diffiehellman implements Diffie-Hellman Key Exchange Algorithm
2+
// description: Diffie-Hellman key exchange
3+
// details : Diffie-Hellman key exchange is a method of securely exchanging cryptographic keys over a public channel by combining private keys of two parties to generate a shared secret key.
4+
// time complexity: O(log(n))
5+
// space complexity: O(1)
26
// for more information watch : https://www.youtube.com/watch?v=NmM9HA2MQGI
37
package diffiehellman
48

cipher/polybius/polybius.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
// Package polybius is encrypting method with polybius square
2+
// description: Polybius square
3+
// details : The Polybius algorithm is a simple algorithm that is used to encode a message by converting each letter to a pair of numbers.
4+
// time complexity: O(n)
5+
// space complexity: O(n)
26
// ref: https://en.wikipedia.org/wiki/Polybius_square#Hybrid_Polybius_Playfair_Cipher
37
package polybius
48

cipher/railfence/railfence.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// railfence.go
2+
// description: Rail Fence Cipher
3+
// details: The rail fence cipher is a an encryption algorithm that uses a rail fence pattern to encode a message. it is a type of transposition cipher that rearranges the characters of the plaintext to form the ciphertext.
4+
// time complexity: O(n)
5+
// space complexity: O(n)
6+
// ref: https://en.wikipedia.org/wiki/Rail_fence_cipher
17
package railfence
28

39
import (

cipher/rot13/rot13.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
// Package rot13 is a simple letter substitution cipher that replaces a letter with the 13th letter after it in the alphabet.
2+
// description: ROT13
3+
// details: ROT13 is a simple letter substitution cipher that replaces a letter with the 13th letter after it in the alphabet. it is a special case of the Caesar cipher
4+
// time complexity: O(n)
5+
// space complexity: O(n)
26
// ref: https://en.wikipedia.org/wiki/ROT13
37
package rot13
48

cipher/rsa/rsa.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// thus both the Encrypt and Decrypt are not a production
77
// ready implementation. The OpenSSL implementation of RSA
88
// also adds a padding which is not present in this algorithm.
9+
// time complexity: O(n)
10+
// space complexity: O(n)
911
// author(s) [Taj](https://github.com/tjgurwara99)
1012
// see rsa_test.go
1113

cipher/rsa/rsa2.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
rsa2.go
33
description: RSA encryption and decryption including key generation
44
details: [RSA wiki](https://en.wikipedia.org/wiki/RSA_(cryptosystem))
5+
time complexity: O(n)
6+
space complexity: O(1)
57
author(s): [ddaniel27](https://github.com/ddaniel27)
68
*/
79
package rsa

0 commit comments

Comments
 (0)