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
Vsevolod [243]
3 years ago
8

A(n) __________ is a common list operation used in programming. Its purpose is to iterate through a list of items, one item at a

time, and check each one to see if it has exactly what we are looking for.
Computers and Technology
1 answer:
34kurt3 years ago
5 0
Linear search

You implement this algorithm by iterating over each item, and checking if the item matches what you are searching for.

It is linear because it takes a linear amount of time to search for an item.
You might be interested in
Consider the following code segment.
m_a_m_a [10]

Answer:

10 20                                                                                                                          

30 40                                                                                                                          

50 60

Explanation:

Given

The above code segment

Required

What is printed, if anything

To do this, we analyze the code line by line.

Line 1: The first line creates a 4 by 3 array named mat

Line 2: for (int[] row : mat) {  -> This creates row[] array which represents each row of array mat

Line 3: for (int j = 0; j < row.length; j += 2){ -> This iterates through the even indexed elements of the row array i.e. 0 and 2

Line 4: System.out.print(row[i] + " "); -> This prints the even indexed elements of the row array.

The even indexed elements are: 10, 20, 30, 40, 50 and 60

Line 5: System.out.println(); --> This prints a new line

8 0
3 years ago
Assume that you have 22 slices of pizza and 7 friends that are going to share it (you've already eaten). There's been some argum
xz_007 [3.2K]

Answer:

In Python:

numberOfWholeSlices = int(22/7)

print(numberOfWholeSlices )

Explanation:

For each friend to get a whole number of slices, we need to make use of the int function to get the integer result when the number of slices is divided by the number of people.

So, the number of slice is: 22/7

In python, the expression when assigned to numberOfWholeSlices  is:

numberOfWholeSlices = int(22/7)

Next, is to print the calculated number of slices

print(numberOfWholeSlices )

4 0
3 years ago
U GET BRAINLIEST HELP PLZ
Art [367]
BOTH OF THEM ARE C : )
3 0
3 years ago
Write a function `has_more_zs` to determine which of two strings contains # more instances of the letter "z". It should take as
nekit [7.7K]

Answer:

// Method's name: has_more_zs

// Parameters are text1 and text2 to hold the two phrases to be tested

public static String has_more_zs(String text1, String text2) {

 // Create and initialize z1 to zero

 // Use z1 to count the number of zs in text1

 int z1 = 0;

 // Create and initialize z2 to zero

 // Use z2 to count the number of zs in text2

 int z2 = 0;

 

 //Create a loop to cycle through the characters in text1

 //Increment z1 by one if the current character is a 'z'

 int i = 0;

 while (i < text1.length()) {

  if (text1.charAt(i) == 'z' || text1.charAt(i) == 'Z') {

   z1 += 1;

  }

  i++;

 }

 //Create a loop to cycle through the characters in text2

 //Increment z2 by one if the current character is a 'z'

 

 i = 0; //Re-initialize i to zero

 

 while (i < text2.length()) {

  if (text2.charAt(i) == 'z' || text2.charAt(i) == 'Z') {

   z2 += 1;

  }

  i++;

 }

 

 

 //Using the values of z1 and z2, return the necessary statements

 if (z1 > z2) {

  return "The phrase '" + text1 + "'" + " has more occurences of z than the phrase " + "'" + text2 + "'";

 }

 else if (z1 < z1) {

  return "The phrase '" + text2 + "'" + " has more occurences of z than the phrase " + "'" + text1 + "'";

 }

 else if (z1 == z2) {

  return "The strings have the same number of z";

 }

 else {

  return "Neither string contains the the letter z";

 }

}

Explanation:

Explanation to answer has been given in the code as comments. Please refer to the comments for the details of the code.

The source code file has been attached to this response and saved as "NumberOfZs.java"

Hope this helps!

Download java
5 0
3 years ago
Select the invalid declaration from the lines of Java code below
yarga [219]

Answer:

float avg = 23.5;

Explanation:

Given

The declarative statements

Required

Determine which of them is invalid

<em>Analyzing them one after the other;</em>

int zebraCnt = 40000;

This statement is valid as zebraCnt is correctly declared as type integer

<em></em>

long birdCnt = 222_222_222_222_222L;

This statement is valid as birdCnt is correctly declared as type long

float avg = 23.5;

This statement is invalid as avg is incorrectly declared as type float.

<em>To correctly declare avg, you either change the datatype to double: as follows;</em>

double avg = 23.5;

or <em>append f to the declaration; as follows</em>

float avg = 23.5f;

double avg = 98.32121;

This statement is valid as avg is correctly declared as type double

Hence, the incorrect declarative statement is float avg = 23.5;

8 0
3 years ago
Other questions:
  • What is the device that allows users to manipulate data by controlling an onscreen pointer
    5·2 answers
  • Which phase takes all the detailed design documents from the design phase and transforms them into the actual system? Testing ph
    7·1 answer
  • How to change font size and style and add a table when creating a webpage?
    6·1 answer
  • You have just made changes to a GPO that you want to take effect as soon as possible on several user and computer accounts in th
    7·1 answer
  • Which of the following savings vehicles usually requires a high minimum balance?
    12·1 answer
  • BRALYEST TO FIRST PERSON THAT IS CORRECT!!! Select the correct navigational path to add titles to your printable worksheet. Clic
    9·2 answers
  • C programmig : Output all combinations of character variables a, b, and c, using this ordering:abc acb bac bca cab cbaSo if a =
    12·2 answers
  • Different between embedded computer &amp;<br> Micro controllers
    8·1 answer
  • Describe two steps to find if photos can be legally used
    15·1 answer
  • Scott sends his backups to a company that keeps them in a secure vault. What type of backup solution has he implemented?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!