Skip to content

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autocomplete Hash vs. Trie Comparison

Overview

This project implements and compares two data structures for word lookup and autocomplete; Hash Map, and Trie. The program allows users to load a dataset of words, insert them into both data structures, perform searches, and compare performance.

How to Build and Run

Using Terminal (g++)

Make sure you are in the project root directory, then run:

g++ -Iinclude src/*.cpp -o main.exe

.\main.exe

Features

  • Load a dataset of words from a file

  • Insert words into both Hash Map and Trie

  • Perform case-insensitive word search

  • Perform prefix-based autocomplete using a Trie

  • Limit autocomplete results to 5 suggestions

  • Compare performance between Hash Map and Trie

Project Structure

data/

    words.txt
  
include/

  Benchmark.h
  
  DatasetLoader.h
  
  HashMap.h
  
  Trie.h

src/

  Benchmark.cpp

  DatasetLoader.cpp
  
  HashMap.cpp
  
  Trie.cpp
  
  main.cpp
  
CMakeLists.txt

README.md

How to Use

After running the program, you will see a menu:

Word Lookup System

  1. Load dataset

  2. Insert words into structures

  3. Search for a word

  4. Search by prefix

  5. Compare performance

  6. Run correctness tests

  7. Exit

Then you will enter the number corresponding to what action you would like to complete and any words or prefix you will like to search up.

Dataset

The dataset file is located in:

data/words.txt

Each line represents a single word.

Notes

  • Searches are case-insensitive (e.g., "dog", "Dog", "DOG" all work).

  • Trie supports efficient prefix searching.

  • Autocomplete results are limited to 5 suggestions for performance and readability.

Author

Viannee

About

Efficient data retrieval is an important problem in Computer Science because many applications depend on quickly searching through large amounts of data. Hashmaps are typically used for fast exact lookups, while tries are better suited for prefix searches, so comparing them helps determine which structure performs better for different search tasks.

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages