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
zubka84 [21]
2 years ago
7

Write a method doubleUp that doubles the size of a list of integers by doubling-up each element in the list. Assume there's enou

gh space in the array to double the size.
Computers and Technology
1 answer:
Savatey [412]2 years ago
6 0

Answer:

The solution in Python is as follows:

class myClass:

    def doubleUp(self,doubleList):

         doubleList[:0] = doubleList[::2] = doubleList[1::2] = doubleList[:]

       

newlist =  []

n = int(input("Number of elements: "))

for i in range(n):

    num = int(input(": "))

    newlist.append(num)

   

list = myClass()

list.doubleUp(newlist)

print(newlist)

Explanation:

Start by creating a class

The solution in Python is as follows:

class myClass:

Then define the method doubleUp

    def doubleUp(self,doubleList):

The duplicates is done here

         doubleList[:0] = doubleList[::2] = doubleList[1::2] = doubleList[:]

The program main begins here

This defines an empty list        

newlist =  []

This prompts user for number of elements

n = int(input("Number of elements: "))

The following iteration get the elements of the list

<em>for i in range(n):</em>

<em>     num = int(input(": "))</em>

<em>     newlist.append(num)</em>

   

This defines the instance of the class

list = myClass()

This calls the method

list.doubleUp(newlist)

Lastly, this prints the duplicate list

print(newlist)

You might be interested in
why is wrong timing, poor technology, bad implementation and politics in business affected the OSI model as a standard
salantis [7]

Answer:

In the academic environment, TCP / IP was much preferred because the OSI model was thought to be inferior to the TCP/IP model

Explanation:

The following show how business affected the OSI model as a standard:

WRONG TIMING

When OSI was made, TCP / IP was already in use. Also nobody wanted to be the first to start using OSI.

POOR TECHNOLOGY

Both the presentation and session layer that was dedicated in OSI was very little.

The technology used was very difficult to understand.

BAD IMPLEMENTATION

The initial implementation of OSI model was very slow and the OSI layer 7 model had bad quality.

POLITICS

In the academic environment, TCP / IP was much preferred because the OSI model was thought to be inferior to the TCP/IP model. They where rumors that the OSI was for the European and US government.

5 0
3 years ago
Lydia used software to calculate the budget for each department. To create this budget, she used a _____.
Ann [662]
Lydia used software to calculate the budget for each department. To create this budget, she used a spreadsheet.
4 0
3 years ago
Read 2 more answers
Roger wants to give semantic meaning to the contact information, which is at the bottom of the web page. To do this he will use
Elden [556K]

Answer:

Parent

Explanation:

HTML is an acronym for hypertext markup language and it is a standard programming language which is used for designing, developing and creating web pages.

Generally, all HTML documents are divided into two (2) main parts; body and head. The head contains information such as version of HTML, title of a page, metadata, link to custom favicons and CSS etc. The body of a HTML document contains the contents or informations that a web page displays.

In this scenario, Roger wants to give semantic meaning (an element conveying informations about the type of content contained within an opening and closing tag) to a contact information placed at the bottom of a webpage. Thus, in order to do this, he should use a footer element as a parent of the contact information and as such all instance variables that have been used or declared in the footer class (superclass) would be present in its contact information (subclass object).

4 0
2 years ago
Power point how to insert diamond symbol
IceJOKER [234]
You got to "insert" and then you go to "shapes" and then you find the symbol you like and you drag and drop it onto the page. Then you can resize to the size and angle you would like it at.
4 0
3 years ago
What is the space complexity of the algorithm?ArithmeticSeries(list, listSize) { i = 0 arithmeticSum = 0 while (i &lt; listSize)
blondinia [14]

Answer:

O(n) which is a linear space complexity

Explanation:

Space complexity is the amount of memory space needed for a program code to be executed and return results. Space complexity depends on the input space and the auxiliary space used by the algorithm.

The list or array is an integer array of 'n' items, with the memory size 4*n, which is the memory size of an integer multiplied by the number of items in the list. The listSize,  i, and arithmeticSum are all integers, the memory space is 4(3) = 12. The return statement passes the content of the arithmetic variable to another variable of space 4.

The total space complexity of the algorithm is "4n + 16" which is a linear space complexity.

7 0
2 years ago
Other questions:
  • In a transaction-processing system (TPS), if the TPS database can be queried and updated while the transaction is taking place,
    12·1 answer
  • On the Insert tab, select Table &gt; _______ to create a table from selected text.
    14·1 answer
  • Research and build a chroot jail that isolates ssh users who belong to the restrictssh group. (You will also need to create the
    9·1 answer
  • 1. What are you going to do if someone ask for your personal information online?​
    12·2 answers
  • Correct all the mistakes in the following sentence:
    15·2 answers
  • Anyone know how to fix black screen of death on computer​
    6·1 answer
  • The post-closing trial balance shows the balances of only the ____ accounts at the end of the period.
    12·1 answer
  • 7. A(n) is the address of a document or other file accessible on the Internet.
    15·1 answer
  • Why do you need to put your phone on airplane mode.
    14·1 answer
  • Why is quantum computing potentially a better fit for weather forecasting than classical computers?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!