Question

Write a program in C to make dictionary to add, delete and search words Using linked lists. MAKE THE SEARCHING IN THE pr...

Write a program in C to make dictionary to add, delete and search words Using linked lists.
MAKE THE SEARCHING IN THE program like the searching in the online dictionary(if we enter the 1 letter then it will show all the letters starting with the same number and if we enter 2 letters then it will show all the numbers starting with same two letters and so on up to the complete word.)

make the following functions
1. insert
2. delete
3. search
4. display
5. exit

use FILE HANDLING to store words in file

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

#include<stdlib.h>

#include<string.h>

struct dict_entry{

char word[20];

char mean[300];

int synonym_count:

struct dict_entry* next;

struct dict_entry* synonym1;

struct dict_entry* synonym2;

struct dict_entry* synonym3;

struct dict_entry* synonym4;

struct dict_entry* synonym5;

struct dict_entry* head =NULL;

int option;

struct dict_entry* createNode(char word[] ,char meaning[]){

struct dict_entry *newNode = malloc(sizeof(struct dict_entry));

strcpy(newNode ->mean,meaning);

newNode -> synonym_count =0;

newNode -> synonym1=NULL;

newNode -> synonym2 =NULL;

newNode -> synonym3 =NULL;

newNode -> synonym4=NULL;

newNode -> synonym5 =NULL;

return newNode;

}

void displayDict(){

int i=1;

struct dict_entry* temp= head;

printf("\t word \t Defination\n*);

while(temp!=NULL){

printf("%d, %s - %s\n",i,temp->word,temp->mean);

i++;

temp =temp-> next:

}

printf("\n\n");

}

void linker2(struct dict_entry* src,struct dict_entry* dest,int number) {

switch (number) {

case 1:

src ->synonym1 =dest;

break;

case 2:

src ->synonym2=dest;

break;

case 3:

src ->synonym3=dest;

break;

case 4:

src ->synonym4=dest;

break;

case 5:

src ->synonym5=dest;

break;

}
}

///

void linker(struct dict_entry* src,struct dict_entry* dest){

if(src -> synonym_count <5){

src -> synonym_count++;

linker2(src,dest,stc -> synonym_count);

}

else{

printf("no space for a synonym");

}

}

void synonym_connecter(struct dict_entry* node,char arr[]){

struct dict_entry* temp=head;

int result = -1;

while(temp !=NULL){

result =strcmp(arr,temp ->word);

if(result ==0){

linker1(node,temp);

break;

}

temp =temp -> next;

}

if (result == -1){

printf("that word not found in dictionary");

}

}

void insert () {

struct dict_entry* temp = head;

char input_word[20]={'\0'};

char arr[300]={'\0'};

printf("enter your word ");

scanf("%s" , input_word);

while(temp!=NULL){

if(strcmp(input_word,temp->word)==0){

printf("same word found in dict\n");

return;

}

temp=temp ->next;

}

struct dict_entry* newN=createNode(input_word,arr);

if(head==NULL){

Ahead =newN;

}

else{

temp= head;

while(temp-> next !=NULL){

temp = temp ->next;

}

temp = temp ->newN;

}

int i;

displayDict():

printf("enter the synonym which are in the list");

//enter f to exit from loop

for(i=0;i<5;i++)

{

scanf("%s", input_word);

if(strcmp(input_word, "f")==0){

break;}

synonym_connector(newN,input_word);

}

return;

Add a comment
Know the answer?
Add Answer to:
Write a program in C to make dictionary to add, delete and search words Using linked lists. MAKE THE SEARCHING IN THE pr...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • write a C program to make the dictionary USING LINKED LISTS and STORE DATA in File HANDLING..... you have to create functions 1. insert 2. delete 3. search(if we search with any letter then the words...

    write a C program to make the dictionary USING LINKED LISTS and STORE DATA in File HANDLING..... you have to create functions 1. insert 2. delete 3. search(if we search with any letter then the words with same first letter have been shown) 4. display 6. exit Appearance should be like proper dictionary.

  • Write a c program to make a dictionary .... we add string in file and if we search with only one ...

    write a c program to make a dictionary .... we add string in file and if we search with only one letter then print all its same first letter word and if we enter the complete name then print the only same number.....it can be done only with linked lists...

  • 13inary Search Tree Using a binary search tree, you are tasked with building a dictionary program...

    13inary Search Tree Using a binary search tree, you are tasked with building a dictionary program which you can store a word with its definition. Each node of the tree will contain the word and definition. The word is what will be used as the key to sort our data. The dictionary should allow you to search for a word. If the word exist then the definition will display. You can also add words to the dictionary. For testing you...

  • C program of a dictionary using linked list

    six options in the menu:Create a new dictionary.2. Add a word to a dictionary. 3. Delete a word from a dictionary. 4. Find a word in a dictionary. 5. Delete a dictionary. 6. Exit.each word represented by typedef struct Word { char** translations; struct Word* next; } Word;each dictionary represented bytypedef struct { char** languages; int numOfLanguages; Word* wordList; } Dictionary;languages will include a pointer to an array of strings so that the first word is the origin language and...

  • Goal: design and implement a dictionary. implement your dictionary using AVL tree . Problem​: Each entry...

    Goal: design and implement a dictionary. implement your dictionary using AVL tree . Problem​: Each entry in the dictionary is a pair: (word, meaning). Word is a one-word string, meaning can be a string of one or more words (it’s your choice of implementation, you can restrict the meaning to one-word strings). The dictionary is case-insensitive. It means “Book”, “BOOK”, “book” are all the same . Your dictionary application must provide its operations through the following menu (make sure that...

  • Write the following C++ program that searches for specified words hidden within a matrix of letters....

    Write the following C++ program that searches for specified words hidden within a matrix of letters. 1) Read a file that the user specifies. The file will first specify the dimensions of the matrix (e.g., 20 30). These two numbers specify the number of rows in the matrix and then the number of columns in the matrix. 2) Following these two numbers, there will be a number of rows of letters. These letters should be read into your matrix row...

  • Question 2: Finding the best Scrabble word with Recursion using java Scrabble is a game in...

    Question 2: Finding the best Scrabble word with Recursion using java Scrabble is a game in which players construct words from random letters, building on words already played. Each letter has an associated point value and the aim is to collect more points than your opponent. Please see https: //en.wikipedia.org/wiki/Scrabble for an overview if you are unfamiliar with the game. You will write a program that allows a user to enter 7 letters (representing the letter tiles they hold), plus...

  • Write a program that employs the four letter word dictionary to check the spelling of an...

    Write a program that employs the four letter word dictionary to check the spelling of an input word (test word). You will need to save the dictionary file to a folder on your computer. For this program you will prompt the user to enter a four letter word (or four characters). Then using a loop read each word from the dictionary and compare it to the input test word. If there is a match then you have spellchecked the word....

  • This lab will combine reading data from a file and searching the array to find a...

    This lab will combine reading data from a file and searching the array to find a specific value. Assignment Write a program that reads in a file full of strings into an array, and prompts the user for a string to find in the array. The program should loop until a sentinel value (such as -1) is entered. After looping in main() for the input, write a search function, with the following prototype: int findWord(string [], int, string); with arguments...

  • Goal:   Unscramble permuted words by generating all permutations of Jumble string and searching for a word...

    Goal:   Unscramble permuted words by generating all permutations of Jumble string and searching for a word in Unix dictionary. Unix Dictionary: dict.txt Details: Write a method called get_permutations that inputs a string like "dog". Your method should return an array of all permutations of the Jumble string. . For example: s = "dog" perms = get_permutations(a) print(perms) Output: ['dog', 'dgo', 'odg', 'ogd', 'gdo', 'god'] Rewrite the script for obtaining permutations and the end of the Comments, Hints, and Observersions section...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT