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
rewona [7]
4 years ago
8

Given an list of N integers, Insertion Sort will, for each element in the list starting from the second element: Compare the ele

ment with the previous element If the previous element is greater than the element in question (EIQ), push the index of the previous element up 1 Repeat step two with the element before the previous element, and so on. Once an element has been reached that is less than the EIQ, stop pushing and insert the EIQ into the spot ahead of this element (or at the beginning of the list, if it is reached instead).

Computers and Technology
1 answer:
Elena L [17]4 years ago
8 0

Answer:

def insSort(arr):

ct=0;

for i in range(1, len(arr)):

key = arr[i]

j = i-1

while j >=0 and key < arr[j] :

arr[j+1] = arr[j]

j -= 1

ct=ct+1;

arr[j+1] = key

return arr,ct;

print(insSort([2,1]))

Output of the program is also attached.

You might be interested in
Which career field has grown most as a result of technological changes?
kondaur [170]
It's A, Service, I just watched a video and it said Service grew the most as technology has advanced 

5 0
3 years ago
Which of the following statements is true?a. Old paper documents, which were previously only available offline, are increasingly
alekssr [168]

Answer:

i believe its d

Explanation:

i took it before and i got 100

3 0
4 years ago
You and a few friends are having a meal at a pizza restaurant, and the server has just given you the bill. Write a function that
cestrela7 [59]

Answer:

How to calculate the total cost of the meal

For bill inclusive of tax, cost1=cost*(1+tax percentage)

For bill inclusive of tax and tip, cost2=cost1*(1+tip percentage)

Meal cost =(pizza cost*(1+tax percentage))*(1+tip percentage)

Now how to calculate the cost per person

cost per person=meal cost/ number of people.

C language code to solve the above problem is given below with appropriate comments for explanation

Explanation:

#include<stdio.h>

float split_bill(int cost,float tax)

{

//Declaring number of people as int

int number;

//Prompting for number of people

printf("Enter number of people ");

scanf("%d",&number);

//Declaring tip percentage as float

float tip_percent;

//Prompting for tip percentage

printf("Enter tip percentage between 0 and 1 ");

scanf("%f",&tip_percent);

//Calculating total meal cost

float meal=(((float)cost)*(1+tax))*(1+tip_percent);

//Printing total cost of meal

printf("Total cost of meal: %0.2f ",meal);

//Calculating cost per person

float cost_per_person=meal/number;

//Returning cost per person to main function

return cost_per_person;

}

int main()

{

//Declaring pizza cost as int and tax percentage as float

int pizza_cost;

float tax_percent;

//Prompting user for pizza cost

printf("Enter billing amount of pizza ");

scanf("%d",&pizza_cost);

//Prompting user for tax percentage

printf("Enter tax percentage between 0 and 1 ");

scanf("%f",&tax_percent);

//Printing the cost per person by calling the function split_bill

printf("Total cost per person is: %0.2f ",split_bill(pizza_cost,tax_percent));

return 0;

}

8 0
3 years ago
Insert Into invoices (vendor_id, invoice_number, invoice_total, payment_total, credit_total, terms_id, invoice_date, invoice_due
FinnZ [79.3K]

Answer:

There are few values in the list. So, this insert statement will not be executed.

Explanation:

4 0
3 years ago
Read 2 more answers
Hey, wanna pair our account on Brainly so we can share the perks? https://brainly.com/invite/8db681239ab5027e03b097bcded13755?ut
sashaice [31]

Answer:

Explanation:

NO Thx

8 0
3 years ago
Read 2 more answers
Other questions:
  • Consider a load-balancing algorithm that ensures that each queue has approximately the same number of threads, independent of pr
    14·1 answer
  • What’s a sign you should talk to an adult about your online time
    14·2 answers
  • What is the advantage of using a high-level language over machine language for writing computer programs?
    15·2 answers
  • What is the purpose of interrupts? How does an interrupt differ from a trap? Can traps be generated intentionally by a user prog
    11·1 answer
  • What is a prototype ?
    9·1 answer
  • PLEASE HURRY!!!!!!!!!! WILL MARK BRAINLIEST!!
    13·1 answer
  • Which utility is used to transform a standalone Windows Server 2012 R2 system into an Active Directory domain controller?
    6·1 answer
  • 1. Haruto was a programmer working in the early 2000s. Which kind of program or language was
    5·1 answer
  • Need the answer ASAP!!! I’ll mark brainliest if correct
    12·2 answers
  • I am trying to do a python code quiz for school, the basic requirements for the quiz are: the quiz MUST have 10 questions
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!