A high-performance word indexing and search engine built in C — powered by Hash Tables and Linked Lists.
Inverted Search is a Data Structures project developed in C that efficiently indexes and searches words across multiple text files.
The project implements an Inverted Index using Hashing and Linked Lists to provide:
- ⚡ Fast word lookup
- 📊 Word occurrence tracking
- 📁 Multi-file search support
| Feature | Description |
|---|---|
| 🗄️ Create Database | Build a searchable index from multiple text files |
| 🔎 Search Words | Find any word across all indexed files instantly |
| 📈 Frequency Tracking | Track how often a word appears in each file |
| 🔄 Update Database | Add new files without losing existing data |
| 💾 Save Database | Persist the database to disk in a structured format |
| 📂 Load Database | Reconstruct the full database from a backup file |
| 🧾 Display Database | View the complete indexed database |
| ✅ Duplicate Validation | Prevents the same file from being indexed twice |
- C Programming
- Hash Tables
- Linked Lists
- Dynamic Memory Allocation
- File Handling
The database uses a hash table of size 27:
| Index | Stores |
|---|---|
0 – 25 |
Words starting with a – z |
26 |
Words starting with special characters or numbers |
Stores the word, file count, and links to sub-nodes.
typedef struct Main
{
char word[25];
int file_count;
S_node *sub_link;
struct Main *main_link;
} M_node;Stores the filename and word frequency for a specific file.
typedef struct Sub
{
int word_count;
char filename[20];
struct Sub *sub_link;
} S_node;📄 Input Files
│
▼
✅ Validate Files
│
▼
🗄️ Create Database
│
▼
#️⃣ Hash Table Generation
│
▼
🔠 Word Indexing
│
▼
🔎 Search / 🖥️ Display / 💾 Save / 🔄 Update
╔══════════════════════════╗
║ INVERTED SEARCH ║
╠══════════════════════════╣
║ 1. Create Database ║
║ 2. Display Database ║
║ 3. Save Database ║
║ 4. Search ║
║ 5. Update Database ║
║ 6. Load Database ║
║ 7. Exit ║
╚══════════════════════════╝
- Reads words from one or more input text files
- Calculates hash index based on the first character of each word
- Creates Main Nodes (per word) and Sub Nodes (per file)
- Tracks word frequency per file
- Computes the hash index for the search term
- Traverses the corresponding linked list chain
- Displays:
- Number of files containing the word
- Frequency of the word in each file
- Accepts new text files to index
- Validates for duplicate files
- Merges new data into the existing database seamlessly
Persists the full database to a text file using a structured delimiter format:
#0;apple;2;file1.txt;3;file2.txt;5;#
Parses a saved backup file and fully reconstructs the in-memory database.
gcc *.c -o inverted_search./inverted_search file1.txt file2.txt file3.txtEnter word to search : embedded
✔ Word 'embedded' is present in 2 files
📄 file1.txt → 4 times
📄 file3.txt → 2 times
Working on this project provided hands-on experience with:
- 🔢 Hash Table implementation from scratch
- 🔗 Singly Linked Lists (Main & Sub node chaining)
- 📁 File I/O and database persistence
- 🧠 Dynamic memory allocation (
malloc,free) - 🗃️ Data indexing and retrieval techniques
- ⚡ Search optimization using hashing
- 🧩 Modular programming in C
- 🔡 Case-insensitive searching
- 💬 Phrase / multi-word search
- 🃏 Wildcard search support (
*,?) - 🖼️ GUI-based interface
- 📦 Performance optimization for large datasets
- 🌐 Web-based frontend for search queries
Avinash Patil
Made with ❤️ and C