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 most common way to access the internet is through ________."
liubo4ka [24]
The most common was is your phone
6 0
4 years ago
Louis wrote a check of $100 to the electricity company. After a few days he received a Notice of Dishonor from the bank regardin
diamong [38]

the checked bounced because he didn’t have any money.

mark me brainliest please!!!!!

4 0
3 years ago
The processor in Q1 above is converted into an 8-stage pipeline, similar to the one discussed on slide 8 of lecture 16. It takes
Nadusha1986 [10]

Answer:

1000/125 billion instructions per second.

Explanation:

All the stages take 125ps and latch time was outlooked.

The clock speed would be the highest stage time in all 5 stages. Here all are same clock speed it would be 125ps only.

throughput = 1/cycle time so ⇒ 1/125 instructions/ps

Since we want it in billion instructions per second so we have to multiply with 10⁻⁹ /10⁻¹² then the result is 1000/125 billion instructions per second.

3 0
3 years ago
By definition, a computer
lapo4ka [179]

Answer has a screen

Explanation:

a computer has a screen

5 0
2 years ago
Items that represent features of smartphones apps
Anestetic [448]
I believe they are icons.
8 0
3 years ago
Other questions:
  • _____ are the supertiny on-off switches in a chip that work collectively to calculate or store things in memory. Transistors Mul
    10·1 answer
  • How to Save Power-Point presentation as a single file Web page that can be uploaded to the World Wide Web ?
    14·1 answer
  • How I can learn writing code?
    12·2 answers
  • Our readings so far explored computer hardware and software, in particular operating systems and application software. There are
    11·1 answer
  • An application with which you can perform calculations on numbers and work with other data
    8·1 answer
  • Write a program that reads a string from the user containing a date in the form mm/dd/ yyyy. It should print the date in the for
    10·1 answer
  • Write a deffrentiate between inkjet peinter and laser printer​
    8·1 answer
  • Sharl downloads images from an online library and uses them in her work. The images are shared under the Creative Commons Attrib
    13·1 answer
  • Personal statements School leaver
    15·1 answer
  • Dyn is a cloud-based internet performance management company that provides DNS services for internet websites. It was attacked w
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!