Algorithms and programs design

Assignment Help Data Structure & Algorithms
Reference no: EM131103889

1 Introduction

Numerous games can actually be played rather well by computers. Amongst all the different games types existing, we consider here a set of games where the goals require the constitution of english words from a set of letters (rep- resented on tiles, cards, ...).
We propose to write in this assignement an algorithm for computing, given a set of letters, a list of possible words. For example, given "a,b,c" we can compute "a", "b", "c", or "cab". This programming exercise will also be the opportunity to practice with strings, C language, trees and complexities.


2 Algorithm

Basically to have a fast algorithm we propose to build a large tree to store all english words. The provided american-english file contains a list of words. Each word will be inserted in the tree and will end in a leaf node. The tree contains 27 levels. At first level (root node) nothing is specified. From there M + 1 edges go down to the next level where M is the maximal number of times any letter can appear in a word. The first edge will correspond to words which do not contain current level letter. The second edge will correspond to words which contain exactly one such letter, and so on.
When the occurence of all letters is chosen we reach a leaf node which contains a list of words containing exactly the same letters. Figure 1 il- lustrates the start of the tree for M = 9 while Figure 2 shows a leaf node example.
We need to program two different algorithms : one for inserting the words in the tree and the other one for displaying words from the tree. Both algorithm work in a recursive manner. The insertion algorithm takes four different parameters: a node pointer, a word signature, the current letter being processed, a pointer to currently inserted word. The signature is just an array of letter frequencies for current word. It allows to get very quickly the number of times a letter appears in a word. To be more precise,

 

1255_1.png

Figure  2: leaf node

a b c d e f g h i j k l m n o p q r s t u v w x y z

536_1.png

the number of times 'a' appears in the word is stored in the first cell of the array. The number of times 'b' appears, in the second cell, and so on...
The algorithm works as follows: first we check current letter. If we reach the last letter then we insert the word in the corresponding list. If not, we do call the insertion algorithm recursively on the corresponding child of current node. For example, while inserting "cab" with current letter 'b', we continue by recursively inserting with current letter 'c' on the child corresponding to exactly one 'b'.
On the other side we also need an algorithm to display all words which can be built using a set of letters. The algorithm takes as input a dictionary, a signature encoding the letters we can use and the current letter. Again the algorithm works recursively. It works as a depth first search with the condition the all children explored must be reachable with the given signa- ture. For example, when starting from the root, we consider all children corresponding to 0 'a', 1 'a', 2 'a', and so on. If the signature only contains
2 'a' then there is no need to explore the children corresponding to 3 or more
'a' but we must explore all others since it is allowed to leave some letters unused. Once a leaf is reached, all words in the list are printed to the screen.


3 Programming Work

All files are to be downloaded at https://www-id.imag.fr/Laboratoire/ Membres/Wagner_Frederic/mosig.html
You are provided a words.c file which helps you by giving you input output functions. Both the main and read_words functions are given and will read a file containing a list of words (american-english), store them in a dictionary and wait for input on stdin to search for words. It is possible to test for a list of words using standard unix redirections, for example by using time ./words < my_test_list > /dev/nul l.

3.1 Basic Algorithm

You are required to code the algorithms from section 2. Dictionary struc- tures are already defined but you need to define list structures to store words. The following functions are left to be completed:
• list_new : returns an empty list

• list_append : adds a word at end of a list

• list_display : displays all words in a list

• compute_signature : returns the signature array for a given string

• dict_insert : the recursive insertion function

• dict_search_and_display : the recursive search function

3.2 Advanced Algorithm

Once the basic algorithm is working we ask you to write an extension. Both the basic and extended versions of your program need to be submitted so the best is surely to copy your file to a new file before starting.
We ask you to modify your algorithms in order to allow the use of jokers. The joker letter which we will take as '*' is a letter which can be used to replace any other one. For example, if your letters are 'r,c,e,a,*' you can build "reach" using the joker as an 'h' or "carve" using the joker as a 'v'.
We consider here that only one joker is available in the game. Any func- tion prototype can be modified as you like. You are in charge of providing an algorithm.

4 Report

Additionally to your code, you need to send a small 2 pages report. In this report you should explain what you did. Are all required algorithms working ? Can you evaluate the performances of your algorithms ? What is the "joker" version doing and is it fast ?
Please also answer the following list of questions where M denotes the maximal number of appearances of any letter in any word and N denotes the total number of words :

• Give an asymptotic worst case execution cost for the basic insertion algorithm.

• How can you evaluate the cost for a basic search ?

• Give the memory consumption for basic algorithms.

• Give an asymptotic worst case execution cost for the advanced (with the joker) insertion algorithm.

• How does the cost of a search changes when switching from basic to advanced version ?
• What is the memory consumption for your advanced algorithms ? Both code and report are to be sent to [email protected] before
friday November 25.

 

Attachment:- algo_words.tgz

Reference no: EM131103889

Questions Cloud

What form is capital income paid when businesses own capital : In what form is capital income paid when businesses own capital?
Explanation will involve eigenfunctions and orthogonality : The following is a general Fourier series for u(x, y), Explain why we multiply u0(t) by ½. A thorough explanation will involve eigenfunctions and orthogonality
Time series forecasting : Collect data on any topic of interest to you, preferably something related to your work (application of the techniques from this course to your work will add value to your organization and to you.) You may choose to do either Time Series Forecast..
Question regarding the sales management-practices : Fully describe three (3) measures for assessing the effectiveness of a sales force as a whole. Explain why they are important, what they determine, and how sales managers apply these criteria to sales force performance evaluations.
Algorithms and programs design : Numerous games can actually be played rather well by computers. Amongst all the different games types existing, we consider here a set of games where the goals require the constitution of english words from a set of letters
A personal website occur quite infrequently : 1. Hits on a personal website occur quite infrequently. They occur randomly and independently with an average of five per week.
Research on strategies for conducting an appraisal interview : Performance management includes activities which ensure that goals are consistently being met in an effective and efficient manner. Performance management can focus on the performance of an organization, a department, employee, or even the process..
Human resource function interacts with other functions : The objective of this assessment is to demonstrate your understanding of how the human resource function interacts with other functions in the organization.
Determine the vtc for such a realization : Unless otherwise stated, in the following problems assume VDD = 1:8 V, μn Cox = 100 μA/V2, μp Cox = 50 μA/V2, VTH;N = 0:4 V, VTH;P = -0:5 V, λN = 0, and λP = 0.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Suppose you develop an algorithm that processes the first

consider searching algorithms on the following array of data 22 21 9 4 16 2 10 14 20 31 26 19 17 28 8 13 suppose you

  Algorithm to divide sixteen digit value by six digit integer

Divide 16 digit value N by six digit integer D obtaining quotient Q and remainder (or sign of the remainder) R by division algorithms.

  Show how to construct a las vegas algorithm c to establish j

A deterministic, process terminating verification algorithm B that tests if j holds or not.Show how to construct a Las Vegas algorithm C to establish J.

  Write efficient pseudocode algorithm to determine record

Write the most efficient pseudocode algorithm you can to determine the record with specific customerID if every single customer ID from 101 to 500 is used and array has 400 elements.

  Design and implement class menu which use doubly linked list

Design and implement a class Menu which uses doubly linked lists as main data structures. A Menu object consists of a set of main menu items, organized as a doubly linked list.

  Write specifications using uml notation for a function

Write specifications using UML notation for a function that computes the sum of the first five positive integers in an array of  n  arbitrary integers.

  Features of a database

What is a VIEW and what are its uses?

  Difference between an index and a discrete logarithm

Find the prime factorization of 7007. Also describe and show how you find it in step by step -  What is the difference between an index and a discrete logarithm?

  Distributed system algorithms

Distributed system algorithms - Leader Election (id),  In: Processor's id , Out: LEADER if processor has largest id, NOT_LEADER if otherwise

  Possible external-memory map implementation

Another possible external-memory map implementation is to use a skip list, but to collect consecutive groups of  O ( B ) nodes, in individual blocks, on any level in the skip list

  Give an algorithm that returns the position

Give an algorithm that returns true if a string contains properly nested and balanced parentheses, and false if otherwise. Hint: At no time while scanning a legal string from left to right will you have encountered more right parentheses than left..

  Question about binomial tree

A binomial tree of height O, Bo is a one node tree. A binomial tree of height k, Bk is formed through attaching a binomial tree, Bk-1 to root of another binomial tree another binomial tree Bk-1.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd