1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Makovka662 [10]
3 years ago
14

Suppose we have two String objects and treat the characters in each string from beginning to end in the following way: With one

string, we push each character on a stack. With the other string, we add each character to a queue. After processing both strings, we then pop one character from the stack and remove one character from the queue, and compare the pair of characters to each other. We do this until the stack and the queue are both empty. What does it mean if all the character pairs match?
Computers and Technology
1 answer:
Simora [160]3 years ago
6 0

Answer:

If all the character pairs match after processing both strings, one string in stack and the other in queue, then this means one string is the reverse of the other.                            

Explanation:

Lets take an example of two strings abc and cba which are reverse of each  other.

string1 = abc

string2 = cba

Now push the characters of string1 in stack. Stack is a LIFO (last in first out) data structure which means the character pushed in the last in stack is popped first.

Push abc each character on a stack in the following order.

c

b

a

Now add each character of string2 in queue. Queue is a FIFO (first in first out) data structure which means the character inserted first is removed first.

Insert cba each character on a stack in the following order.

a   b   c

First c is added to queue then b and then a.

Now lets pop one character from the stack and remove one character from queue and compare each pair of characters of both the strings to each other.

First from stack c is popped as per LIFO and c is removed from queue as per FIFO. Then these two characters are compared. They both match

c=c. Next b is popped from stack and b is removed from queue and these characters match too. At the end a is popped from the stack and a is removed from queue and they both are compared. They too match which shows that string1 and string2 which are reverse of each other are matched.

You might be interested in
When you are making multiples of a brownie recipe, you cannot - without great difficulty - use a fraction of an egg. The calcula
Lera25 [3.4K]
The answer is one ☝️ question for the poll of a vote
5 0
2 years ago
At higher doses what behaves like PCP causing feelings of power and invulnerability
ser-zykov [4K]
I don't think any answer would be correct, if you have an option "none of the above" then that would be the correct answer
5 0
3 years ago
A user logging on, an application server connecting to a database server, an authentication server rejecting a password, or an a
ser-zykov [4K]
<span>The answer is Event.  A user logging on, an application server connecting to a database server, an authentication server rejecting a password, or an antivirus scanner reporting a suspected virus are all examples of Event.
</span>
4 0
3 years ago
What’s the difference between an entry-condition loop and an exit-condition loop? Which kind is each of the C loops? Provide a d
egoroff_w [7]

Explanation:

The difference between entry condition loop is and exit - condition loop is that the entry condition loops first checks the condition to enter the loop body if the condition true then the loop body is executed otherwise loop body is not executed while the exit-condition loops first executes the loop body and then the condition for the loop is checked.

There are three loops in C that are as following:-

  1. For
  2. While
  3. Do While

Among these three loops While and For loops are entry condition loops and Do While loop is exit condition loop.

For example:-

for(int i=0;i<10;i++)

{

    printf("%s","John Doe\n");

}

If the initial value of i should have been 10 then loop body didn't had executed.

int i=0;

while(i<4)

   {

       printf("%s","John Doe\n");

   }

If you try to run this while loop nothing will print on the screen because the condition is false.So the compiler will not enter the loop body and will skip over it.

int i=5;

   do{

       printf("%s","John Doe\n");

   }while(i<4);

Even if the condition is false.You will see that the John doe have been printed one time on the screen because first the body is executed then the condition is checked.

7 0
2 years ago
A computer has a cache and main memory. 20 ns are required to reference a word that is in the cache. If the word is in main memo
Alecsey [184]

Answer:

T_{average} =12026ns

Explanation:

Given Information:

T_{cache}=20 ns

T_{main}=60ns

T_{disk} =12ms=12,000,000ns

hit_{cache} =0.9

miss_{cache} =1-0.9=0.10

hit_{main} =0.99

miss_{main} =1-0.99=0.01

There are 3 possible cases

1. Location of reference word is in cache

T_{cache}*hit_{cache} =20*0.9=18ns

2. Location of reference word is not in cache but in main memory

(T_{cache}+T_{main})*(miss_{cache}*hit_{main}) =(20+60)*(0.10*0.99)=7.92ns

3. Location of reference word is neither in cache nor in main memory

(T_{cache}+T_{main}+T_{disk})*(miss_{cache}*miss_{main})

(20+60+12,000,000)*(0.10*0.01)=12000.08 ns

The average time required to access a referenced word on this system is simply the sum of above 3 cases

T_{average} =18+7.92+12000.08=12026ns

5 0
3 years ago
Other questions:
  • Don is the superintendent of the county school system. What task might Don
    8·1 answer
  • If the current through a heater coil is 5 amp and the supply voltage is 120 volts, the coil resistance is A. 0.04 ohm. B. 24 ohm
    6·1 answer
  • You need to immediately terminate process id 2129. which command should you use?
    15·1 answer
  • Terms that represents the achual speed used by device to transfer data​
    14·1 answer
  • Wich technology can a website use to allow you to listen to a concert live over the internet?
    10·1 answer
  • Whoever understands this first and replies will be the brainliest.<br><br><br><br> Road work ahead?
    9·2 answers
  • 1. Write program, WriteData.java, that writes the following data to file books.txt. Include the semicolons. Fiction;Abraham Linc
    11·1 answer
  • In c++ 11, the ________ tells the compiler to determine the variable's data type from the initialization value.
    6·1 answer
  • How do I start conversations with ppl??? If u answer right I will try send u more points... So please help me
    7·1 answer
  • High level languages are closer to machine language than humans yes or no​
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!