Data Structures & AlgorithmsEasyHCL · Tech Mahindra pattern
Linear search looks for a key that is NOT in an unsorted array of 100 elements. How many key comparisons does it make?
- A. 50
- B. 99
- C. 100
- D. 7
Correct answer: C. 100
To be sure the key is absent, every one of the 100 elements must be compared. 50 is the average for a successful search; 7 is the binary-search figure, which needs sorted data.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is the minimum number of stacks needed to implement a queue, if no other data structure may be used?
- What is the prefix (Polish) form of (A + B) (C − D)?
- Bubble sort is written with a flag that stops it when a full pass makes no swap. What is its time complexity on an array that is already…
- Kadane's algorithm is run on [3, −4, 5, −1, 2, −6, 4]. What maximum contiguous subarray sum does it return?
- What is the auxiliary space used by the standard top-down merge sort on an array of n elements?
- In a singly linked list you are given only a pointer to a node X (not the last node) and no head pointer. How can X be deleted, and in…