Skip to content

Slmaking/Data-Structure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Data-Structure and algorithm

Fundamental Algorithms and Data Structures

This repository is a comprehensive collection of Java and Python implementations of fundamental algorithms and data structures, inspired by the curriculum of Princeton University. It serves as an educational resource for understanding and applying key concepts in computer science, with an emphasis on applications and scientific performance analysis.

Structure

The repository is organized into two main parts:

Part I: Elementary Data Structures, Sorting, and Searching

Covers basic data structures and algorithms for sorting and searching, including:

  • Union-Find
  • Binary Search
  • Stacks, Queues, Bags
  • Various Sorting Algorithms
  • Binary Heaps
  • Binary Search Trees and Red-Black Trees
  • Hash Tables
  • Geometric Algorithms and kd-Trees

Part II: Graph and String-Processing Algorithms

Focuses on advanced topics in graph theory and string processing, including:

  • Graph Algorithms
  • String-Processing Algorithms
  • Compression and Encoding Algorithms
  • Reductions and Intractability

Data Structures and Algorithms

Data Structures and Algorithms Summary

Topic Data Structures and Algorithms Part
Data Types stack, queue, bag, union-find, priority queue Part 1
Sorting quicksort, mergesort, heapsort
Searching BST, red-black BST, hash table
Graphs BFS, DFS, Prim, Kruskal, Dijkstra Part 2
Strings radix sorts, tries, KMP, regexps, data compression
Advanced B-tree, suffix array, maxflow

Sorting models comaparision

Implementation Worst-case cost (after N inserts) Average case (after N random inserts) Ordered iteration? Key interface
search insert delete search hit insert delete
Sequential search (unordered list) N N N N/2 N N/2 no equals()
Binary search (ordered array) lg N N N lg N N/2 N/2 yes compareTo()
BST N N N 1.39 lg N 1.39 lg N sqrt(N) yes compareTo()
2-3 tree c lg N c lg N c lg N c lg N c lg N c lg N yes compareTo()
Red-black BST 2 lg N 2 lg N 2 lg N 1.00 lg N* 1.00 lg N* 1.00 lg N* yes compareTo()

* exact value of coefficient unknown but extremely close to 1

Sorting Algorithm Summary

Algorithm Inplace? Stable? Worst Average Best Remarks
Selection ✔️ N / 2 N / 2 N / 2 N exchanges
Insertion ✔️ ✔️ N / 2 N / 4 N Use for small N or partially ordered
Shell ✔️ N^2 n^1.25 N Tight code, subquadratic
Merge ✔️ N lg N N lg N N lg N N log N guarantee, stable
Quick ✔️ N / 2 2 N ln N N lg N Fastest in practice
3-way Quick ✔️ ✔️ N / 2 2 N ln N N Improves quicksort in presence of duplicate keys
Ideal ✔️ ✔️ N lg N N lg N N lg N Holy sorting grail

Usage

Each directory within this repository corresponds to a specific topic or algorithm and contains both Java and Python implementations. Detailed README files are provided in each directory to explain the concepts, applications, and performance analysis of the implementations.

Contributing

Contributions to this repository are welcome.

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published