Top Related Projects
All Algorithms implemented in Python
Minimal examples of data structures and algorithms in Python
📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
120+ interactive Python coding interview challenges (algorithms and data structures). Includes Anki flashcards.
A complete computer science study plan to become a software engineer.
💯 Curated coding interview preparation materials for busy software engineers
Quick Overview
This GitHub repository contains implementations of various data structures and algorithms in Python. It serves as a resource for learning and practicing fundamental computer science concepts, offering a collection of well-documented code examples for common data structures and algorithms.
Pros
- Comprehensive collection of data structures and algorithms
- Clear and well-documented Python implementations
- Useful for interview preparation and learning computer science concepts
- Includes both basic and advanced topics
Cons
- Limited language support (primarily Python)
- Some implementations may not be optimized for production use
- Lacks extensive test coverage
- May not cover all edge cases for each algorithm
Code Examples
Here are a few code examples from the repository:
- Binary Search implementation:
def binary_search(arr, target):
left, right = 0, len(arr) - 1
while left <= right:
mid = (left + right) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1
- Bubble Sort implementation:
def bubble_sort(arr):
n = len(arr)
for i in range(n):
for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
return arr
- Linked List implementation:
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def append(self, data):
new_node = Node(data)
if not self.head:
self.head = new_node
return
current = self.head
while current.next:
current = current.next
current.next = new_node
Getting Started
To use the implementations in this repository:
-
Clone the repository:
git clone https://github.com/ua-nick/Data-Structures-and-Algorithms.git
-
Navigate to the desired algorithm or data structure file.
-
Import the implementation in your Python script:
from binary_search import binary_search arr = [1, 3, 5, 7, 9] result = binary_search(arr, 5) print(f"Element found at index: {result}")
-
Run your script to use the implemented algorithm or data structure.
Competitor Comparisons
All Algorithms implemented in Python
Pros of Python
- Larger community and more contributors, leading to a wider variety of algorithms and implementations
- Better organization with categorized folders for different types of algorithms
- More comprehensive documentation and explanations for each algorithm
Cons of Python
- May be overwhelming for beginners due to the large number of algorithms
- Some implementations might be more complex or less optimized than necessary for learning purposes
Code Comparison
Data-Structures-and-Algorithms (Binary Search):
def binary_search(arr, x):
low = 0
high = len(arr) - 1
while low <= high:
mid = (low + high) // 2
if arr[mid] == x:
return mid
elif arr[mid] < x:
low = mid + 1
else:
high = mid - 1
return -1
Python (Binary Search):
def binary_search(array, target):
left, right = 0, len(array) - 1
while left <= right:
mid = (left + right) // 2
if array[mid] == target:
return mid
if array[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1
Both implementations are similar in approach and efficiency, with minor differences in variable naming and style.
Minimal examples of data structures and algorithms in Python
Pros of algorithms
- More comprehensive coverage of algorithms and data structures
- Better organized with clear categorization of topics
- Includes implementations in multiple programming languages
Cons of algorithms
- Less focus on detailed explanations and theory
- May be overwhelming for beginners due to the large number of algorithms
Code Comparison
Data-Structures-and-Algorithms (Python):
def binary_search(arr, x):
low = 0
high = len(arr) - 1
while low <= high:
mid = (low + high) // 2
if arr[mid] == x:
return mid
elif arr[mid] < x:
low = mid + 1
else:
high = mid - 1
return -1
algorithms (Python):
def binary_search(array, target):
lower = 0
upper = len(array)
while lower < upper:
x = lower + (upper - lower) // 2
val = array[x]
if target == val:
return x
elif target > val:
if lower == x:
break
lower = x
elif target < val:
upper = x
return -1
Both implementations showcase a binary search algorithm, but the algorithms repository version includes additional optimizations and edge case handling.
📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
Pros of javascript-algorithms
- More comprehensive coverage of algorithms and data structures
- Better documentation and explanations for each implementation
- Includes Big O notation analysis for algorithms
Cons of javascript-algorithms
- Larger repository size, potentially overwhelming for beginners
- Less focus on practical applications and real-world examples
Code Comparison
Data-Structures-and-Algorithms:
class Node {
constructor(data, next = null) {
this.data = data;
this.next = next;
}
}
javascript-algorithms:
export default class LinkedListNode {
constructor(value, next = null) {
this.value = value;
this.next = next;
}
toString(callback) {
return callback ? callback(this.value) : `${this.value}`;
}
}
The javascript-algorithms implementation includes a toString
method for easier debugging and customization, while Data-Structures-and-Algorithms keeps the implementation simpler.
javascript-algorithms provides a more extensive collection of algorithms and data structures with detailed explanations, making it suitable for in-depth study. However, its size might be overwhelming for beginners. Data-Structures-and-Algorithms offers a more concise approach, potentially easier for newcomers to grasp, but with less comprehensive coverage.
120+ interactive Python coding interview challenges (algorithms and data structures). Includes Anki flashcards.
Pros of Interactive-Coding-Challenges
- More comprehensive coverage of topics, including system design and object-oriented design
- Includes interactive Jupyter notebooks for hands-on learning
- Well-structured with clear categorization of problems and solutions
Cons of Interactive-Coding-Challenges
- Less focused on pure algorithmic problems compared to Data-Structures-and-Algorithms
- May be overwhelming for beginners due to its extensive content
- Requires additional setup for Jupyter notebooks
Code Comparison
Data-Structures-and-Algorithms (Python implementation of Quick Sort):
def quickSort(arr, low, high):
if low < high:
pi = partition(arr, low, high)
quickSort(arr, low, pi-1)
quickSort(arr, pi+1, high)
Interactive-Coding-Challenges (Python implementation of Quick Sort):
class QuickSort(object):
def sort(self, data):
if data is None:
raise TypeError('data cannot be None')
return self._sort(data)
def _sort(self, data):
if len(data) < 2:
return data
equal = [x for x in data if x == data[0]]
left = [x for x in data if x < data[0]]
right = [x for x in data if x > data[0]]
return self._sort(left) + equal + self._sort(right)
The Interactive-Coding-Challenges implementation provides a more object-oriented approach with additional error handling, while Data-Structures-and-Algorithms offers a more traditional recursive implementation.
A complete computer science study plan to become a software engineer.
Pros of coding-interview-university
- Comprehensive curriculum covering a wide range of computer science topics
- Well-structured learning path with clear progression
- Extensive list of resources, including books, videos, and practice problems
Cons of coding-interview-university
- May be overwhelming for beginners due to its extensive content
- Lacks hands-on coding examples and implementations
- Primarily focused on theoretical knowledge rather than practical application
Code comparison
Data-Structures-and-Algorithms provides practical implementations, while coding-interview-university focuses on theoretical concepts. Here's a brief comparison:
Data-Structures-and-Algorithms:
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
coding-interview-university: No direct code implementations are provided. Instead, it offers links to external resources for learning and practice.
Summary
Data-Structures-and-Algorithms offers practical implementations of various algorithms and data structures, making it suitable for hands-on learning. coding-interview-university provides a comprehensive curriculum covering a wide range of computer science topics, making it ideal for thorough preparation for technical interviews. While Data-Structures-and-Algorithms focuses on code implementation, coding-interview-university emphasizes theoretical knowledge and provides extensive resources for self-study.
💯 Curated coding interview preparation materials for busy software engineers
Pros of tech-interview-handbook
- Comprehensive coverage of various tech interview topics beyond just data structures and algorithms
- Includes soft skills advice, resume tips, and company-specific interview information
- Regularly updated with contributions from a large community
Cons of tech-interview-handbook
- Less focused on in-depth implementation of data structures and algorithms
- May be overwhelming for beginners due to the breadth of information covered
Code Comparison
tech-interview-handbook:
function binarySearch(arr, target) {
let left = 0;
let right = arr.length - 1;
while (left <= right) {
const mid = Math.floor((left + right) / 2);
if (arr[mid] === target) return mid;
if (arr[mid] < target) left = mid + 1;
else right = mid - 1;
}
return -1;
}
Data-Structures-and-Algorithms:
def binary_search(arr, target):
left, right = 0, len(arr) - 1
while left <= right:
mid = (left + right) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1
Both repositories provide implementations of common algorithms, but tech-interview-handbook offers a broader range of interview preparation materials, while Data-Structures-and-Algorithms focuses more on detailed implementations and explanations of data structures and algorithms.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Data Structures and Algorithms
Clean and simple implementation in Go
Implementation
There are several data structures and algorithms implemented in this project. The list will be replenished with time.
Data structures
- Circular Buffer
- Linked List
- Doubly Linked List
- Stack
- Queue
- Binary Tree
- Hash Table
- Trie
Searching algorithms
- Linear Search
- Binary Search
- Jump Search
- Interpolation Search
- Exponential Search
- Ternary Search
String searching algorithms
- Naive String Search
- Rabin-Karp Algorithm
Sorting algorithms
- Selection Sort
- Insertion Sort
- Bubble Sort
- Comb Sort
- Cocktail Sort
- Gnome Sort
- Merge Sort
Usage
The library is not intended for direct use by importing. We strongly recommend copying the necessary implementations and adjusting to your case.
You can download the source using go get
command:
go get github.com/floyernick/Data-Structures-and-Algorithms
Don't forget about proverb:
A little copying is better than a little dependency.
Contribute
We would be happy to receive your propositions of improvement! Read Contributing Guide for more details.
License
This project is licensed under the MIT License.
Authors
Mykyta Paliienko - GitHub profile
Top Related Projects
All Algorithms implemented in Python
Minimal examples of data structures and algorithms in Python
📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
120+ interactive Python coding interview challenges (algorithms and data structures). Includes Anki flashcards.
A complete computer science study plan to become a software engineer.
💯 Curated coding interview preparation materials for busy software engineers
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot