Problem 2: The following dictionary word and its meaning is given. Create a struct data structure such that when the client types the word, the meaning of that word is displayed.
Word: foo; Meaning: A file
Word: fooo; Meaning: A long file
Word: foooo; Meaning: A long long file
Word: fooooo; Meaning: A long long long file
Word: foooooo; Meaning: A long long long long file
Word: fooooooo; Meaning: A long long long long long file
Write the algorithm in a .doc file and C++ code of the problem
Algorithm:
Step 1: Start
Step 2: Define a structure dictionary
Step 3: Declare variables dictionary, word, flag, temp, file
Step 4: Initialising the variable
flag <-
0
open file <-
dictionary.txt
Step 5: Read word from user.
Step 6: Repeat the steps until !file.eof()
6.1 Read the first word into temp
second
word into dictionary.word
third word
into temp
rest line
into dictionary.meaning
6.2 if dictionary.word = word
flag = 1
break
Step 7: If flag=1
Display dictionary.meaning
else
Display meaning not found
Step 8: Stop
Code:
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
// Struct data type dictionary
struct dictionary
{
string word;
string meaning;
};
int main()
{
ifstream file("dictionary.txt"); // opening the file that contains
the word and meanings
int flag=0;
string word,temp;
dictionary d1;
if(!file.is_open()) // Checking if the file is open
{
cout<<"File doesnt exist!!";
exit(0);
}
cout<<"Enter the word you want to search : "; // getting
the word from the user
cin>>word;
while(!file.eof()) // reading till the end of file
{
file>>temp;
file>>d1.word;
d1.word.pop_back();
file>>temp;
getline(file,d1.meaning);
if(d1.word==word) // checking if the word in the file and user
entered is matching
{
flag=1;
break;
}
}
if(flag==1) // if its matching
cout<<endl<<"The meaning if the word
"<<d1.word<<" is "<<d1.meaning<<endl;
else // if it doesn't match
cout<<endl<<"The meaning of the word could not be
found!!"<<endl;
file.close(); // closing the file
}
Output:

Problem 2: The following dictionary word and its meaning is given. Create a struct data structure...
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...
() Given the following structure definition and typedef for a linked list of strings: typedef struct node st node; struct node st { char *word; /* a valid string pointer or NULL */ node *next; /* next node in the list or NULL */ }; Write a C function, free list(), that takes as an argument one of these lists, possibly NULL, and frees all the strings as well as the list itself. Write robust code. void free list(node *list){
struct student { char name[10]; int rank; }; Using the student structure given above, create an array of size 5 students.. Then write a complete C program to sort the students array based on the students rank. Use the following sorting techniques in your code. Don’t forget to print initial array and final (sorted) array. a. Selection sort b. Insertion sort c. Merge sort / Quick sort.
You are given a set of ABC cubes for kids (like the one shown below) and a word. On each side of each cube a letter is written 7 FI 0 You need to find out, whether it it possible to form a given word by the cubes For example, suppose that you have 5 cubes: B1: MXTUAS B2:OQATGE ВЗ: REwMNA B4: MBDFAC В5: IJKGDE (here for each cube the list of letters written on its sides is given) You...
For each of the following word problems, write corresponding numerical division problem. Also, interpret the meaning of the whole-number-with-reminder answer and the meaning of the mixed number answer to the division problem in terms of the word problem and its answer. a. You have 27 pints of soup and several containers that hold 4 pints. How many containers will you need to hold ll the soup? b. How long will it take you to drive 105 miles at a steady...
Write a function, named display_count_dict, that when given a my_count dictionary, representing a key with its value being a count, displays the dictionary with key and count so that the key having the highest count is displayed, first. Sample:my_counts{"A":3, "D":3, "B": 7, "E": 2, "C"10}
Problemi: Create a new Java Application that has the following methods: 1. A method that generate a binary search tree (BST) where the number of nodes and the range of the values are from a file 2. A recursive method to print the BST in preorder traversal 3. A recursive method to print the BST in post-order traversal 4. A recursive method to print the BST in in-order traversal 5. A method to find the largest value in a BST...
Activities Define a struct called Unit containing the following fields I Unit code Unit credit hours Unit semester of study List of prerequisites Number of prerequisites List of post requisites Number of post requisites Inside your main function declare an array of type Unit called units with size 20 elements. This array will contain the information related to all the units in our diploma program. Each of the elements of this array correspond with one our diploma units. II III...
1. Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. (employee.py) 2. Create a UML diagram for Employee class. (word file) 3. Create a program that stores Employee objects in a dictionary. Use the employee ID number as the key. (employee_App.py) The program should present a menu that lets the user perform the following actions: ✓ Look up an employee in the dictionary ✔ Add a new...
Program Language: PYTHON Consider the following file structure: each line of the file contains a word. The words are in sorted order. For example, a file might look like this apple apple apple apple banana bargain brick brick sample sample simple text text text Write a program that asks the user for a filename with this structure. The program's job is to write the sequence of words to another file, without any duplicates. Name the output file result.txt. Each word is...