**Book Description:**

**Second Edition**

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.

**Table of Contents**

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

**Sample from the book**

**35: List any two disadvantages of quicksort algorithms.**

**Answer:**

a) Performance is dependent on whether the data structure used is partially sorted

b) Computational overheads can be experienced during the execution of a recursive function when the portions are small

**36: Give two examples of any sorting quadratic algorithms.**

**Answer:**

a) Insertion sort

b) Bubble sort

**37: Between ecliuds algorithm and factorization, which one of the two techniques would you use to determine the greatest common divisor between two or more integers in positive R space?**

**Answer:**

We would use Ecliuds algorithm; as it requires fewer iterations of the algorithm.

**38: In what scenario would a quicksort algorithm exhibit a time complexity running time that is or approaches O(n2)?**

**Answer:**

This is the worst case time complexity of the quicksort algorithm; said to occur when with fairly large datasets the pivot chosen happens to be either the largest or the smallest element of the dataset.

**39: As the manager of a local bus terminal, you have been looking for ways to prioritize the seating arrangement for your fleet due to the high numbers of passengers. You decide to give priority of seats according to age, with senior citizens getting seats first and so on, up to the capacity of the bus. Which sorting algorithm would you use and why?**

**Answer:**

We can use Heap Sort algorithm; as it provides a time complexity of O(N Log N) and is well suited to priority queue data structures.

**40: What advantages does an introsort algorithm have over quicksort algorithm for large datasets where the number of elements exceeds 1,000,000; assume the elements are 32bit integers?**

**Answer:**

It has a worst case performance of O(N Log N). It is able to detect when algorithmic performance has a time complexity that approaches quadratic performance and use the heap sort algorithm to maintain O(N Log N).

**41: You are given a dataset of ordered pairs in R2 space that you would like to sort. You are interested in sorting the set by the second value of each ordered pair. Your first attempt was to use a quicksort algorithm to sort the set but you realize that that some second values in some pairs are equal. Explain why a quicksort algorithm would not be effective in such a scenario.**

**Answer:**

Quicksort algorithm would not be stable; it does not have stability inherently built in; if the second values are equal then it would be preferable that the algorithm sort the ordered pairs that have equal second value in ascending order of the first value of each pair.

**43: Using simple pseudocode, write a quicksort algorithmic function that will sort an array [x] of 9 integral values; assume that all values in the array are unique.**

**Answer:**

partition (x, size)

if size < 2

return

pivot = X [random() %size]

lbound = 0, Ubound = size-1

while lbound<ubound

while x[lbound]<pivot

lbound+=1

while x[ubound]>pivot

ubound-=1

swap (x[lbound],x[ubound])

partition (x,lbound)

partition (&x[lbound +1], size-lbound-1)