Simple answers but work shown thank you!
(a) In how many different ways can the letters of the word wombat be arranged?
(b) In how many different ways can the letters of the word wombat be arranged if the letters wo must remain together (in this order)?
(c) How many different 3-letter words can be formed from the letters of the word wombat? And what if w must be the first letter of any such 3-letter word?
In: Statistics and Probability
JAVA CODE, BEGINERS; Please use comments to explain
For all of the following words, if you move the first letter to the end of the word, and then spell the result backwards, you will get the original word:
banana dresser grammar potato revive uneven assess
Write a program that reads a word and determines whether it has this property. Continue reading and testing words until you encounter the word quit. Treat uppercase letters as lowercase letters.
In: Computer Science
Translate this algorithm to code on C
compare(char array[ ])
word = split(array, " "); //gets the first word before the blank space
if word == Hello {
print("I am saying hello");
}else if (word == Bye)
print("I am saying goodbye");
}
Example---------------------
char array = "Hello Ana";
compare(array);
char array1 = "Bye Ana"
compare(array1);
result
"I am saying hello"
"I am saying goodbye"
In: Computer Science
Write a function in python that accepts a sentence as the argument and converts each word to “Pig Latin.” In one version, to convert a word to Pig Latin, you remove the first letter and place that letter at the end of the word. Then you append the string “ay” to the word. Here is an example: English: I SLEPT MOST OF THE NIGHTPIG LATIN: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY. Please, I want the coding indented and then the results screen shot.
In: Computer Science
Concepts tested by this program
Hash Table,
Link List,
hash code, buckets/chaining,
exception handling, read/write files (FileChooser)
A concordance lists every word that occurs in a document in alphabetical order, and for each word it gives the line number of every line in the document where the word occurs.
Write a program that creates a concordance. There will be two ways to create a concordance. The first requires a document to be read from an input file, and the concordance data is written to an output file. The second reads the input from a string and returns an ArrayList of strings that represent the concordance of the string.
Because they are so common, don't include the words "the" or “and” in your concordance. Also, do not include words that have length less than 3. Strip out all punctuation, except apostrophes that occur in the middle of a word, i.e. let’s, we’d, etc.
Data Elements – ConcordanceDataElement, implements Comparable and consists of a String (the word) and a reference to a LinkedList (list of line numbers where word occurs). Follow the Javadoc provided for you.
Data Structure – ConcordanceDataStructure,
Implements the ConcordanceDataStructureInterface Interface that is provided.
You will be implementing a hash table with buckets. It will be an array of linked list of ConcordanceDataElements. The add method will take a word and a line number to be added to the data structure. If the word already exists, the line number will be added to the linked list for this word. If the line number for the word already exists, don’t add it again to the linked list. (i.e. if Sarah was on line 5 twice, the first line 5 would be added to the linked list for Sarah, the second one would not). If the word doesn’t exist, create a ConcordanceDataElement and add it to the HashTable. Two constructors will be required, one that takes in an integer that is the estimated number of words in the text, the other is used for testing purposes. Look at the provided Javadoc.
Data Manager – ConcordanceDataManager
Implements the ConcordanceDataManagerInterface interface that is provided.
The data manager allows the client (user) to create a concordance file or a concordance list (ArrayList of strings). The input is read (from a file or string) and is added to the data structure through the add method. The add method requires a word and a line number. The line number is incremented every time a newline appears in the file or the string.
Concepts tested by this program
Hash Table,
Link List,
hash code, buckets/chaining,
exception handling, read/write files (FileChooser)
A concordance lists every word that occurs in a document in alphabetical order, and for each word it gives the line number of every line in the document where the word occurs.
Write a program that creates a concordance. There will be two ways to create a concordance. The first requires a document to be read from an input file, and the concordance data is written to an output file. The second reads the input from a string and returns an ArrayList of strings that represent the concordance of the string.
Because they are so common, don't include the words "the" or “and” in your concordance. Also, do not include words that have length less than 3. Strip out all punctuation, except apostrophes that occur in the middle of a word, i.e. let’s, we’d, etc.
Data Elements – ConcordanceDataElement, implements Comparable and consists of a String (the word) and a reference to a LinkedList (list of line numbers where word occurs). Follow the Javadoc provided for you.
Data Structure – ConcordanceDataStructure,
Implements the ConcordanceDataStructureInterface Interface that is provided.
You will be implementing a hash table with buckets. It will be an array of linked list of ConcordanceDataElements. The add method will take a word and a line number to be added to the data structure. If the word already exists, the line number will be added to the linked list for this word. If the line number for the word already exists, don’t add it again to the linked list. (i.e. if Sarah was on line 5 twice, the first line 5 would be added to the linked list for Sarah, the second one would not). If the word doesn’t exist, create a ConcordanceDataElement and add it to the HashTable. Two constructors will be required, one that takes in an integer that is the estimated number of words in the text, the other is used for testing purposes. Look at the provided Javadoc.
Data Manager – ConcordanceDataManager
Implements the ConcordanceDataManagerInterface interface that is provided.
The data manager allows the client (user) to create a concordance file or a concordance list (ArrayList of strings). The input is read (from a file or string) and is added to the data structure through the add method. The add method requires a word and a line number. The line number is incremented every time a newline appears in the file or the string.
In: Computer Science
Program Zeus: Complete the Count Vowels program (Count Vowels.cpp template provided at the end) to include two user defined functions (which you will write!). Code lenguage is C++
bool isVowel (char c) // returns true if c is a vowel and false otherwise
int countVowels (string s) // returns the number of vowels in s.
You can access each character of s by using s.at(i) where i ranges from 0 to s.length()-1.
countVowels () should call isVowel (s.at(i)) to check if character i is a vowel.
Run the program once with the following inputs. For full credit, your output should be the same as the output below.
Please enter a word or type "quit" to exit: apple
apple has 2 vowels.
Please enter a word or type "quit" to exit: twang
twang has 1 vowel.
Please enter a word or type "quit" to exit: xyz
xyz has 0 vowels.
Please enter a word or type "quit" to exit: aeiou
aeiou has 5 vowels.
Please enter a word or type "quit" to exit: antidisestablishmentarianism
antidisestablishmentarianism has 11 vowels.
Please enter a word or type "quit" to exit: quit
Goodbye!
Template for Program:
#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;
bool isVowel(char);
int countVowels(string); .
int main ( )
{
string word;
int numVowels;cout << "Please enter a word or type \"quit\" to exit: ";
cin >> word;
while ()
{
cout << "Please enter a word or type \"quit\" to exit: ";
cin >> word;
}
cout << "Goodbye!" << endl;
return 0;
}
// This function returns the number of vowels in s.
// This function will call isVowel.
int countVowels(string s)
{
}
// This function returns true if c is a vowel and false otherwise
bool isVowel(char c)
{
}
In: Computer Science
a) Given a variable word that has been assigned a string value, write a string expression that parenthesizes the value of word. So, if word contains "sadly", the value of the expression would be the string "(sadly)"
b) Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Write a statement that prints the value of price in the form "X dollars and Y cents" on a line by itself. So, if the value of price was 4321, your code would print "43 dollars and 21 cents". If the value was 501 it would print "5 dollars and 1 cents". If the value was 99 your code would print "0 dollars and 99 cents".
c) Assume that word is a String variable. Write a statement to display the message "Today's Word-Of-The-Day is: " followed by the value of word on a line by itself on standard output.
In: Computer Science
You can turn a word into pig-Latin using the following two rules:
Write a function pig() that takes a word (i.e., a string) as input and returns its pig-Latin form. Your function should still work if the input word contains upper case characters. Your output should always be lower case.
For example, if you enter
pig('happy')
The output should be
'appyhay'
If you enter
pig('Enter')
The output should be
'enterway'
In: Computer Science
If all permutations of the letters of the word "BEFORE" are arranged in the order as in a dictionary. What is the 32 word?
In: Statistics and Probability
Please complete in Python and neatly explain and format code. Use snake case style when defining variables. Write a program named wordhistogram.py which takes one file as an argument. The file is an plain text file(make your own) which shall be analyzed by the program. Upon completing the analysis, the program shall output a report detailing the shortest word(s), the longest word(s), the most frequently used word(s), and a histogram of all the words used in the input file.
If there is a tie, then all words that are of the same length for that classification (longest, shortest, most frequent) are displayed as part of that class.
A word histogram shows an approximate representation of the distribution of words used in the input file. An example text, The_Jungle_Upton_Sinclair.txt, is provided as a starting point for analyzing natural language. Draw your histogram by listing the word first and then print up to 65 * characters to represent the frequency of the word.
Since there is limited space on a terminal, ensure that your histogram does not wrap along the right edge of the terminal. Assume that the width of the histogram can not be wider than 65 characters. In calculating your histogram, map the highest frequency to 65 characters. For example, if the text has a word that appears 2000 times and it is the most frequently used word, then divide 2000 by 65 to approximate that each * character represents 30 occurrences of the word in question in the text. Thus if a word should appear less than 30 times, it receives zero * characters, a word that appeared 125 time would receive 4 * characters (0-30, 31-60, 61-90, 91-120, 120-150).
Print the order of the histogram from most frequent to least frequent.
The program must have a class named WordHistogram. This class must be the data structure that keeps track of the words that appear in the input text file and can return the histogram as a single string. The main function is responsible for opening and reading the the input text file.
Make sure your WordHistogram class has data members that are correctly named (use the underscore character!), has an initializer, and any necessary methods and data members.
In your main, use the given function to read from the filehandle.
def word_iterator(file_handle):
""" This iterates through all the words of a given file handle. """
for line in file_handle:
for word in line.split():
yield word
DO NOT COMPUTE OR STORE THE HISTOGRAM OUTSIDE OF AN OBJECT named WordHistogram
Please use this code to get started:
#!/usr/bin/env python3
import sys
def main():
if len(sys.argv) < 2:
print("Provide an input file. Exiting");
exit(1)
wh = WordHistogram( )
with open(sys.argv[1], "r") as fh:
for word in word_iterator(fh):
wh.insert(word)
print(wh.report( ))
if __name__ == '__main__':
main()
Example Output
$ ./wordhistogram.py Candide_Voltaire.txt Word Histogram Report the (2179) ****************************************************************** of (1233) ************************************* to (1130) ********************************** and (1127) ********************************** a (863) ************************** in (623) ****************** i (446) ************* was (434) ************* that (414) ************ he (410) ************ with (395) *********** is (348) ********** his (333) ********** you (317) ********* said (302) ********* not (276) ******** ... $
In: Computer Science