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]
3 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]3 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
Question 12 (2 points)
Gelneren [198K]
1.) narrative = a THATS all I can answer rn sorryyyy
5 0
3 years ago
Read 2 more answers
________ are viruses that masquerade as useful programs or files. hydras spyware programs worms adware programs trojan horses
Harrizon [31]
Trojan horse is the correct answer
5 0
3 years ago
Write a function int checkBalance(char exp[]); that can take an expression as input and check whether the parenthesis used in th
mylen [45]

Answer:

Explanation:

The following code is written in Java. It uses for loops to loop through the array of characters, and uses IF statements to check if the symbols in the expression are balanced. If so it returns true, otherwise it breaks the function and returns false. Two test cases have been provided in the main method and the output can be seen in the attached image below.

import java.util.ArrayList;

class Brainly {

   public static void main(String[] args) {

       char[] exp = { '[', 'A', '*', '{', 'B', '(', 'C', 'D', ')', '}', ']'};

       char[] exp2 = {'[', 'A', '*', '(', 'C', '}', ']'};

       System.out.println(checkBalance(exp));

       System.out.println(checkBalance(exp2));

   }

   public static boolean checkBalance(char exp[]) {

       ArrayList<Character> symbols = new ArrayList<>();

       for (char x: exp) {

           if ((x =='[') || (x == '{') || (x == '(')) {

               symbols.add(x);

           }

           if (x ==']') {

               if (symbols.get(symbols.size()-1) == '[') {

                   symbols.remove(symbols.size()-1);

               } else {

                   return false;

               }

           }

           if (x =='}') {

               if (symbols.get(symbols.size()-1) == '{') {

                   symbols.remove(symbols.size()-1);

               } else {

                   return false;

               }

           }

           if (x ==')') {

               if (symbols.get(symbols.size()-1) == '(') {

                   symbols.remove(symbols.size()-1);

               } else {

                   return false;

               }

           }

       }

       return true;

   }

}

3 0
3 years ago
How does the CSMA/CD protocol resolve when two network adapters on the same network transmit at the same time?
KengaRu [80]

Answer:

If two network adapters on the same network transmit at the same time, one of the adapters would stop transmitting until the second adapter has finished transmitting before retransmission

Explanation:

Carrier Sense Multiple Access with Collision Detection (CSMA/CD) is a network protocol used to prevent data collision. CSMA/CD detects collisions by sensing transmissions from other nodes. If a collision is detected, the node stops transmitting, sends a jam signal, and then waits for some time until the channel is idle before retransmission.

If two nodes on the network start transmitting at the same time, the nodes will detect the collision and take the appropriate action.

If two network adapters on the same network transmit at the same time, one of the adapters would stop transmitting until the second adapter has finished transmitting before retransmission

4 0
2 years ago
Who created Microsoft​
saveliy_v [14]

Bill Gates and Paul Allen

6 0
3 years ago
Read 2 more answers
Other questions:
  • 11. Describe an algorithm that interchanges the values of the variables x and y, using only assignments. What is the minimum num
    10·1 answer
  • Which measure should you take for the periodic maintenance of your computer? You need to invest in a for_______________ the peri
    15·2 answers
  • What is a Photojournalist
    5·1 answer
  • A _______________ is a security threat that may launch a worm through a Trojan horse or launch a denial-of-service attack at a t
    10·1 answer
  • Help me find the difference between these logos
    10·2 answers
  • -) An attribute is a(n)?
    5·1 answer
  • Two parter:
    11·1 answer
  • RAM IS often referred
    9·1 answer
  • Select the correct answer.
    6·1 answer
  • What is the definition of Graphic AIDS?.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!