Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer all parts of the question (a) Consider the following algorithm: Input: n (a non-negative integer), A[0], A[1], A[2], ellipsis, A[n] (a array of

Please answer all parts of the question

image text in transcribedimage text in transcribed

(a) Consider the following algorithm: Input: n (a non-negative integer), A[0], A[1], A[2], ellipsis, A[n] (a array of an integers). for I = 0 to n for j = I + 1 to n if (A[i] + A[j] = k) return true return false (i) What does the algorithm compute? (ii) Express the worst-case running time of the algorithm using the Big-Oh notation. Give details of your working. (iii) If it takes 10 seconds to run the algorithm on an array of 10000 elements, how long will it take to run the algorithm on an array with 40000 elements? (b) Prove or disprove each of the following statements. (i) log n! = O(nlog(n)) (ii) If f(n) is O(g(n)), then g(n) is O(f(n)) (c) (i) A pointer start points to the first clement of a singly-linked list L.Write an algorithm that inserts a new node (with data field val) at thebeginning of the linked list L and returns start. What is the worst-caserunning time of your algorithm? (ii) A priority queue is implemented using an array. Items stored in thearray are ordered by the values of their keys in non-decreasing order.Write an algorithm to insert a new item with a specified key into thearray

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

Students also viewed these Databases questions