Question

In: Computer Science

define aray and string?

define aray and string?

Solutions

Expert Solution

Array

Arrays are non-primitive data type which is used to store a sequence or set of data on any particular primitive or non-primitive data type. It is generally used to store the collection of data. Arrays can store data in various dimensions or axis forming 2D,3D...nD arrays storing complex data according to the memory available and compiler.

arrays can be declared like array_name[i], where i is the size and the range is from 0 to i-1.

Various operations can be performed on arrays like splitting parts of the input, mathematical operations on input, sorting, etc.

String

String is also a non-primitive data type which is used to store sequence or set of data. But it has its advantages over arrays that a string is not constrained to any particular data type, it can store values of any data type in a single variable as input. This unique property is possible as it stores the ASCII value of the inserted character or number.

String also doesn't have any limit or size constrain while declaration, it could easily store any length of the input.

As string data type can store and return any data type within it is most widely used for any operation.


Related Solutions

#include <bits/stdc++.h> using namespace std; string ltrim(const string &); string rtrim(const string &); #define BUFFLEN 10...
#include <bits/stdc++.h> using namespace std; string ltrim(const string &); string rtrim(const string &); #define BUFFLEN 10 /*     This code closely mimics the Python hash table we created in class this     week. Each "person" is defined by their name, zipcode, and their pet's name.     Persons are hashed by their zipcode. */ //---------------------------------------------------------------------------- /* function declarations ------------------------*/ int computeKey(int); void add_to_buffer(string,int,string); void find_in_buffer(int); //---------------------------------------------------------------------------- /* define a "person" --------------------*/ class person{     public:     // variables that define a person     string name;     int zipcode;...
Define a sequence of string of 0’s and 1’s: 1 The first string, s0, is just...
Define a sequence of string of 0’s and 1’s: 1 The first string, s0, is just the empty string "". The second string, s1, is 1. The third, fourth, fifth, . . . strings are defined as follows: si = si−11ti−1 where ti−1 is the reverse of si−1 with all 0s replaced by 1s and all 1s replaced by 0s. The first few strings are s0 = "", s1 = 1, s2 = 110, s3 = 1101100, s4 = 110110011100100....
python 3 please Define a function voweliest that takes as input a string and returns as...
python 3 please Define a function voweliest that takes as input a string and returns as output a tuple where the string that has the most vowels in it is the first element and the second is the number of vowels in that string. Note: don't worry about ties or capital letters Hint: consider defining and using a separate function that counts the number of vowels in a given string
C++ Please Define a function named "isAscending" that accepts a string as an input parameter and...
C++ Please Define a function named "isAscending" that accepts a string as an input parameter and returns "true" if all the characters included in the string are ordered in ascending order of their ASCII codes or the input string is a null string, and returns "false" otherwise. For example, if the string "ABXab" is passed to the function, it returns "true" because the ASCII code of 'B' is greater than 'A', 'X' is greater than 'B', 'a' is greater than...
Define a class named Document that contains an instance variable of type String named text that...
Define a class named Document that contains an instance variable of type String named text that stores any textual content for the document. Create a method named toString that returns the text field and also include a method to set this value. Next, define a class for Email that is derived from Document and includes instance variables for the sender, recipient, and title of an email message. Implement appropriate set and get methods. The body of the email message should...
a. Define a function less of type (String, List) -> List so that less(e, L) is...
a. Define a function less of type (String, List) -> List so that less(e, L) is a list of all the strings in L that are shorter than e. b. Define a function more of type (String, List) -> List so that more(e, L) is a list of all the strings in L that are longer than e. c. Replace the above functions with a function compare of type (String, List, (String, String) -> Boolean) such that depending on the...
<Haskell> Using getCh, define an action readLine :: IO String that behaves in the same way...
<Haskell> Using getCh, define an action readLine :: IO String that behaves in the same way as getLine, except that it also permits the delete key to be used to remove characters. Hint: the delete character is ’\DEL’, and the control character for moving the cursor back one space is ’\b’.
Define a function file_to_hist() which takes a string representing a filename, opens the file, reads its...
Define a function file_to_hist() which takes a string representing a filename, opens the file, reads its contents, closes the file,* and returns a histogram based on the letter frequencies in the given file. If no such file exists, your function should return an empty histogram (i.e., an empty dictionary {}). So for example, if the file nash.txt was in the same directory as char_hist3.py and had the following contents: I have never seen a purple cow, And I never hope...
Meant to be written in Java JDK 14.0 4. Define 2 String variables str1 and str2,...
Meant to be written in Java JDK 14.0 4. Define 2 String variables str1 and str2, get input from console and assign input to str1 and str2. (a) Display the length of str1 and str2 (b) Display the first and last characters in str1 and str2 (c) Compare str1 and str2 to check if they are equal or not: (1) The comparison is case sensitive (2) The comparison is case insensitive (d) Compare str1 with str2 to check which string...
Draw UML diagram Define a class named Document that contains a member variable of type string...
Draw UML diagram Define a class named Document that contains a member variable of type string named text that stores any textual content for the document. Create a function named getText that returns the text field and a way to set this value. Next, define a class for Email that is derived from Document and that includes member variables for the sender , recipient , and title of an e-mail message. Implement appropriate accessor and mutator functions. The body of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT