logic
.cpp
keyboard_arrow_up
School
Texas A&M University *
*We aren’t endorsed by this school
Course
121
Subject
Computer Science
Date
Jun 13, 2024
Type
cpp
Pages
6
Uploaded by CoachElement14434
#include <iostream>
#include <fstream>
#include <string>
#include "logic.h"
using std::cout, std::endl, std::ifstream, std::string;
/**
* TODO: Student implement this function
* Load representation of the dungeon level from file into the 2D map.
* Calls createMap to allocate the 2D array.
* @param fileName File name of dungeon level.
* @param maxRow Number of rows in the dungeon table (aka height).
* @param maxCol Number of columns in the dungeon table (aka width).
* @param player Player object by reference to set starting position.
* @return pointer to 2D dynamic array representation of dungeon map with player's
location., or nullptr if loading fails for any reason
* @updates maxRow, maxCol, player
*/
char** loadLevel(const string& fileName, int& maxRow, int& maxCol, Player& player) {
bool valid = false;
ifstream input_file(fileName);
if (!input_file.is_open()){
return nullptr;
}if (!(input_file>> maxRow >> maxCol)){ return nullptr;
}if (maxRow <= 0 || maxCol <= 0 || maxRow > (INT32_MAX/maxCol) || maxCol > 999999 || maxRow > 999999){
return nullptr;
}
char** gamemap = createMap(maxRow, maxCol);
if (!gamemap){
return nullptr;
}
if(!(input_file >> player.row >> player.col)){
return nullptr;
}if ( player.col < 0 || player.col >= maxCol || player.row<0 || player.row >= maxRow){
deleteMap(gamemap, maxRow);
return nullptr;
}
for (int row = 0; row < maxRow; ++row){
for(int col = 0; col < maxCol; ++col){
char tile;
if (!(input_file >> tile)){
deleteMap(gamemap, maxRow);
return nullptr;
}
gamemap[row][col]=tile;
if(!(tile == TILE_AMULET || tile == TILE_EXIT || tile == TILE_MONSTER || tile == TILE_DOOR || tile == TILE_OPEN || tile == TILE_PILLAR || tile == TILE_TREASURE)){
deleteMap(gamemap, maxRow);
return nullptr;
}if (tile == TILE_EXIT || tile == TILE_DOOR){
valid = true;
}
}
} if (valid == false){
deleteMap(gamemap, maxRow);
return nullptr;
}
char extravalue;
if (input_file >> extravalue){
deleteMap(gamemap, maxRow);
return nullptr;
}if (gamemap[player.row][player.col] == TILE_OPEN){
gamemap[player.row][player.col] = TILE_PLAYER;
}else{
deleteMap(gamemap, maxRow);
return nullptr;
}
input_file.close();
return gamemap;
}
/**
* TODO: Student implement this function
* Translate the character direction input by the user into row or column change.
* That is, updates the nextRow or nextCol according to the player's movement direction.
* @param input Character input by the user which translates to a direction.
* @param nextRow Player's next row on the dungeon map (up/down).
* @param nextCol Player's next column on dungeon map (left/right).
* @updates nextRow, nextCol
*/
void getDirection(char input, int& nextRow, int& nextCol) {
if(input == MOVE_UP){
nextRow += -1;
nextCol += 0;
}else if(input == MOVE_DOWN){
nextRow += 1;
nextCol += 0;
}else if(input == MOVE_LEFT){
nextCol += -1;
nextRow += 0;
}else if(input == MOVE_RIGHT){
nextCol += 1;
nextRow += 0;
}else{
nextCol += 0;
nextRow += 0;
}
}
/**
* TODO: [suggested] Student implement this function
* Allocate the 2D map array.
* Initialize each cell to TILE_OPEN.
* @param maxRow Number of rows in the dungeon table (aka height).
* @param maxCol Number of columns in the dungeon table (aka width).
* @return 2D map array for the dungeon level, holds char type.
*/
char** createMap(int maxRow, int maxCol) {
if(maxCol <= 0 || maxRow <= 0){
return nullptr;
}
char** gamemap = new char*[maxRow];
for (int row = 0; row < maxRow; ++row){
gamemap[row] = new char [maxCol];
}for (int row = 0; row < maxRow; row++){
for(int col = 0; col < maxCol; col++){
gamemap[row][col] = TILE_OPEN;
}
}
return gamemap;
}
/**
* TODO: Student implement this function
* Deallocates the 2D map array.
* @param map Dungeon map.
* @param maxRow Number of rows in the dungeon table (aka height).
* @return None
* @update map, maxRow
*/
void deleteMap(char**& map, int& maxRow) {
if((map != nullptr) && (maxRow >0)){
for(int row = 0; row < maxRow; row++){
delete[] map[row];
}
delete[] map;
}
map = nullptr;
maxRow = 0;
}
/**
* TODO: Student implement this function
* Resize the 2D map by doubling both dimensions.
* Copy the current map contents to the right, diagonal down, and below.
* Do not duplicate the player, and remember to avoid memory leaks!
* You can use the STATUS constants defined in logic.h to help!
* @param map Dungeon map.
* @param maxRow Number of rows in the dungeon table (aka height), to be doubled.
* @param maxCol Number of columns in the dungeon table (aka width), to be doubled.
* @return pointer to a dynamically-allocated 2D array (map) that has twice as many columns and rows in size.
* @update maxRow, maxCol
*/
char** resizeMap(char** map, int& maxRow, int& maxCol) {
int nuevomax_row = maxRow * 2;
int nuevomax_col = maxCol * 2;
if (map == nullptr || maxCol < 1 || maxRow < 1){
return nullptr;
}
char** new_map = createMap(nuevomax_row, nuevomax_col);
for (int row = 0; row < maxRow; row++){
for (int col = 0; col < maxCol; col++){
new_map[row][col] = map[row][col];
if (map[row][col] == TILE_PLAYER){
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Doctor
-signature:String
-doctorID:int
- medicine:Arraylist
+Doctor(signature:String,doctorID:int)
+PrescribeMedicine():void
+ salary ()
+checkRecords():void
Medicine
Pharmacist
-medName:String
-startTime:int
-dosage :int
-endTime:int
-date_prescribed:int
- medicine:Arraylist
+Medicine(medName:String,-dosage :int,date_prescribed:int)
+Pharmacist (startTime:int,endTime:int)
+checkForConflict():double
+confirm_prescription():String
+getStartTime():int
+getEndTime():int
+setStartTime(time:int):void
+setEndTime(time1:int).void
arrow_forward
c++
arrow_forward
Concatenate Map
This function will be given a single parameter known as the Map List. The Map List is a list of maps. Your job is to combine all the maps found in the map list into a single map and return it. There are two rules for addingvalues to the map.
You must add key-value pairs to the map in the same order they are found in the Map List. If the key already exists, it cannot be overwritten. In other words, if two or more maps have the same key, the key to be added cannot be overwritten by the subsequent maps.
Signature:
public static HashMap<String, Integer> concatenateMap(ArrayList<HashMap<String, Integer>> mapList)
Example:
INPUT: [{b=55, t=20, f=26, n=87, o=93}, {s=95, f=9, n=11, o=71}, {f=89, n=82, o=29}]OUTPUT: {b=55, s=95, t=20, f=26, n=87, o=93}
INPUT: [{v=2, f=80, z=43, k=90, n=43}, {d=41, f=98, y=39, n=83}, {d=12, v=61, y=44, n=30}]OUTPUT: {d=41, v=2, f=80, y=39, z=43, k=90, n=43}
INPUT: [{p=79, b=10, g=28, h=21, z=62}, {p=5, g=87, h=38}, {p=29,…
arrow_forward
Unique Words
Summary Specifications:You are tasked to implement an abstract data type class which takes in a given input file called input.txt, and processes, identifies and sorts all unique word instances found in the file.
Sample InputHi hello hi good bye goodbye Bye bye good say
Sample OutputBye Hi bye hello hi say
The input.txt file is found along with the zip folder where this instructions file also came along with.
Note: you are not allowed to use pythonic lists, and its methods and functions, and string methods.
However the use of the file handling methods (read readlines and readline) are allowed for this project.
arrow_forward
Q3 / create multiple graphs
with single call to plot,
these statements plot three
related functions of x : t1
= 2sinc (x), t2 = sinc (x),
and t3 = 0.5sinc (x), in
the interval O < x < 2n . The
graphs must be contain
desired title , axis labels , and
annotations , with symbols
for color , style , and marker
respectively.
arrow_forward
main.cc file
#include <iostream>#include <memory>
#include "train.h"
int main() { // Creates a train, with the locomotive at the front of the train. // LinkedList diagram: // Locomotive -> First Class -> Business Class -> Cafe Car -> Carriage 1 -> // Carriage 2 std::shared_ptr<Train> carriage2 = std::make_shared<Train>(100, 100, nullptr); std::shared_ptr<Train> carriage1 = std::make_shared<Train>(220, 220, carriage2); std::shared_ptr<Train> cafe_car = std::make_shared<Train>(250, 250, carriage1); std::shared_ptr<Train> business_class = std::make_shared<Train>(50, 50, cafe_car); std::shared_ptr<Train> first_class = std::make_shared<Train>(20, 20, business_class); std::shared_ptr<Train> locomotive = std::make_shared<Train>(1, 1, first_class);
std::cout << "Total passengers in the train: "; // =================== YOUR CODE HERE…
arrow_forward
class BinaryImage:
def __init__(self):
pass
def compute_histogram(self, image):
"""Computes the histogram of the input image
takes as input:
image: a grey scale image
returns a histogram as a list"""
hist = [0]*256
return hist
def find_otsu_threshold(self, hist):
"""analyses a histogram it to find the otsu's threshold assuming that the input hstogram is bimodal histogram
takes as input
hist: a bimodal histogram
returns: an optimal threshold value (otsu's threshold)"""
threshold = 0
return threshold
def binarize(self, image):
"""Comptues the binary image of the the input image based on histogram analysis and thresholding
take as input
image: an grey scale image
returns: a binary image"""
bin_img = image.copy()
return…
arrow_forward
What function does this Syntax perform?
function myMap() {var map Canvas = document.getElementById("map");var mapOptions = {center: new google.maps.LatLng(51.5, -0.2),zoom: 10};var map = new google.maps.Map(mapCanvas, mapOptions);}
arrow_forward
Bar Graph, v 1.0
Purpose. The purpose of this lab is to produce a bar graph showing the population growth of a
city called Prairieville, California. The bar graph should show the population growth of the city
in 20 year increments for the last 100 years. The bar graph should be printed using a loop. The
loop can be either a while loop or a for loop.
Write a program called cityPopulation Graph.cpp to produce the bar graph.
Requirements.
1. Use these population values with their corresponding years:
1922, 2000 people
1942, 5000 people
1962, 6000 people
1982, 9000 people
2002, 14,000 people
2012, 15,000 people
2022, 17,000 people
2. For each year, the program should display the year with a bar consisting of one asterisk for
each 1000 people.
3. Each time the loop is performed (that is, each time the loop iterates) one of
the year values is displayed with asterisks next to it. That is:
1st time loop is performed/iterates the year 1922 and the correct number of asterisks
should be…
arrow_forward
Fix an error and show it please?
arrow_forward
flip_matrix(mat:list)->list
You will be given a single parameter a 2D list (A list with lists within it) this will look like a 2D matrix when printed out, see examples below. Your job is to flip the matrix on its horizontal axis. In other words, flip the matrix horizontally so that the bottom is at top and the top is at the bottom. Return the flipped matrix.
To print the matrix to the console:
print('\n'.join([''.join(['{:4}'.format(item) for item in row]) for row in mat]))
Example:
Matrix:
W R I T X
H D R L G
L K F M V
G I S T C
W N M N F
Expected:
W N M N F
G I S T C
L K F M V
H D R L G
W R I T X
Matrix:
L C
S P
Expected:
S P
L C
Matrix:
A D J
A Q H
J C I
Expected:
J C I
A Q H
A D J
arrow_forward
C++
arrow_forward
A map interface's list collection views
arrow_forward
Write the definitions of the functions to overload the assignment operator and copy constructor for the class queueType.
Also, write a program (in main.cpp) to test these operations.
HEADER FILE FOR queueAsArray.h
//Header file QueueAsArray
#ifndef H_QueueAsArray
#define H_QueueAsArray
#include<iostream>
#include <cassert>
#include "queueADT.h"
using namespace std;
template <class Type>
class queueType: public queueADT<Type>
{
public:
const queueType<Type>& operator=(const queueType<Type>&);
//Overload the assignment operator.
bool isEmptyQueue() const;
//Function to determine whether the queue is empty.
//Postcondition: Returns true if the queue is empty,
// otherwise returns false.
bool isFullQueue() const;
//Function to determine whether the queue is full.
//Postcondition: Returns true if the queue is full,
// otherwise returns false.
void initializeQueue();
//Function to initialize the queue to an empty state.
//Postcondition:…
arrow_forward
# define stemmer functionstemmer = SnowballStemmer('english')
# tokenise datatokeniser = TreebankWordTokenizer()tokens = tokeniser.tokenize(data)
# define lemmatiserlemmatizer = WordNetLemmatizer()
# bag of wordsdef bag_of_words_count(words, word_dict={}): """ this function takes in a list of words and returns a dictionary with each word as a key, and the value represents the number of times that word appeared""" for word in words: if word in word_dict.keys(): word_dict[word] += 1 else: word_dict[word] = 1 return word_dict
# remove stopwordstokens_less_stopwords = [word for word in tokens if word not in stopwords.words('english')]
# create bag of wordsbag_of_words = bag_of_words_count(tokens_less_stopwords)
Use the stemmer and lemmatizer functions (defined in the cells above) from the relevant library to find the stem and lemma of the nth word in the token list.
Function Specifications:
Should take a list as input and…
arrow_forward
A "generic" data structure cannot use a primitive type as its generic type.
O True
False
arrow_forward
Two-dimensional list tictactoe represents a 3x3 tic-tac-toe game board read from input. List tictactoe contains three lists, each representing a row. Each list has three elements representing the three columns on the board. Each element in the tic-tac-toe game board is 'x', 'o', or '-'.
If all the elements at column index 0 are 'o', output 'A win at column 0.' Otherwise, output 'No win at column 0.'
arrow_forward
Bishops on a binge def safe_squares_bishops(n, bishops):
A generalized n-by-n chessboard has been taken over by some bishops, each represented as a tuple (row, column) of the row and the column of the square the bishop stands on. Same as in the earlier version of this problem with rampaging rooks, the rows and columns are numbered from 0 to n - 1. Unlike a chess rook whose moves are axis-aligned, a chess bishop covers all squares that are on the same diagonal with that bishop arbitrarily far into any of the four diagonal compass directions. Given the board size n and the list of bishops on that board, count the number of safe squares that are not covered by any bishop.
To determine whether two squares (r1, c1) and (r2, c2) are reachable from each other in one diagonal move, use abs(r1-r2) == abs(c1-c2) to check whether the horizontal distance between those squares equals their vertical distance, which is both necessary and sufficient for the squares to lie on the same diagonal. This…
arrow_forward
#include <bits/stdc++.h>#include<unordered_map>#include <string>
using namespace std;
struct Student{string firstName;string lastName;string studentId;double gpa;};
class MyClass{public:unordered_map<string, int>classHoursInfo;vector<Student> students;unordered_map<string, int> creditValue = {{"A", 4}, {"B", 3}, {"C", 2}, {"D", 1}, {"F", 0}};
void readStudentData(string filepath){cout << "reading student data \n";ifstream inpStream(filepath);string text;string tmp[4];while (getline (inpStream, text)) {string str = "", prevKey = ""; int j= 0;unordered_map<string, int> curStudentClassInfo;for(int i=0; i<text.length(); i++){if(isspace(text[i])){if(j>3){if(prevKey.length()==0){curStudentClassInfo[str] = 0;prevKey = str;str.clear();}else{curStudentClassInfo[prevKey] = creditValue[str];prevKey = "";str.clear();}}else{tmp[j++] = str;str.clear();}}else{str = str+text[i];}}if(str.length() != 0){curStudentClassInfo[prevKey] =…
arrow_forward
Q8 Hive Minds: Migrating Birds
You again control a single insect, but there are B birds flying along known paths. Specifically, at
time t each bird b will be at position (x¿(t), Yb(t)). The tuple of bird positions repeats with
period T. Birds might move up to 3 squares per time step. An example is shown below, but
keep in mind that you should answer for a general instance of the problem, not simply the map
and path shown below.
Your insect can share squares with birds and it can even hitch a ride on them!
On any time step that your insect shares a square with a bird, the insect may
either move as normal or move directly to the bird's next location (either
action has cost 1, even if the bird travels farther than one square).
arrow_forward
using namespace std;
class SinglyLinkedListNode {
// INSERT YOUR CODE HERE
};
class SinglyLinkedList {
public:
SinglyLinkedListNode *head;
SinglyLinkedListNode *tail;
SinglyLinkedList() {
this->head = nullptr;
this->tail = nullptr;
}
voidinsert_node(intnode_data) {
// INSERT YOUR CODE HERE
}
};
void free_singly_linked_list(SinglyLinkedListNode* node) {
// INSERT YOUR CODE HERE
}
// Complete the has_cycle function below.
/*
* For your reference:
*
* SinglyLinkedListNode {
* int data;
* SinglyLinkedListNode* next;
* };
*
*/
bool has_cycle(SinglyLinkedListNode* head) {
SinglyLinkedListNode* temp = head;
bool isCycle = false;
while (temp != nullptr)
{
// INSERT YOUR CODE HERE
}
}
int main()
{
// INSERT YOUR CODE HERE TO TEST YOUR CODE
return0;
}
arrow_forward
using namespace std;
class SinglyLinkedListNode {
// INSERT YOUR CODE HERE
};
class SinglyLinkedList {
public:
SinglyLinkedListNode *head;
SinglyLinkedListNode *tail;
SinglyLinkedList() {
this->head = nullptr;
this->tail = nullptr;
}
voidinsert_node(intnode_data) {
// INSERT YOUR CODE HERE
}
};
void free_singly_linked_list(SinglyLinkedListNode* node) {
// INSERT YOUR CODE HERE
}
// Complete the has_cycle function below.
/*
* For your reference:
*
* SinglyLinkedListNode {
* int data;
* SinglyLinkedListNode* next;
* };
*
*/
bool has_cycle(SinglyLinkedListNode* head) {
SinglyLinkedListNode* temp = head;
bool isCycle = false;
while (temp != nullptr)
{
// INSERT YOUR CODE HERE
}
}
int main()
{
// INSERT YOUR CODE HERE TO TEST YOUR CODE
return0;
}
arrow_forward
Strings all_colors and updated_value are read from input. Perform the following tasks:
Split all_colors into tokens using a comma (',') as the separator and assign color_list with the result.
Replace the first element in color_list with updated_value.
arrow_forward
CONVERT TO USE CASE DIAGRAM
arrow_forward
C++ program Reverse Phone Book
you are given map<string,int> object named phone_book. write a program that produces a map<int,set<string>> object from it named reverse_phone_book.The data is that for each phone number, the reverse phone book contains all the names who have that phone number.
arrow_forward
String Pair
// Problem Description
// One person hands over the list of digits to Mr. String, But Mr. String understands only strings. Within strings also he understands only vowels. Mr. String needs your help to find the total number of pairs which add up to a certain digit D.
// The rules to calculate digit D are as follow
// Take all digits and convert them into their textual representation
// Next, sum up the number of vowels i.e. {a, e, i, o, u} from all textual representation
// This sum is digit D
// Now, once digit D is known find out all unordered pairs of numbers in input whose sum is equal to D. Refer example section for better understanding.
// Constraints
// 1 <= N <= 100
// 1 <= value of each element in second line of input <= 100
// Number 100, if and when it appears in input should be converted to textual representation as hundred and not as one hundred. Hence number…
arrow_forward
True or true: False or true: Map-reduce is just applications.
arrow_forward
C Language
Title : Tennis Game
arrow_forward
dict_graph = {}
# Read the data.txt file
with open('data.txt', 'r') as f:
for l in f:
city_a, city_b, p_cost = l.split()
if city_a not in dict_graph:
dict_graph[city_a] = {}
dict_graph[city_a][city_b] = int(p_cost)
if city_b not in dict_graph:
dict_graph[city_b] = {}
dict_graph[city_b][city_a] = int(p_cost)
# Breadth First Search Method
def BreadthFirstSearch(graph, src, dst):
q = [(src, [src], 0)]
visited = {src}
while q:
(node, path, cost) = q.pop(0)
for temp in graph[node].keys():
if temp == dst:
return path + [temp], cost + graph[node][temp]
else:
if temp not in visited:
visited.add(temp)
q.append((temp, path + [temp], cost + graph[node][temp]))
# Depth First Search Method
def DepthFirstSearch(graph, src, dst):
stack = [(src, [src], 0)]
visited = {src}
while stack:…
arrow_forward
Language is C++
arrow_forward
Data structure/ C language / Graph / Dijkstra’s algorithm
implement a solution of a very common issue: how to get from one town to another using the shortest route.* design a solution that will let you find the shortest paths between two input points in a graph, representing cities and towns, using Dijkstra’s algorithm. Your program should allow the user to enter the input file containing information of roads connecting cities/towns. The program should then construct a graph based on the information provided from the file. The user should then be able to enter pairs of cities/towns and the algorithm should compute the shortest path between the two cities/towns entered.Attached a file containing a list of cities/towns with the following data:Field 1: Vertex ID of the 1st end of the segmentField 2: Vertex ID of the 2nd of the segmentField 3: Name of the townField 4: Distance in Kilometer Please note that all roads are two-ways. Meaning, a record may represent both the roads from…
arrow_forward
struct insert_into_hash_table {
// Function takes a constant Book as a parameter, inserts that book indexed by
// the book's ISBN into a hash table, and returns nothing.
void operator()(const Book& book) {
/////
/// TO-DO (8) ||||.
// Write the lines of code to insert the key (book's ISBN) and value
// ("book") pair into "my_hash_table".
/// END-TO-DO (8) //
}
std::unordered_map& my_hash_table;
};
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- Doctor -signature:String -doctorID:int - medicine:Arraylist +Doctor(signature:String,doctorID:int) +PrescribeMedicine():void + salary () +checkRecords():void Medicine Pharmacist -medName:String -startTime:int -dosage :int -endTime:int -date_prescribed:int - medicine:Arraylist +Medicine(medName:String,-dosage :int,date_prescribed:int) +Pharmacist (startTime:int,endTime:int) +checkForConflict():double +confirm_prescription():String +getStartTime():int +getEndTime():int +setStartTime(time:int):void +setEndTime(time1:int).voidarrow_forwardc++arrow_forwardConcatenate Map This function will be given a single parameter known as the Map List. The Map List is a list of maps. Your job is to combine all the maps found in the map list into a single map and return it. There are two rules for addingvalues to the map. You must add key-value pairs to the map in the same order they are found in the Map List. If the key already exists, it cannot be overwritten. In other words, if two or more maps have the same key, the key to be added cannot be overwritten by the subsequent maps. Signature: public static HashMap<String, Integer> concatenateMap(ArrayList<HashMap<String, Integer>> mapList) Example: INPUT: [{b=55, t=20, f=26, n=87, o=93}, {s=95, f=9, n=11, o=71}, {f=89, n=82, o=29}]OUTPUT: {b=55, s=95, t=20, f=26, n=87, o=93} INPUT: [{v=2, f=80, z=43, k=90, n=43}, {d=41, f=98, y=39, n=83}, {d=12, v=61, y=44, n=30}]OUTPUT: {d=41, v=2, f=80, y=39, z=43, k=90, n=43} INPUT: [{p=79, b=10, g=28, h=21, z=62}, {p=5, g=87, h=38}, {p=29,…arrow_forward
- Unique Words Summary Specifications:You are tasked to implement an abstract data type class which takes in a given input file called input.txt, and processes, identifies and sorts all unique word instances found in the file. Sample InputHi hello hi good bye goodbye Bye bye good say Sample OutputBye Hi bye hello hi say The input.txt file is found along with the zip folder where this instructions file also came along with. Note: you are not allowed to use pythonic lists, and its methods and functions, and string methods. However the use of the file handling methods (read readlines and readline) are allowed for this project.arrow_forwardQ3 / create multiple graphs with single call to plot, these statements plot three related functions of x : t1 = 2sinc (x), t2 = sinc (x), and t3 = 0.5sinc (x), in the interval O < x < 2n . The graphs must be contain desired title , axis labels , and annotations , with symbols for color , style , and marker respectively.arrow_forwardmain.cc file #include <iostream>#include <memory> #include "train.h" int main() { // Creates a train, with the locomotive at the front of the train. // LinkedList diagram: // Locomotive -> First Class -> Business Class -> Cafe Car -> Carriage 1 -> // Carriage 2 std::shared_ptr<Train> carriage2 = std::make_shared<Train>(100, 100, nullptr); std::shared_ptr<Train> carriage1 = std::make_shared<Train>(220, 220, carriage2); std::shared_ptr<Train> cafe_car = std::make_shared<Train>(250, 250, carriage1); std::shared_ptr<Train> business_class = std::make_shared<Train>(50, 50, cafe_car); std::shared_ptr<Train> first_class = std::make_shared<Train>(20, 20, business_class); std::shared_ptr<Train> locomotive = std::make_shared<Train>(1, 1, first_class); std::cout << "Total passengers in the train: "; // =================== YOUR CODE HERE…arrow_forward
- class BinaryImage: def __init__(self): pass def compute_histogram(self, image): """Computes the histogram of the input image takes as input: image: a grey scale image returns a histogram as a list""" hist = [0]*256 return hist def find_otsu_threshold(self, hist): """analyses a histogram it to find the otsu's threshold assuming that the input hstogram is bimodal histogram takes as input hist: a bimodal histogram returns: an optimal threshold value (otsu's threshold)""" threshold = 0 return threshold def binarize(self, image): """Comptues the binary image of the the input image based on histogram analysis and thresholding take as input image: an grey scale image returns: a binary image""" bin_img = image.copy() return…arrow_forwardWhat function does this Syntax perform? function myMap() {var map Canvas = document.getElementById("map");var mapOptions = {center: new google.maps.LatLng(51.5, -0.2),zoom: 10};var map = new google.maps.Map(mapCanvas, mapOptions);}arrow_forwardBar Graph, v 1.0 Purpose. The purpose of this lab is to produce a bar graph showing the population growth of a city called Prairieville, California. The bar graph should show the population growth of the city in 20 year increments for the last 100 years. The bar graph should be printed using a loop. The loop can be either a while loop or a for loop. Write a program called cityPopulation Graph.cpp to produce the bar graph. Requirements. 1. Use these population values with their corresponding years: 1922, 2000 people 1942, 5000 people 1962, 6000 people 1982, 9000 people 2002, 14,000 people 2012, 15,000 people 2022, 17,000 people 2. For each year, the program should display the year with a bar consisting of one asterisk for each 1000 people. 3. Each time the loop is performed (that is, each time the loop iterates) one of the year values is displayed with asterisks next to it. That is: 1st time loop is performed/iterates the year 1922 and the correct number of asterisks should be…arrow_forward
- Fix an error and show it please?arrow_forwardflip_matrix(mat:list)->list You will be given a single parameter a 2D list (A list with lists within it) this will look like a 2D matrix when printed out, see examples below. Your job is to flip the matrix on its horizontal axis. In other words, flip the matrix horizontally so that the bottom is at top and the top is at the bottom. Return the flipped matrix. To print the matrix to the console: print('\n'.join([''.join(['{:4}'.format(item) for item in row]) for row in mat])) Example: Matrix: W R I T X H D R L G L K F M V G I S T C W N M N F Expected: W N M N F G I S T C L K F M V H D R L G W R I T X Matrix: L C S P Expected: S P L C Matrix: A D J A Q H J C I Expected: J C I A Q H A D Jarrow_forwardC++arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education