answersLogoWhite

0


Best Answer

Stack

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What data structures is most efficient in terms of both space and time to reverse a string of characters?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Computer Science

A string of characters that unlock the door into your computer is called what?

omg cheater.


What is a search string?

If I opened WikiAnswers on the internet and inside the "ask window" I put the question, "What is a search string?", that phrase, the part inside the quote, would become "the search string". Computers are quite efficient at searching for patterns in large databases. When the computer finds the specified search string, this answer would be displayed. I just verified it, and that's exactly what it does. RB


What is the difference between numeric and string variables?

Numeric variables store numbers for doing mathematics, counting etc.. String variables store printable sets of characters that can be read by humans in what ever language. int i=3; /* a numeric variable in c */ char *hello = "Hello world, Im 3 years old" /* string that contains a number */ Computer languages generally provide many different ways to transform one into the other.


How do you compare strings?

In most programming languages you will be relying on pre-existing library functions for all your string comparison needs.The algorithm is:Consider both strings as arrays of characters (depending on the language, they will either have a specified maximum length, eg in Pascal or a terminating symbol - usually a zero - eg in C and C++)Iterator n represents the position in the character string, with its' initial value representing the first index in the array. If the language permits it, you can use pointer arithmetic instead.For each character in a string:Take the n-th character from string 1Take the n-th character from string 2Compare both characters (the exact comparison method may vary)If not equal, return falseIncrease n by 1If reached end of string, return trueHere is an example function in C (returning a 1 if the strings are identical, 0 if not). This implementation forgoes use of an iterator in favor of pointer arithmetic and comparison in favor of XORing the characters with each other (a XOR of identical values returns a zero):int string_compare(char* a, char* b){while (*a){if (*a++^*b++) return 0;}return 1;}


What is a connection string used for in computers?

A connection string in computing is a string that specifies how to connect to a data source and information about the data source. It is commonly used in database files.

Related questions

Which of the data structures is most efficient in terms of both space and time to reverse a string characters?

stack


How do you get value of a string in reverse order in c?

Assume C#, not C: Traditional way: public string Reverse(string s) { if (string.IsNullOrEmpty(s)) return s; // "" or null char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } or as an extension method: public static string Reverse(this string s) { if (s == "") return ""; char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } The differences of the 2 methods above is on the caller (how to use Reverse()), and they may co-exist: For example: string test = "abc"; string result1 = Reverse(test); // traditional way string result2 = test.Reverse(); // call the extension


What is the complexity of reverse the input string using stack?

O(n*2) for n characters. It is more efficient to simply walk from both ends of the string, swapping characters as you go, reducing the complexity to just O(n/2).


How do you convert a number that consist of alphabet and number in reverse order?

To reverse a number, first convert the number to a string, then reverse the string. Given your number consists of alphanumeric characters, the number must already be a string so simply reverse the string: #include<string> using std::string; string reverse (const string& s) { string str {}; for (auto c : s) str.insert (str.begin(), c); return str; } int main () { std::cout << "Enter a number: "; string s {}; std::cin >> s; std::cout << "The number in reverse is: " << reverse (s); }


What is the use of Reverse String in C program?

The use of the reverse string in C program is used to reverse the letters in the string. An example would be reverse me would be reversed to em esrever.


How do you create a string and reverse a string in vb?

gov


How do you reverse a string in PHP?

A predefined function can reverse a string as shown below:echo strrev('pizza'); // outputs: azzip


What elements are in string?

A string is an array of characters.


How to write a program in python to print the reverse of a number?

In python, type the following into a document. NOTE: Sentences following a # symbol are comments, and are not necessary for the program to run. #!/usr/bin/python #This program takes a input from a user and reverses it. number = input("Type a number: ") #This takes input from a user. a = len(number) #This finds the length of the number reverse = "" #This sets the variable reverse to an empty string. for i in number: a = a-1 #The places in a string start from 0. The last value will be the length minus 1.reverse = reverse + number[a] #Makes the number's last digit the new string's first. print("The reverse of", number, "is", reverse + ".") #prints the resulting string. This program will take any sequence of characters and reverse them. The final value is a string, but if an integer is needed, one needs only to add the line reverse = int(reverse) above the print statement. However, this will stop the program from being able to reverse strings, as it is not possible to convert a string to an integer if it is not a number.


How do you Print all the first characters in the string in python programming?

Let's say your string is a variable called "string" To print out all the characters in order, you would do: for i in string: print(string[i]) If you wanted to print out characters up to a point (n = maximum characters): for i in range(n): print(string[i]) hope this helps!


How do you write string in reverse through the HTML tags?

Not possible through html. Use php strrev function. For eg:


Reverse of a string without using string handling function?

shashi