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
Hitman42 [59]
3 years ago
12

* Write a recursive function that finds the index of s2 in s1. Do not use any * string functions except for .length(), .equals()

, and .substring(). Do not use * any loops, or any data structures.
Engineering
1 answer:
ankoles [38]3 years ago
4 0

Answer:

public int indexOfStrings(String s1, String s2) {

if(s1.length() < s2.length())

return -1;

if(s1.substring(0, s2.length()).equals(s2))

return 0;

int index = indexOf(s1.substring(1), s2);

if(index == -1)

return -1;

return 1 + index;

}

Explanation:

First create the method indexOfStrings to receive 2 strings s1 and s2.

Then test with an 'if' statement to check if the length of s1 is less than s2. We hope to find the index s2 in s1 therefore s1 should be greater in length than s2. If this doesn't follow them it should return -1 showing negativity in the function.

Then with check using a substring () function with the endIndex as the length of s2 and beginIndex as 0, to see if the new substring of s1 is equal to string s2. If this true we return 0 and the method ends.

We the initialize index as integer, and repeat the function and insert the substring of s1 with a beginIndex of 1, and the second variable as s2.

We test to see if this index will be equal to -1(negative), if true we end the function.

Finally if all goes well the method returns 1 plus the index integer.

You might be interested in
This is an essential safety procedure that protects workers from injury while working on or near electrical circuits and equipme
Mice21 [21]

Answer:

Option B

Lockout/ Tagout

Explanation:

lockout and tagout is a safety procedure used in most industries and work places. This ensures that during any maintenance work, that dangerous machines are properly shut off and not able to be started up again prior to the completion of maintenance or repair work.

The procedure includes:

1. Turns off and disconnects the machinery or equipment from its energy source(s) before performing service or maintenance.

2. The authorized employee(s) either lock or tag the energy-isolating device(s) to prevent the release of hazardous energy.

8 0
4 years ago
true or false: the types of building materials that’s should be used in a project does not constitute a conditional for projects
kenny6666 [7]

Answer:

true: the types of building materials that’s should be used in a project does not constitute a conditional for projects’ permits and approvals

6 0
3 years ago
Read 2 more answers
Investiga por que esta simple actividad puede ayudar a mejorar las condiciones ambientales que tu comunidad?
skad [1K]

Creo que por simple actividad hablas de reciclar no?

Espero que sea de ayuda (:

Permite ahorrar energía de forma significativa. Es menos costoso reciclar un material que fabricarlo desde cero, como ocurre por ejemplo con el vidrio.

Reciclar ayuda a evitar la explotación de los recursos naturales. El reciclaje hace posible que los materiales originales puedan ser aprovechados con un nuevo uso, sin que sea necesario volver a usar recursos naturales para fabricarlos.

Se evitan los métodos de extracción de recursos naturales, que son invasivos y contaminantes. El reciclaje permite no sustraer nueva materia prima para fabricación y se puede simplemente reciclar la materia existente.

Se reduce la contaminación, proporcionando una atmósfera más limpia. Reciclando ayudamos a reducir el daño producido al medio ambiente.

Se conserva el medio ambiente ya que permite reducir la cantidad de desechos sólidos que llegan a los vertederos. Esto hace posible que los vertederos ocupen menos espacio e incluso puedan llegar a cerrarse, evitando el impacto negativo que causan sobre el medio ambiente.

Permite alargar la vida útil de los vertederos, ya que se llenan a un menor ritmo evitando que se abran más vertederos.

Si depositamos los desechos que generamos en el contenedor correspondiente para que sean reciclados se reducen los costes de recolección y clasificación de los residuos, ya que son las personas las que ayudan a realizar dicha labor.

En algunos centros de reciclaje ofrecen una compensación económica por llevar material reciclable, como latas y botellas de plástico, por lo que puedes obtener un pequeño ingreso extra reciclando.

7 0
3 years ago
Oxygen enters an insulated 14.2-cm-diameter pipe with a velocity of 60 m/s. At the pipe entrance, the oxygen is at 240 kPa and 2
MatroZZZ [7]

Answer:

Entropy generation==0.12 KW/K

Explanation:

s_2-s_1=C_p\ln \frac{T_2}{T_1}-R\ln \frac{P_2}{P_1}

s_2-s_1=0.891\ln \frac{291}{293}-0.2598\ln \frac{200}{240}

s_2-s_1=0.0412\frac{KJ}{kg-K}

Mass flow rate= \rho\times\dfrac{\pi}{4}d^2V

\rho_1=\dfrac {P_1}{RT_1}

\rho_1=\dfrac {240}{0.2598\times 293}

\rho_1=3.51\frac{kg}{m^3}

mass flow rate=\rho_1A_1V_1

So by putting the values

Mass flow rate=2.97 kg/s

So entropy generation=(2.97)(0.0412)

                                    =0.12 KW/K

8 0
4 years ago
Routers cannot be used to cut through material.<br><br> True<br> False
mario62 [17]

Answer:

Yes a router can be used to cut right through wood and sometimes it makes sense to do so. It leaves nice clean edges, can cut sharp curves and can follow a template

Explanation:

hope thats right

7 0
3 years ago
Read 2 more answers
Other questions:
  • Compute the estimated actual endurance strength (Sn) for SAE 3140 OQT 1000 steel bar with a rectangular cross section of w-30 mm
    6·1 answer
  • I need help with this ASAP pls help
    10·1 answer
  • Develop an E-R model (E-R Diagram) for the application belowDatabase RequirementsLogin
    12·1 answer
  • VICTV
    11·2 answers
  • Which is an alloy made up of iron and carbon and has high compressive and tensile strength?
    6·1 answer
  • What is working fluid and mention five example of working fluid.​
    14·2 answers
  • HELP ASSAPPP
    15·1 answer
  • What is valve overlap?
    5·1 answer
  • What are the three major costs of owning a vehicle throughout a year?
    12·2 answers
  • The air conditioner in a house or a car has a cooler that brings atmospheric air from 30C to 10C, with both states at 101KPa. If
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!