(dominoes N) which returns a list containing the (N+1)(N+2)/2 tiles in a double-N domino set, with each tile represented as a dotted pair (an improper list).
(dominoes 2) ⇒ ((2 . 2) (2 . 1) (2 . 0) (1 . 1) (1 . 0) (0 . 0))
using the programming language scheme
i need the question to be answered using the programming language Scheme
In: Computer Science
c++
Please read the whole question and instrucions.
The instructor wants a function to convert string to int to perform the bitwise operations then convert int to string back again to show results.
Question:Write a program that produces the
bitwise OR, bitwise AND, and bitwise XOR of the bit strings
1001 0011 1011 and 1111 1010 0000.
Thank you in advance.
In: Computer Science
C++ Zybook LAB15.3.1: What order? (function templates
Define two generic functions called GetVector() and CheckOrder(). GetVector() takes a string of items delimited by spaces and an item of a generic type (i.e., char, int, double, or string) and returns a vector of the given item type. CheckOrder() checks if the vector of items is in ascending, neither, or descending order. The function should return 'a' if the items are in ascending order, 'u' if the items are unordered, and 'd' if the items are in descending order.
To test your functions, you are provided a main program which: Reads items from the input one line at a time, Uses a function called DataType() to determine the type of data (e.g., char, int, etc.) in the line, Constructs a vector of the appropriate type using your GetVector() function, and Then calls your CheckOrder() to output how the items are ordered. The items can be different types, including integers, strings, characters, or doubles.
Ex. If the input is: bat hat mat sat 63.2 196.5 123.5 the output is: Order: a Order: u
Code:
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
using namespace std;
// TODO: Define a generic function called GetVector() that
// takes a string of items delimited by spaces and
// an item of a generic type (i.e., char, int, double,
// or string) and returns a vector of the given item
// type. The GetVector() function signature is below.
template <typename T>
vector<T> GetVector(string items, T item);
// TODO: Define a generic function called CheckOrder()
that
// takes a vector of either char, double, int or string
// type as an argument and returns 'a' if the contents
// of the vector is ascending, 'd' if descending and 'u'
// if it is neither. A vector of zero or one items is
// considered 'u'. The CheckOrder() signature is below.
template <typename T>
char CheckOrder(vector<T> v);
char DataType(string items);
int main(int argc, char* argv[]) {
// Read in items
string items, str_item = "";
char char_item = ' ';
int int_item = 0;
double double_item = 0.0;;
vector<string> sv;
vector<int> iv;
vector<double> dv;
vector<char> cv;
getline(cin, items);
while (!cin.eof()) {
// check for the type of data: DataType returns 'c' for char,
// 'd' for double, 'i' for int, and 's' for string
char type = DataType(items);
// populate the vector
switch (type) {
case 'c': cv = GetVector(items, char_item);
cout << "Order: " << CheckOrder(cv) <<
endl;
break;
case 'd': dv = GetVector(items, double_item);
cout << "Order: " << CheckOrder(dv) <<
endl;
break;
case 'i': iv = GetVector(items, int_item);
cout << "Order: " << CheckOrder(iv) <<
endl;
break;
default : sv = GetVector(items, str_item);
cout << "Order: " << CheckOrder(sv) <<
endl;
break;
}
getline(cin, items);
}
return 0;
}
char DataType(string items) {
bool chars = true;
bool strings = true;
bool ints = true;
bool doubles = true;
for (auto c : items) {
if (isalpha(c)) { ints = false; doubles = false; }
if (c == '.') { ints = false; }
}
if (ints) { return 'i'; }
if (doubles) { return 'd'; }
stringstream ss(items);
string s;
while (ss >> s) {
if (s.length() > 1) { chars = false; }
}
if (chars) { return 'c'; }
return 's';
}
In: Computer Science
Views are virtual in database but Materialized view are persistent. Discuss the need to have materialized view instead of views and in what condition No materialization if preferred.
In: Computer Science
Write a C++ program which performs a rot 13 substitution. Must be in C++. Thank you.
In: Computer Science
Scientific Computing course - I honestly dont know what this question means, we use python in this course. Not sure if that helps with answering this question.
Write an algorithm/pseudo code to transpose an nxn matrix.
In: Computer Science
Specify any four difference between Client/Server computing and Peer-to-Peer computing. Which architecture used by Bitcoin digital currency?
In: Computer Science
The Central Processing Unit consist of three main units. List these three units and discuss the functionality of each.
In: Computer Science
In: Computer Science
Goals
In this assignment you must use Java language to program the small application for a grocery buyer.
You will create meaningful utility that implements
The implementation plus coding style and efficiency will be graded.
Description
The supermarket uses three pricing scenarios for the local products –
Your application must calculate how much you pay for one item depending on a regular price, day of the week, and number of items.
For example, yogurt has regular price of $3. Then, if you buy 3 yogurts on Sunday your spending will be $2 per item.
It is not as simple as it first appears. Consider the following questions before programming:
Program requirements
There is no any sample run, just need a JAVA program to conform the
above requirements.
In: Computer Science
complete all methods in java!
/*
Note: Do not add any additional methods,
attributes.
Do not modify the given
part of the program.
Run your program against
the provided Homework2Driver.java for requirements.
*/
/*
Hint: This Queue implementation will always dequeue
from the first element of
the array i.e,
elements[0]. Therefore, remember to shift all elements
toward front of the
queue after each dequeue.
*/
public class QueueArray<T> {
public static int CAPACITY = 100;
private final T[] elements;
private int rearIndex = -1;
public QueueArray() {
}
public QueueArray(int size) {
}
public T dequeue() {
}
public void enqueue(T info) {
}
public boolean isEmpty() {
}
public boolean isFull() {
}
public int size() {
}
}
In: Computer Science
What is the public interface of counter class in section 3.1 ? How does it differ from the implementation of the class?
| Submission Folder | |
| Chapter 3 Practice Exercise E3.1 | |
| Instructions | |
|
Submit this assignment as an exported archive called CounterModified Textbook ISBN NUmber : 978-1-119-05645-4 |
|
In: Computer Science
In C, write a function that inserts a new node by taking four arguments, a head, tail, current node, and new node pointers. If head is NULL, perform head insertion, otherwise transverse the linked list recursively by using current node pointer. Terminate when the current node points at the tail after inserting new node at tail and pointing tail at new node.
In: Computer Science
Please use C programming to write the code to solve the following problem. Also, please use the instructions, functions, syntax and any other required part of the problem. Thanks in advance. Use these functions below especially:
void inputStringFromUser(char *prompt, char *s, int arraySize);
void songNameDuplicate(char *songName);
void songNameFound(char *songName);
void songNameNotFound(char *songName);
void songNameDeleted(char *songName);
void artistFound(char *artist);
void artistNotFound(char *artist);
void printMusicLibraryEmpty(void);
void printMusicLibraryTitle(void);
const int MAX_LENGTH = 1024;
You will write a program that maintains information about your personal music library using a Linked List data structure. The program will allow you to add and delete entries from your personal music library, to search your personal music library for songs by song name, and to print out the entire list of your library. This lab will be due in the week of April 1.
Your Personal Music
Library. The data in your personal music library will be stored in
memory with the use of a linked list, with one list node per song.
Each node will contain three strings: a song’s name, its artist,
and its genre (the type of music). The linked list must be kept in
sorted alphabetical order, by song name, beginning with A through Z
(i.e. increasing alphabetical order). No two songs in your personal
music library should have the same name. Your program should be
“menu” driven, with the user being offered a choice of the
following five “commands”:
• Command I. Insert a new song into the library.
The program should prompt the user for a new song name, its
artist’s name, and its genre. This information must be placed in a
new node that has been created using the malloc function (to be
clear, you must use malloc for this purpose). This node should then
be inserted at the appropriate (alphabetical) position in the
linked list. Don’t forget that the music library must be stored in
increasing order, by song name. If a node with the given song name
is already in the music library, an error message should be output,
and the new node should not be inserted into the linked list.
• Command D. Delete an entry from your the
library. The program should prompt the user for the name of the
song to be deleted, and then find and delete the node containing
that song name from the library. If no node with the given song
name is found, an error message should be output. All memory
allocated for a deleted entry must be released back to the system
using the free function. This includes not only the memory
allocated for the node, but also the strings in the node that would
have been separately allocated.
• Command S. Search for a user supplied song name
in the library. The program should print the name, artist, and
genre of the song, with each piece of information on a separate
line. If no node with the given song name is found, an error
message should be output.
• Command P. Print your personal music library, in
alphabetical order by song name. Print the song name, artist, and
genre of each song, each on a separate line. A blank line should be
printed between each song.
• Command Q. Quit the program. When the program is
given the Q command, it should delete all of the nodes in the
linked list, including all the strings contained
in each node. Deletion
means both removing from the list, but also freeing all dynamically
allocated memory using call the free function. It should then print
the (what should be an empty) linked list.
To assist you in the production of your program, we have provided
you with a file, musiclibrary.c, that contains part of the complete
program. This program is provided on the course website along with
this lab. This “skeleton” of the lab 9 program includes all of the
C statements required to implement the menu driven parts of the
program. It also includes a few helpful functions for reading data
and printing messages. You should take this file and edit it to
become your version of Lab9.c. Note, however, that you may not
change any of the code in the existing implementation of the
skeleton program, except where indicated in comments. In
particular, you must use the inputStringFromUser()
function and the prompts provided to obtain inputs from the user,
and you must use the given Node structure. In addition we strongly
recommend that you do your work for this lab in the following
way:
• Read the entire skeleton program carefully. Take note of the
provided functions for reading strings, printing the name, artist
and genre of a song, and for printing error messages. Using these
functions will make it easier for you to satisfy the exercise and
marker programs.
• Add the function for inserting a new node(the I command) into the
linked list. Your function will need to read the name, artist, and
genre of a song. Test your program by trying to insert nodes into
the linked list. Try to insert nodes with both new and duplicate
song names.
• Add a function for printing the linked list (the P command). Test
your program by inserting songs into the linked list and then
printing them out. Are the entries in the correct order? • Add a
function that searches the linked list for a given song name and
then either prints the appropriate song or, if a node is not found,
prints an error message. This is the S command.
• Add the statements that need to be executed when the Q command is
entered. These statements should delete the linked list by using
calls to the free function. To check your work, print the linked
list after the elements have been deleted. • Add a function for
deleting a song from the personal music library. It will need to
search the linked list for a given song name, delete the
appropriate node from the linked list, and then use the free
function to release the memory used to store the node, as well as
all the memory that the node uses for storing strings. If the given
song name is not found in the music library, print an error
message.
We recommend that you test your program after attempting to
complete each step. This way, if your program no longer works, you
will know which statements are causing the error. Complete each
step before moving on to the next one.
Sample Output From
Executing The Program
Here is a sample output from an execution of the program that you
are to prepare.
Personal Music Library.
Commands are I (insert), D (delete), S (search by song name), P
(print), Q (quit).
Command --> P
The music library is empty.
Command --> I
Song name --> The Shade
Artist --> Metric
Genre --> Rock
Command --> I
Song name --> Heads Will Roll
Artist --> Yeah Yeah Yeahs
Genre --> Punk
Command --> I
Song name --> Bad Boys Need Love Too
Artist --> Bahamas (Afie Jurvanen)
Genre --> Folk
Command --> P
My Personal Music Library:
Bad Boys Need Love Too
Bahamas (Afie Jurvanen)
Folk
Heads Will Roll
Yeah Yeah Yeahs
Punk
The Shade
Metric
Rock
Command --> I
Song name --> Heads Will Roll
Artist --> Yeah Yeah Yeahs
Genre --> Punk
A song with the name 'Heads Will Roll' is already in the music
library.
No new song entered.
Command --> I
Song name --> Adult Diversion
Artist --> Alvvays
Genre --> Pop
Command --> P
My Personal Music Library:
Adult Diversion
Alvvays
Pop
Bad Boys Need Love Too
Bahamas (Afie Jurvanen)
Folk
Heads Will Roll
Yeah Yeah Yeahs
Punk
The Shade
Metric
Rock
Command --> S
Enter the name of the song to search for --> Bad Boys Need Love
Too
The song name 'Bad Boys Need Love Too' was found in the music
library.
Bad Boys Need Love Too
Bahamas (Afie Jurvanen)
Folk
Command --> S
Enter the name of the song to search for --> Young Blood
The song name 'Young Blood' was not found in the music
library.
Command --> D
Enter the name of the song to be deleted --> The Shade
Deleting a song with name 'The Shade' from the music library.
Command --> P
My Personal Music Library:
Adult Diversion
Alvvays
Pop
Bad Boys Need Love Too
Bahamas (Afie Jurvanen)
Folk
Heads Will Roll
Yeah Yeah Yeahs
Punk
Command --> Q
Deleting a song with name 'Adult Diversion' from the music
library.
Deleting a song with name 'Bad Boys Need Love Too' from the music
library.
Deleting a song with name 'Heads Will Roll' from the music
library.
The music library is empty.
In: Computer Science
You have 21 cards written from 1 to 21. The number K is inputted from a command window (using input command). First, please shuffle these 21 cards such that the sequence becomes random (using rand command). You need to make a function of New_Cards=shuffle(Orig_Card), where New_Cards is a 1X21 vector that has random sequence of the cards (Ex. New_Cards=[ 14 7 21 6….. 9 1 3 5 8]). When the first even number is greater than K, you should print in the command window saying that ‘You win!’, otherwise ‘You lost!’. K should be set as a global variable in the main cell. Please create a function of Output = game(New_Cards). Output is 1 when the first even number is greater than K, and it is 0 when the first even number is less than K.(Using Matlab)
In: Computer Science