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
OleMash [197]
2 years ago
8

Brian has created the following selection sort class in Java. In which line is the index of the smallest value returned? In whic

h line is the input array given as an argument?
public class SelectionSort{
private static int positionMin (int] vals, int startPosition) {
int minPosition startPosition;
for (int i startPosition; i
if (vals[i] vals[min Position]) {

minPosition = i;
return min

Position; private static void swap(int] vals, int firstPosition, int secondPosition) {

int temp; temp vals[firstPosition];
vals[firstPosition] vals[second Position];
vals[secondPosition] temp return public static void selSort(int| vals) {
int minPos for (int startPos 0; startPos< vals.length; startPos++){

minPos positionMin(vals,startPos); swap(vals,startPos, min Pos) ;

for (int i 0; i< vals.length; i++) { if(i
}else Jelse { System.out.println(vals[i]); } }; }

return; } }
Computers and Technology
1 answer:
katen-ka-za [31]2 years ago
8 0

Answer:

Explanation:

Since there are no line numbers in this question I will start counting from public class SelectionSort{ as line 1 and so on, as well as provide the code on that line.

The index of the smallest value is returned on line 8 where it says return min which shouldn't have any spaces and should be return minPosition;

The input array is given as an argument at the beginning of the function on line 2 where it says private static int positionMin (int] vals, int startPosition) {, as the variable vals.

This input array is also used as an argument on line 10 where it says Position; private static void swap(int] vals, int firstPosition, int secondPosition) and line 15 where it says vals[secondPosition] temp return public static void selSort(int| vals) {

You might be interested in
Write a bool function isPalindrome that takes one string parameter and returns true if that string is a palindrome and false oth
kkurt [141]

Answer:

Here is the bool function isPalindrome:

bool isPalindrome(string s)

{  bool palindrome;      

 int j;

 int len = s.length();

 for (int i =0, j= len-1; i < len/2; i++, j--)  

   if (s[i] == s[j])

     palindrome = true;  

   else

     palindrome = false;

 return palindrome; }

Explanation:

The bool function isPalindrome takes a string as parameter and returns true if the string is a palindrome or false if the string is not palindrome. The string variable s holds the string value. In function isPalindrome, there is a bool type variable palindrome. bool is a data type which is used to hold values true or false which is then stored in the palindrome variable.

Next it is being found that how many characters are there in the input string using length() function which returns the length of the string. The length of the string is stored in int type variable len.

Next the for loop starts which has two variables i and j where i starts at 0 position of the input string and j starts at the last position of the string. These two variables move or traverse along the string this way. i variable stops when half the length of the input string is reached. At the end of every iteration i moves forward by the increment of its value to 1 and j moves backwards by the decrement  of its value to 1.

Every the body of  the loop executes, there is an if condition in the body of the loop which checks if the string is a palindrome. This is checked by matching the character at position/index i with the character at position j of the string. This will continue character by character until the i reached half the length of the input string and if every character in i was matched to every character in j then palindrome = true; statement is executed which returns true as the string is a palindrome otherwise palindrome = false; is returned as the string is not a palindrome.

For taking input string from the user and to check if the function isPalindrome() works correctly a main() function is written which takes input string from the user and reads in variable str calls isPalindrome() function. If the string is palindrome then the cout statement in main() function prints the message: String is a palindrome and if the input string is not a palindrome the the following message is displayed in the output screen: String is not a palindrome

int main()

{

string str;

cout<<"Enter a string: ";

cin>>str;

if(isPalindrome(str))

cout<<"String is a palindrome";

else

cout<<"String is not a palindrome";

}

The screenshot of the program along with the output is attached.

7 0
2 years ago
2.<br> The force of impact is
NNADVOKAT [17]

Answer:

lực ( Tiếng Anh : force ) là bất kỳ ảnh hưởng nào làm một vật thể chịu sự thay đổi, hoặc là ảnh hưởng đến chuyển động, hướng của nó hay cấu trúc hình học của nó.

Explanation:

7 0
3 years ago
I. Name and describe two options in Orientation.
goldfiish [28.3K]

Answer:

Page orientation is the direction in which a document is displayed or printed. The two basic types of page orientation are portrait (vertical) and landscape (horizontal). Most monitors have a landscape display, while most documents are printed in portrait mode.

Explanation:

3 0
3 years ago
What is the output of the following query? SELECT INSERT ('Knowledgeable', 5, 6, 'SUPER');
Scrat [10]

Answer:

The above query gives an error.

Explanation:

  • The query gives an error because is not the correct syntax of the select or inserts query.
  • The syntax of the select query is as follows: "select Attributes_1_name, Attributes_2_name,...., Attributes_n_name from table_name;".
  • The syntax of the insert query is : "insert into table_name (column_1_name, column_2_name,...,column_n_name) values (column_1_value, column_2_value,...,column_n_value);".
  • The syntax of the insert and select query is : "insert into table_name (select Attributes_1_name, Attributes_2_name,...., Attributes_n_name from table_name);".
  • But the above query does not satisfy any property which is defined above. Hence it gives a compile-time error.
6 0
3 years ago
1) what are two functions of a pick or count condition?
anastassius [24]
1. The answer is C. Pick an object at random, and keep track of how many copies of an object are left in a game.

2. The answer is D. Clockwise and counter clockwise.

3. The answer is B. To play an object's animation.

I hope you find this helpful.
5 0
2 years ago
Other questions:
  • What is one example of technology influencing health​
    9·1 answer
  • When building systems, the only two entities that constitute software engineering are people and process.
    9·1 answer
  • How to reply to text from unknown number?
    11·1 answer
  • Given the lists list1 and list2, not necessarily of the same length, create a new list consisting of alternating elements of lis
    10·1 answer
  • Which guidelines should be used to make formatting tasks more efficient?
    15·2 answers
  • How do I make my own extension for chrome?
    7·1 answer
  • What does the following loop do?
    5·1 answer
  • A collection of wiress connecting the CPU with main memory that is used to identify particular location is called
    13·1 answer
  • Using complete sentences post a detailed response to the following.
    13·1 answer
  • The _____ feature enables you to represent text as colorful visuals.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!