Question

Using Big O notation, indicate the time requirement of each of the following tasks in the...

Using Big O notation, indicate the time requirement of each of the following tasks in the worst case.

Computing the sum of the first n even integers by using a for loop

           [ Choose ] O(1) O(2n) O(n*log n ) O(2^n) O(log n) O(n^2) O(n) O(2) O(n^3)         

Displaying all n integers in an array

           [ Choose ] O(1) O(2n) O(n*log n ) O(2^n) O(log n) O(n^2) O(n) O(2) O(n^3)         

Displaying all n integers in a sorted linked chain

           [ Choose ] O(1) O(2n) O(n*log n ) O(2^n) O(log n) O(n^2) O(n) O(2) O(n^3)         

Displaying all n names in an array of linked chains

           [ Choose ] O(1) O(2n) O(n*log n ) O(2^n) O(log n) O(n^2) O(n) O(2) O(n^3)         

Displaying one array element

           [ Choose ] O(1) O(2n) O(n*log n ) O(2^n) O(log n) O(n^2) O(n) O(2) O(n^3)         

Displaying the last integer in a linked chain

           [ Choose ] O(1) O(2n) O(n*log n ) O(2^n) O(log n) O(n^2) O(n) O(2) O(n^3)         

Searching an array of n items for a particular value by using a sequential search

           [ Choose ] O(1) O(2n) O(n*log n ) O(2^n) O(log n) O(n^2) O(n) O(2) O(n^3)         

Searching an array of n items for a particular value by using a binary search

           [ Choose ] O(1) O(2n) O(n*log n ) O(2^n) O(log n) O(n^2) O(n) O(2) O(n^3)         

Adding an item to a stack of n items

           [ Choose ] O(1) O(2n) O(n*log n ) O(2^n) O(log n) O(n^2) O(n) O(2) O(n^3)         

Adding an item to a bag of n items

        [ Choose ] O(1) O(2n) O(n*log n ) O(2^n) O(log n) O(n^2) O(n) O(2) O(n^3)

Homework Answers

Answer #1

Answer :

Computing the sum of the first n even integers by using a for loop : O(n).

Displaying all n integers in an array : O(n).

Displaying all n integers in a sorted linked chain : O(n).

Displaying all n names in an array of linked chains : O(n).

Displaying one array element : O(1).

Displaying the last integer in a linked chain : O(n).

Searching an array of n items for a particular value by using a sequential search : O(n).

Searching an array of n items for a particular value by using a binary search : O(log n).

Adding an item to a stack of n items : O(1).

Adding an item to a bag of n items : O(1).

Know the answer?
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
Similar Questions
1. Given an n-element array A, Algorithm X executes an O(n)-time computation for each even number...
1. Given an n-element array A, Algorithm X executes an O(n)-time computation for each even number in A and an O(log n)-time computation for each odd number in A. What is the best-case running time of Algorithm X? What is the worst-case running time of Algorithm X? 2. Given an array, A, of n integers, give an O(n)-time algorithm that finds the longest subarray of A such that all the numbers in that subarray are in sorted order. Your algorithm...
Data Structures using C++ Searching a Linked List Here are the declarations for a simple unsorted...
Data Structures using C++ Searching a Linked List Here are the declarations for a simple unsorted linked list of ints that ends in a null pointer. //=============================================================== class Cell { friend class UList; private: int data; Cell* next; Cell( int dt, Cell* nx=nullptr ) : data(dt), next(nx) {} }; //=============================================================== class UList { private: Cell* head = nullptr;    // stationary head pointer. Cell* scan = nullptr;          // for walking down the List. Cell* follow = nullptr; public: void find( int...
For each of the following situations, which of the following ADTs would be most appropriate, and...
For each of the following situations, which of the following ADTs would be most appropriate, and explain (1) Queue ADT; (2) Stack ADT; (3) Ranked or Positional Sequence ADT; (4) None of these. a. The customers at the deli counter who take numbers to mark their turn. b. An alphabetic list of names. c. Integers that need to be sorted. d. Execution environments of a recursive method. e. The items on a cash register tape. f. A word processor that...
A Queue is a linked list with pointers to both the head of the list as...
A Queue is a linked list with pointers to both the head of the list as well as the tail (or the last element) of the list. Given a queue Q, Q.head gives the head of the queue and Q.tail gives the tail of the queue. Give O(1) time algorithms for the following tasks. Enqueue • Input: A queue Q of distinct integers and a queue element a not in Q. 1 • Output: Q with the element a added...
Q1: Thefollowing code is supposed to return n!, for positive n. An analysis of the code...
Q1: Thefollowing code is supposed to return n!, for positive n. An analysis of the code using our "Three Question" approach reveals that: int factorial(int n){ if (n == 0)     return 1;   else     return (n * factorial(n – 1)); } Answer Choices : it fails the smaller-caller question.     it passes on all three questions and is a valid algorithm.     it fails the base-case question.     it fails the general-case question. Q2: Given that values is of...
1.Determine the generation time by using the following formula : Generation time =∆ t log 2...
1.Determine the generation time by using the following formula : Generation time =∆ t log 2 Log n – log N Where: N = number of bacteria at a particular time point during log phase n = number of bacteria at a second time point during log phase ∆t = time (This question was not anwsered in my previos question that i posted , please help. ) (please check the details and information needed on this question in my prevoius...
C PROGRAMMING Doubly Linked List For this program you’ll implement a doubly linked list of strings....
C PROGRAMMING Doubly Linked List For this program you’ll implement a doubly linked list of strings. You must base your code on the doubly linked list implementation given in my Week 8 slides. Change the code so that instead of an ‘int’ each node stores a string (choose a suitable size). Each node should also have a next node pointer, and previous node pointer. Then write functions to implement the following linked list operations: • A printList function that prints...
Write a code in c++ using linear insertion following the steps below. Comment your work. 1....
Write a code in c++ using linear insertion following the steps below. Comment your work. 1.    Ask the user for the name of a file containing data. If it does not exist, the program should display an error, then ask for a new file name. Entering an asterisk (*) as the first and only character on a line should terminate the program. 2.     You can use a statically-allocated one-dimensional array of doubles for this with length 100. You...
The main goal is to implement two recursive methods, each is built to manipulate linked data...
The main goal is to implement two recursive methods, each is built to manipulate linked data structures. To host these methods you also have to define two utterly simplified node classes. 1.) Add a class named BinaryNode to the project. This class supports the linked representation of binary trees. However, for the BinaryNode class Generic implementation not needed, the nodes will store integer values The standard methods will not be needed in this exercise except the constructor 2.) Add a...
Complete the following activities and then post your responses in the Activity #5 discussion forum (link...
Complete the following activities and then post your responses in the Activity #5 discussion forum (link below). Consider a short multiple choice quiz with three items, and each item has four choices (only one of the choices is correct). Suppose that you are taking this quiz but you are completely and utterly unprepared for it. That means that you only option for the quiz is to guess the answers. Suppose you are thinking about the first item: what's the probability...