## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Ratings:

118 pages1 hour

Algorithms Interview Questions You'll Most Likely Be Asked is a perfect companion to stand ahead above the rest in today’s competitive job market. Rather than going through comprehensive, textbook-sized reference guides, this book includes only the information required immediately for job search to build an IT career. This book puts the interviewee in the driver's seat and helps them steer their way to impress the interviewer.

Includes:

a) 250 Algorithms Interview Questions, Answers and Proven Strategies for getting hired as an IT professional

b) Dozens of examples to respond to interview questions

c) 51 HR Questions with Answers and Proven strategies to give specific, impressive, answers that help nail the interviews

d) 2 Aptitude Tests download available on www.vibrantpublishers.com

Publisher: Vibrant PublishersReleased: Oct 31, 2011ISBN: 9781466076556Format: book

*****

**1: What do you understand by the term time complexity in the design and analysis of algorithmic functions? **

**Answer: **

Time complexity is a function of the computational growth and use of computational resources as the number of iterations of a given algorithmic procedure increases.

**2: Why would you need to calculate the time complexity of the best & worst performance of using a given algorithmic procedure on a dataset? **

**Answer: **

It is done to determine the optimum (efficient use of storage and time) algorithm to use to solve a given problem, and to determine whether a given algorithm would be scalable to large input datasets.

**3: You are the clerk at a voting station. After millions of votes are cast at your station into the ballot, you want to determine the oldest and youngest age of voters at your station. Having chosen an algorithm to use, what is the WORST performance you are likely to achieve with it and why? Assume that the order in which the votes were cast is irrelevant and that the age is expressed as a 32bit integer? **

**Answer: **

Sort the dataset according to age ascending and select the first and kth element in the dataset. Accounting for the possibility that during a partition operation using a quicksort algorithm, that the oldest or the youngest is selected as the pivot, the worst case time complexity would be Ω(N).

**4: Efficiency of the quality control department has dropped significantly; as a result, the company has lost millions in consumer call-backs. As the head of IT, you've been asked to design a computer program that can conduct quality control checks using the standard quality control checklist for the organization’s products. From your preliminary observation, what’s the best case performance you can get out of an algorithm that can achieve this and why? **

**Answer: **

O(nlogn); the algorithm will compare the properties of the product against pre-determined quality properties and see if the product either meets, doesn't meet or exceeds those.; this is a comparison sort problem.

**5: If you were able to design an algorithm that could return 98,760,300 records in 7 seconds, out of 100,000,000 records and 395,041,200 in 28 seconds, what class would you say the best time complexity of the algorithm falls in? **

**Answer: **

O(N); because the algorithm’s growth appears proportional.

**6: The new PABX system allows you to create functions and algorithms that can be used to search for staff members given a surname since the contact details of each staff member is indexed in the directory. You implement a dichotomic algorithm to return the results of a search. What’s the best and average running time that you are likely to achieve and why? Assume the PABX already stores the contact details as a sorted dataset and that all surnames are unique. **

**Answer: **

O(1) at best and O(log N) on average using a BST; As the contacts are already in the index, the algorithm will look up the search against the stored keys halving the sample space at each iteration.

**7: What is the best running time complexity that a binary search can achieve? **

**Answer: **

The best running time complexity that a binary search can achieve is O(N Log N)

**8: While searching for strings in a dataset that contains values that are arranged in alphabetical order, what is the best running time that one can achieve with an implemented algorithm? **

**Answer: **

O(n) as the time complexity is directly proportional to the size of the dataset.

**9: What are the most important factors to consider when implementing an algorithmic function that utilizes a very large dataset? **

**Answer: **

Time complexity, the storage space and memory available for the data types are the important factors to consider.

**10: Why do we neglect constants when using asymptotic notation to evaluate time and space complexity of any given algorithm? **

**Answer: **

Constants refer to procedures or functions outside the bounds of the algorithm; the constants refer to parts of the algorithm whose complexity will always be O(1) regardless of the number of iterations required to complete the algorithm relative to the input size. That is the reason we neglect constants during evaluation.

**11: Where big O notation gives us the upper bounds of an algorithmic function, what notation would be used to give the lower bounds of the same algorithmic function? **

**Answer: **

Big Omega notation would be used.

**12: In performing your time and space complexity analysis of any given algorithm, what are the most important factors of the algorithm that will influence your run time analysis? **

**Answer: **

The number of operations that the algorithm must perform irrespective of the size of the input; and the size of the input itself will influence the run time analysis.

**13: List any three advantages of the quicksort algorithm. **

**Answer: **

The advantages of Quicksort Algorithm are:

a) Time complexity of O(N Log N)

b) Space complexity of O(N Log N)

c) It is an in-place algorithm that’s faster than heap and merge sort

**14: What do you understand by an algorithm which is said to have a quadratic time, best case performance? **

**Answer: **

It means that, given a set X of size N, it would take the algorithm N2 iterations to solve a problem using the elements within X.

**15: What is wrong with this statement: f(N)>= O(N2) and how would you write it in a way that makes sense? **

**Answer: **

Big O notation is used only as the upper bounds of any given function. To correct the statement, you would write

f(N)>= Ω(N2)

**16: Why is the theta notation preferred when calculating the average time and space complexities of a tightly bound algorithm? **

**Answer: **

Theta notation provides both the upper and lower time and space complexities of the given function. Hence it is preferred.

**17: Given the following expression, 19N2 + 756N16 + 4, write the Big-O notation of the time complexity for the execution of the algorithm that satisfies it and state the class of the algorithm. **

**Answer: **

O(N16); an algebraic or Polynomial algorithm.

**18: You are presented with a table in front of you that stands between you and the exit door. On the table there are four identical dishes each with four keys. One of the keys will open the exit door but you have no way of knowing which at the **

You've reached the end of this preview. Sign up to read more!

Page 1 of 1

Close Dialog## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Loading