Question

Find and explain an example of some programming processing task that demonstrates one of the common...

Find and explain an example of some programming processing task that demonstrates one of the common growth rate functions.

For example, the constant time function describes a task in which the work steps are the same regardless of the amount of input.
The linear time function describes a task in which the work steps grow just as much as the input size does ('1 for 1').
The quadratic time function describes a task in which the work steps grow by as much as the square of the input size (e.g. 4 work steps are required it the input size is 2, 9 steps required for 3).

It is important in thinking about this topic to look at a problem or algorithm, decide on the meaningful work steps it does, then look at how much the work steps grow as the input size increases.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The three time functions described above are constant time function, linear time function, quadratic time function. The time complexity is generally measured by the number of elementary operations a program has to perform .The elementary functions will have a prefixed value of time to perform. Let's go through them one by one.

Constant time function:

Constant time function indicates the time to perform a operation is constant i.e O(1). Also it can be noted that only the programs which take O(1) are not called constant but also programs which take fixed amount of time for whatever the input are also called as constant time functions. For example addition of two numbers can be completed in O(1) time and at the same point exchanging of two values i.e swapping of numbers also takes a constant time regardless of the input given.

So we can say if T(n) is O(constant value) which is noted as T(n) is equal to O(1) then it's a constant time function.

Linear time function:

A program is said to be varying in linear time function if it's time complexity is O(n). Also it can vary along with a constant c i.e if the size of input n increases then time complexity may increase by O(cn) which is linear time. The most common example is to add the elements in a list. If the size of the list increases then time to add them also increases linearly. Most of the programs both in software and hardware have to be solved in linear time or nearly linear time for effective functioning. Content addressable memory is an algorithm which runs in linear time. It reads the input and stores them and also check the input with already stored values and returns their address if they are present. This is used in boyer-moore algorithm.

Quadratic time function:

It represents a program whose time complexity changes square of the input size. If the size of input is n then t(n) is equal to O(n²). This occurs when we nest over the multiple iterations over the given input.

Var hasDuplicates= function (array){

for(var i=0;i<array.length;i++){

var element=array[i];

if(array.slice(i+1).indexOf(element)!==-1)

return true;

else

return false;

}

This is a very good example of quadratic time function because we are searching through the array twice. Firstly we are iterating through the array using for and in the if statement we are passing the rest of array to find the element thus it's taking quadratic time.

Add a comment
Know the answer?
Add Answer to:
Find and explain an example of some programming processing task that demonstrates one of the common...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming Concepts cin/cout variables/types Functions Reference structs Task Summary: For this first Quest you I have...

    Programming Concepts cin/cout variables/types Functions Reference structs Task Summary: For this first Quest you I have set up a program in Visual Studio that will use operation between fractions. I have written a basic code example that does all the resources that you need to follow. Your job is to complete the exercises presented below in quest2.cpp. For this assignment you will learn and demonstrate how to: Work with functions use Past-by-Value and Past-by-Reference. use structs. use cin to get...

  • this is the page no. 255 .. can some one please help me with please. just...

    this is the page no. 255 .. can some one please help me with please. just give a way to do it assuming that we have add algs4.jar. thank you!! As a general r libraries provided by the authors of our text in algs4.jar. However, java.util.Arrays.sort(), should be used as indicated below ule for programming assignments for this class, you should feel free to use the Exercise Comparing Sorting Methods . The purpose of this exercise is to get a...

  • This problem demonstrates the use of import module. The Python programming language has many strengths, but...

    This problem demonstrates the use of import module. The Python programming language has many strengths, but one of its best is the availability to use many existing modules for various tasks, and you do not need to be an experienced computer programmer to start using these modules. We have given you some incomplete code; note that the very first line of that code contains an import statement as follows: import math This statement enables your program to use a math...

  • Detecting Substrings (C++ Version) Introduction A very common task that is often performed by programs that...

    Detecting Substrings (C++ Version) Introduction A very common task that is often performed by programs that work with text files is the problem of locating a specific substring within the file. I am sure we’ve all done this many times when working with Word, Notepad, or other editors. Since we don’t have a GUI or other means of displaying the contents of a file all at once, let’s modify the problem slightly. Rather than locating a specific substring within a...

  • Summary Write a program that demonstrates the skills you’ve learned throughout this quarter. This type of...

    Summary Write a program that demonstrates the skills you’ve learned throughout this quarter. This type of project offers only a few guidelines and requirements, allowing you to invest as much time, effort and imagination as you want.  Submit your java programs (*.java) and any other I/O (*.txt) via Canvas  You’ve worked quite hard to make it this far, so have a bit of fun with this project! Design Brief: Use Case Scenario You are hired to develop a...

  • C++ please Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require...

    C++ please Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require that you read in an encrypted message from a file, decode the message, and then output the message to a file. The encryption method being used on the file is called a shift cipher (Info Here). I will provide you with a sample encrypted message, the offset, and the decrypted message for testing. For this project I will provide you main.cpp, ShiftCipher.h, and ShiftCipher.cpp....

  • C++ Programming Question: This programming assignment is intended to demonstrate your knowledge of the following: ▪...

    C++ Programming Question: This programming assignment is intended to demonstrate your knowledge of the following: ▪ Writing a while loop ▪ Write functions and calling functions Text Processing [50 points] We would like to demonstrate our ability to control strings and use methods. There are times when a program has to search for and replace certain characters in a string with other characters. This program will look for an individual character, called the key character, inside a target string. It...

  • Programming in C with comments/steps 1. Overview The purpose of this assignment is to give you...

    Programming in C with comments/steps 1. Overview The purpose of this assignment is to give you some experience with writing functions that take in arguments and return values, as well as writing a program that consists of multiple files. This assignment also requires the use of a switch statement, in addition to more practice with printf& scanf declaring variables, using loops, and using logical expressions. For this assignment, you will prompt the user in the main function to enter their...

  • Programming Assignment 6: A Python Class, Attributes, Methods, and Objects Obiectives .Be able to...

    I need some help with programming this assignment. Programming Assignment 6: A Python Class, Attributes, Methods, and Objects Obiectives .Be able to write a Python class Be able to define class attributes Be able to define class methods .Be able to process input from a text file .Be able to write an application using objects The goal of this programming assignment is to develop a simple image processing application. The application will import a class that creates image objects with...

  • CSE 002: Fundamentals of Programming Spring 2020 Homework Assignment 6: Objectives. The objective of this homework...

    CSE 002: Fundamentals of Programming Spring 2020 Homework Assignment 6: Objectives. The objective of this homework is to give you practice with writing while, for, and do-while loops. You may find it helpful to work through the check point questions embedded in the chapter, and to practice on homework problems from the text that we have not assigned. Note that solutions to the even-numbered problems are available on the book’s student resource website as described on page xii. All homework...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT