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
Which is the correct notation to specify the following inheritance?
Alika [10]

Answer:

Create the student class object which inherit the printinfo() from the abstract class People

Explanation:

Classes in object-oriented programming are blueprints of a defined type of data structure.

An object of an abstract class cannot be instantiated. So, the People class in question, is only inherited by the Student class which able to use the define printinfo() method.

4 0
3 years ago
Which of the following grinding methods is best suited to a shorter cylindrical workpiece?
schepotkina [342]
well i dont know but i would go with b :D

4 0
3 years ago
I Need an experienced or inspired game developer to answer these questions
Ivahew [28]

Answer:

WHAT ARE u trying to work for dm me on discord RealFazeRug#4361 and ill help ya m8 because im good with tech lol

Explanation:

5 0
4 years ago
What is the difference between a learner’s license and a driver’s license?
kirill115 [55]

privilege to operate a motor vehicle-drivers License

Able to get when 15. Valid for 1 yr. Allows you to drive with a parent in the car. $15. Bring social security and birth certificate to the DLD. Have for 6 months (and do 40 hrs) before getting license.-Learner Permit

4 0
3 years ago
A new company is upgrading a media workstation. The computer will be predominantly used for graphic intensive presentations, sli
Lilit [14]

Answer:

The answer is letter A

Explanation:

High-end video, high-end audio, multicore processor

4 0
3 years ago
Other questions:
  • The shortest-route technique would best be used to determine the amount of LAN network wiring within a building. determine the p
    12·1 answer
  • Your organization issues devices to employees. These devices generate one-time passwords every 60 seconds. A server hosted withi
    15·1 answer
  • On the Cities worksheet, click cell H13 and enter the function that calculates the total costs for the first city. Copy the func
    14·1 answer
  • True or False: A function with no parameters or extern vars can only return a
    8·1 answer
  • Ronald downloads a movie from the Internet onto his company's computer. During this process, his system gets infected with a vir
    12·1 answer
  • Jerry is working at the desk of a client in the marketing department of his company. The client thinks that the problem is the v
    5·1 answer
  • In which drawer can you set certain lights to light up on your micro:bit?
    12·2 answers
  • John buy cheap stolen rims for his new truck?
    11·1 answer
  • Research the significance of the UNIX core of macOS and write a few sentences describing your findings.
    8·1 answer
  • Artificial intelligence (ai) in perspective is a complex and interdisciplinary field that involves several specialties, includin
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!