0% found this document useful (0 votes)
9 views

FDSA Assignment-4

Uploaded by

Chirag Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

FDSA Assignment-4

Uploaded by

Chirag Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Birla Institute of Technology and Science, Pilani Hyd Campus

BITS F232: Foundations of Data Structures and Algorithms


1st Semester 2022-23

Programming Assignment-4, Max Marks: 07


Date of Submission: 26th Nov 2022
Mini-project: In this assignment your group may choose any one of the below projects and use either STLs
or previously developed code by you to implement the task (in either labs/ earlier assignments). This has
to be done using C++.

Q.1: Write a spell-checker class that stores a set of words, W, in a hash table and implements a function,
spellCheck(s), which performs a spell check on the string s with respect to the set of words, W. If s is in W,
then the call to spellCheck(s) returns an iterable collection that contains only s, since it is assumed to be
spelled correctly in this case. Otherwise, if s is not in W, then the call to spellCheck(s) returns a list of every
word in W that could be a correct spelling of s. Your program should be able to handle all the common
ways that s might be a misspelling of a word in W, including swapping adjacent characters in a word,
inserting a single character in-between two adjacent characters in a word, deleting a single character from
a word, and replacing a character in a word with another character. For an extra challenge, consider
phonetic substitutions as well.

Q.2 Write a simple text editor, which stores a string of characters using the list ADT, together with a cursor
object that highlights the position of some character in the string (or possibly the position before the first
character). Your editor should support the following operations and redisplay the current text (that is, the
list) after performing any one of them:

• left: Move cursor left one character (or nothing if at the beginning)
• right: Move cursor right one character (or do nothing if at the end)
• delete: Delete the character to the right of the cursor (or do nothing if at the end)
• insert c: Insert the character c just after the cursor

Q.3 Given N words and Q queries. Each query contains a string with a wildcard character. Only one type
of wildcard character is used, which is (*). You need to write a program that prints “Found the Word(s)!”
if the string in the query is found matching with the given N words and print all the available words in
the following line. If no words are found, print “No words Found.”

* --> Matches with 0 or more instances of any character or set of characters.


Input Format:

First, take input N and Q and then N words. Then, take input Q queries and output the corresponding
output for each of them.

Output Format:

Explained above.

Example:

N=6

Q=1

[‘suyash, ’samarth’, ‘sanchit,’ ‘saman,’ ‘amish,’ ‘ravi’]

[‘sa*n’]

Output:

Found the Word(s)!

saman

Explanation:

The starting and ending of the string match with starting and ending of saman.

Constraints

1<=Q (Number of queries) <= 10⁴

1 <= N (Number of given words) <=10⁴

1 <= M (Length of each word) <= 7

Please note that the time complexity of the code should be strictly less than Q*N.
Submission Instructions:

You can form your own group of two students. This grouping is allowed only for allowing peer learning.
However, you need to solve yourself all the questions. There will be a demo or viva for these assignments
at a later date. You should submit your exe file, and source files putting all of those into a tar file/ zip file,
and upload it into google class before the submission deadline i.e. midnight, 26th Nov 2022. Your code
should also run on Ubuntu systems (like in the lab) for evaluation purposes. You should also keep a copy
of your code. Any doubts or queries regarding the questions can be emailed to
[email protected].

I/C
(C R Hota)

Date given: 17th Nov 2022

-----------------------------

You might also like