Skip to content
GK24
Computer AwarenessMedium

The worst-case time complexity of binary search on a sorted array of n elements is:

  1. A.O(n)
  2. B.O(n log n)
  3. C.O(log n)
  4. D.O(n squared)

Correct answer

C. O(log n)

Explanation

The correct answer is C, O(log n). Binary search compares the key with the middle element and throws away half the array at every step, so the number of comparisons grows with the logarithm of the array size; an array of a million sorted items needs about twenty comparisons. The method works only on data that is already sorted, which is the condition examiners like to test. Option A is wrong because O(n) is linear search, which looks at the elements one after another and does not need sorted data. Option B is wrong because O(n log n) is the complexity of the efficient sorting algorithms such as merge sort and heap sort, not of a search. Option D is wrong because O(n squared) describes the simple sorts, namely bubble sort, selection sort and insertion sort in their worst case. Remember that Big-O keeps only the dominant term.

Read the full article: Algorithms, Flowcharts and SDLC: Symbols, Models and PYQs

View all
Q2.Computer AwarenessEasy

In a flowchart, the oval or rounded shape is used to show:

  1. A.Start and Stop
  2. B.A subroutine call
  3. C.A decision
  4. D.The direction of flow
Show answer
Correct answer: A. Start and Stop

The oval is the terminal symbol, and a well-formed flowchart has exactly one Start terminal and at least one Stop terminal; a chart that can never reach a Stop describes an infinite loop and so breaks the finiteness property of an algorithm.

Q3.Computer AwarenessEasy

The word algorithm is derived from the name of which mathematician?

  1. A.Euclid
  2. B.Al-Khwarizmi
  3. C.Charles Babbage
  4. D.Blaise Pascal
Show answer
Correct answer: B. Al-Khwarizmi

Muhammad ibn Musa al-Khwarizmi was a ninth-century Persian mathematician and astronomer whose treatise on calculation with Hindu-Arabic numerals reached Europe in Latin translation; his Latinised name produced the word algorithm, and another of his works gave the word algebra.

Q4.Computer AwarenessAsked in: Delhi · 7 Aug 2021, Shift 1Medium

What is the other name of Linear Sequential model in software engineering?

  1. A.Spiral model
  2. B.Prototype model
  3. C.Waterfall model
  4. D.RAD model
Show answer
Correct answer: C. Waterfall model

The Waterfall model is called the linear sequential model because the project flows in one direction through requirement analysis, design, coding, testing, deployment and maintenance, with each phase completed and signed off before the next begins and no overlap between them.

Q5.Computer AwarenessEasy

Which phase of the software development life cycle produces the Software Requirements Specification (SRS)?

  1. A.Requirement gathering and analysis
  2. B.Design
  3. C.Coding
  4. D.Maintenance
Show answer
Correct answer: A. Requirement gathering and analysis

This is the first phase of the SDLC: the team meets the users, records what the system must do and what constraints apply, and sets it all down in the Software Requirements Specification, which then becomes the agreed basis for everything that follows and the yardstick for acceptance testing.