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 of the following is NOT a type of cable used in wired networks?a) Unshielded coaxialb) Coaxialc) Unshielded twisted-paird)
zysi [14]

Answer:

I think it is unshielded coaxial. Not 100% sure.

Explanation:

5 0
4 years ago
A company wants to transmit data over the telephone, but they are concerned that their phones may be tapped. All of their data i
erastovalidia [21]

Answer:

def encrypt_digit(digit):

   if type(digit) is int or float:

       digit = str(digit)

   hold = list()

   for x in digit:

       d = str((int(x) + 3)%10)

       hold.append(d)

   first = hold.pop(0)

   second = hold.pop(0)

   third = hold.pop(0)

   fourth = hold.pop()

   print(int("".join([third,fourth, first, second])))

encrypt_digit(7836)

Explanation:

The python function accepts a four-digit parameter which represents the data transmitted over the company's telephone network. The function encrypts the data by adding 3 to each digit and getting the modulus of division 10, then the digits are swapped and printed out encrypted and ready for transmission.

6 0
3 years ago
Write a recursive, string-valued method, reverse, that accepts a string and returns a new string consisting of the original stri
Ket [755]

The program is an illustration of recursive functions in Python;

Recursive functions are functions executed from within itself

<h3>The python program</h3>

The program written in python, where comments are used to explain each action is as follows:

#This defines the function

def revStr(myStr):

   #This returns an empty string if the string is empty

   if myStr == "":

       return myStr

   #If otherwise, this returns the reversed string recursively

   else:

       return revStr(myStr[1:]) + myStr[0]

Read more about python recursions at:

brainly.com/question/19089783

#SPJ1

8 0
2 years ago
Brainliest for correct answer
OLga [1]

Answer:

its the 4th sentence

Explanation:

5 0
3 years ago
Read 2 more answers
personalization allows customers to modify the standard offering, such as selecting a different home page to be displayed each t
shusha [124]
True, personalization is definitely part of this.
6 0
2 years ago
Other questions:
  • Using caller id is part of which step in an effective time management plan
    10·1 answer
  • In mathematics, the notation n! represents the factorial of the nonnegative integer n. The factorial of n is the product of all
    7·1 answer
  • You should always try to avoid showing that an animal in a zoo is a captive animal. True False
    5·1 answer
  • Which of the following are true if you pay only the minimun amount each month towards your credit card bill? You will be charged
    11·1 answer
  • In excel online what is it called when you join connecting cells together to span across more than one column and/or row?
    7·2 answers
  • Press _________ to toggle the selected range as bold​
    6·1 answer
  • What are the pros and cons for E-trade?
    15·2 answers
  • Match each role to the corresponding web development task.
    14·1 answer
  • The table shows the price of apples in the local market. What is the cost of 12 pounds of apples? Apples (pounds) Price (dollars
    13·1 answer
  • Matching parentheses. An math expression may have a number of parentheses like (, ), [, ], { and }. Each openning parenthesis (,
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!