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
A network technician is asked to redesign an Ethernet network before some new monitoring software is added to each workstation o
mina [271]

Answer: network administrator

Explanation:

8 0
3 years ago
__________ is a term used to indicate any unwanted event that takes place outside normal daily security operations. This type of
Delvig [45]
The answer is “a security event”
6 0
3 years ago
Do laws ever change to help enforce cyber hacking crimes
prisoha [69]
No I don’t think so personally
5 0
2 years ago
Read 2 more answers
Round 74,361 to the nearest 10​
grandymaker [24]

Answer:

74,400 i think

Explanation:

8 0
3 years ago
What is mean by sole trading concern?​
DENIUS [597]

Answer:

trading as a whole

Explanation:

pls give brainlest almost lvled up.

6 0
3 years ago
Other questions:
  • What operating system allows various teams in its office to network and collaborate on projects
    5·1 answer
  • Which type of JPEG image records the most information in the digital file? Medium Low Fine Expert
    6·2 answers
  • What is the main purpose of cutting plane line arrows?
    7·1 answer
  • A company purchased a high-quality color laser printer to print color brochures and sales proposals. The printer is connected to
    5·1 answer
  • Directory services store information in a heirarchical structure. Which statements about Organizational Units (OUs) of a directo
    13·1 answer
  • In his digital portfolio, Ben wants to locate each work he created. Where can he list details about the work in his digital port
    7·2 answers
  • What does the "zoom tool" do in Photoshop?
    15·2 answers
  • Risk taker positive or negative​
    8·1 answer
  • What do you use to add a new slide to your presentation.
    11·1 answer
  • By default word documents include _______ margins on all sides of the document.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!