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
pychu [463]
3 years ago
8

Given a vector and a starting position, find the index of // the smallest value in the range [start, last], where last is // vec

tor.size()-1. That index is returned.
Computers and Technology
1 answer:
marusya05 [52]3 years ago
7 0

Answer:

The solution code is written in Python

  1. def findSmallest(vec, start):
  2.    index = start
  3.    smallest = vec[start]
  4.    for i in range(start + 1, len(vec)):
  5.        if(smallest > vec[i]):
  6.            smallest = vec[i]
  7.            index = i
  8.    return index

Explanation:

Firstly we can define a function findSmallest() that takes two input parameters, a vector, <em>vec</em>, and a starting position, <em>start </em> (Line 1).

Next, create two variables, <em>index</em> and <em>smallest</em>, to hold the current index and current value where the smallest number is found in the vector. Let's initialize them with <em>start</em> position and the value held in the<em> start </em>position (Line 3-4).

Next, create a for-loop to traverse through the next value of the vector after start position and compare it with current <em>smallest </em>number. If current <em>smallest</em> is bigger than any next value in the vector, the <em>smallest </em>variable will be updated with the new found  lower value in the vector and the index where the lower value is found will be assigned to variable<em> index</em>.

At the end return index as output.

You might be interested in
The _____ is a computer-based test that measures the degree to which you associate particular groups of people with specific cha
scoray [572]

Answer:Implicit Association Test (IAT)

Explanation:Implicit Association Test is the sort of test that is made for the analyzing the thoughts and beliefs of group of people . It is basically performed because of displaying the unknown facts or attitude which people don't want to display or don't want to report.

Implicit Association Test (IAT) is the test that helps in bringing out the hidden and unreported situations or facts about the people.

3 0
2 years ago
Write a Python program string_functions.py that defines several functions. Each function re-implements Python's built-in string
Svetach [21]

Answer:

def length( mystring):

   count = 0

   for i in mystring:

       count += 1

   return count

def reversed( mystring):

   strlist = []

   for i in range(length(mystring)):

       strlist.append(mystring[(length(mystring) - 1) - i])

       txt = "".join(strlist)

   return txt

string = 'Yolanda'

print(reversed(string))

Explanation:

The python module defines two functions 'reversed' and 'length'. The length function counts the number of characters in a string variable while the reversed function reverses the string variable value.

3 0
2 years ago
Handhed computer is otherwise called as<br> 1.laptop<br> 2.Notebook<br> 3.Palmtop
NikAS [45]

Answer:

personal digital assistants (PDAs)palmtop

3 0
3 years ago
In a relational database design, all relationships are expressed by ________.
velikii [3]
Explain what is meant by a limited data set and how this HIPAA rule may affect medical assistants
8 0
3 years ago
What is a spreadsheet​
Delicious77 [7]
A spreadsheet function that indicates the average of a group of numbers in a range.
8 0
2 years ago
Other questions:
  • Write a short java method that takes an integer n and returns the sum of all the odd positive integers less than or equal to n.
    5·1 answer
  • When was unicode invented?
    13·1 answer
  • Select the correct answer.
    15·1 answer
  • In relation to data science,advances in technology has made it more feasible to do what
    5·1 answer
  • 1.printer is an example of......... device.<br><br>​
    11·2 answers
  • Which program will have the output shown below?
    7·1 answer
  • What is a web browser​
    9·1 answer
  • Which TWO of the following are input devices that are parts of a laptop computer?
    9·2 answers
  • Explain different users of computer in briefly?​
    14·1 answer
  • Anyone know why my desktop won’t turn on, I upgraded my ram and my monitor won’t turn on
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!